diff --git a/src/MqttClass/Mqtt.php b/src/MqttClass/Mqtt.php index 932cf3f..4acb84b 100644 --- a/src/MqttClass/Mqtt.php +++ b/src/MqttClass/Mqtt.php @@ -16,6 +16,7 @@ class Mqtt protected $cert_file = null; protected $password = null; protected $port = null; + protected $debug = null; public function __construct() { @@ -24,6 +25,7 @@ class Mqtt $this->password = config('mqtt.password'); $this->cert_file = config('mqtt.certfile'); $this->port = config('mqtt.port'); + $this->debug = config('mqtt.debug'); // $this->client = new phpMQTT($this->host, $this->port, 25,$this-$this->cert_file); // $this->client = new MQTTClient($this->host,$this->port); @@ -32,7 +34,7 @@ class Mqtt public function ConnectAndSendMessage($topic, $msg) { - $client = new phpMQTT($this->host,$this->port, rand(0,100), $this->cert_file); + $client = new phpMQTT($this->host,$this->port, rand(0,100), $this->cert_file, $this->debug); if ($client->connect(true)) { diff --git a/src/MqttClass/phpMQTT.php b/src/MqttClass/phpMQTT.php index 9b09441..0b57786 100644 --- a/src/MqttClass/phpMQTT.php +++ b/src/MqttClass/phpMQTT.php @@ -48,7 +48,7 @@ class phpMQTT { private $password; /* stores password */ public $cafile; - function __construct($address, $port, $clientid, $cafile = NULL, $debug=false){ + function __construct($address, $port, $clientid, $cafile = NULL, $debug){ $this->debug = $debug; $this->broker($address, $port, $clientid, $cafile); } diff --git a/src/config/mqtt.php b/src/config/mqtt.php index 18c5a9a..99a1499 100644 --- a/src/config/mqtt.php +++ b/src/config/mqtt.php @@ -13,5 +13,5 @@ return [ 'username' => env('mqtt_username',''), 'certfile' => env('mqtt_cert_file',''), 'port' => env('mqtt_port','1883'), - 'debug' => env('mqtt_debug',false) + 'debug' => env('mqtt_debug',false) //Optional Parameter to enable debuging set it to True ];