Merge branch 'development'
This commit is contained in:
commit
794934bc62
|
|
@ -16,6 +16,8 @@ composer require salmanzafar/laravel-mqtt
|
||||||
* Certificate Protection for end to end encryption
|
* Certificate Protection for end to end encryption
|
||||||
* Enable Debug mode to make it easier for debugging
|
* Enable Debug mode to make it easier for debugging
|
||||||
* Now you can also set Client_id of your choice and if you don't want just simply don't use or set it to null
|
* Now you can also set Client_id of your choice and if you don't want just simply don't use or set it to null
|
||||||
|
* Set QOS flag directly from config file
|
||||||
|
* Set Retain flag directly from config file
|
||||||
|
|
||||||
## Enable the package (Optional)
|
## Enable the package (Optional)
|
||||||
|
|
||||||
|
|
@ -51,6 +53,8 @@ php artisan vendor:publish --provider="Salman\Mqtt\MqttServiceProvider"
|
||||||
'certfile' => env('mqtt_cert_file',''),
|
'certfile' => env('mqtt_cert_file',''),
|
||||||
'port' => env('mqtt_port','1883'),
|
'port' => env('mqtt_port','1883'),
|
||||||
'debug' => env('mqtt_debug',false) //Optional Parameter to enable debugging set it to True
|
'debug' => env('mqtt_debug',false) //Optional Parameter to enable debugging set it to True
|
||||||
|
'qos' => env('mqtt_qos', 0), // set quality of service here
|
||||||
|
'retain' => env('mqtt_retain', 0) // it should be 0 or 1 Whether the message should be retained.- Retain Flag
|
||||||
```
|
```
|
||||||
#### Publishing topic
|
#### Publishing topic
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ class Mqtt
|
||||||
protected $password = null;
|
protected $password = null;
|
||||||
protected $port = null;
|
protected $port = null;
|
||||||
protected $debug = null;
|
protected $debug = null;
|
||||||
|
protected $qos = 0;
|
||||||
|
protected $retain = 0;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
@ -49,6 +51,8 @@ class Mqtt
|
||||||
$this->cert_file = config('mqtt.certfile');
|
$this->cert_file = config('mqtt.certfile');
|
||||||
$this->port = config('mqtt.port');
|
$this->port = config('mqtt.port');
|
||||||
$this->debug = config('mqtt.debug');
|
$this->debug = config('mqtt.debug');
|
||||||
|
$this->qos = config('mqtt.qos');
|
||||||
|
$this->retain = config('mqtt.retain');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +65,7 @@ class Mqtt
|
||||||
|
|
||||||
if ($client->connect(true, null, $this->username, $this->password))
|
if ($client->connect(true, null, $this->username, $this->password))
|
||||||
{
|
{
|
||||||
$client->publish($topic,$msg);
|
$client->publish($topic,$msg, $this->qos, $this->retain);
|
||||||
$client->close();
|
$client->close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -81,7 +85,7 @@ class Mqtt
|
||||||
{
|
{
|
||||||
$topics[$topic] = array("qos" => 0, "function" => $proc);
|
$topics[$topic] = array("qos" => 0, "function" => $proc);
|
||||||
|
|
||||||
$client->subscribe($topics, 0);
|
$client->subscribe($topics, $this->qos);
|
||||||
|
|
||||||
while($client->proc())
|
while($client->proc())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,7 @@ return [
|
||||||
'username' => env('mqtt_username',''),
|
'username' => env('mqtt_username',''),
|
||||||
'certfile' => env('mqtt_cert_file',''),
|
'certfile' => env('mqtt_cert_file',''),
|
||||||
'port' => env('mqtt_port','1883'),
|
'port' => env('mqtt_port','1883'),
|
||||||
'debug' => env('mqtt_debug',false) //Optional Parameter to enable debugging set it to True
|
'debug' => env('mqtt_debug',false), //Optional Parameter to enable debugging set it to True
|
||||||
|
'qos' => env('mqtt_qos', 0), // set quality of service here
|
||||||
|
'retain' => env('mqtt_retain', 0) // it should be 0 or 1 Whether the message should be retained.- Retain Flag
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue