From 28e50e2080dad8657e9e89d8dcca31ccc42c4151 Mon Sep 17 00:00:00 2001 From: Salman Zafar Date: Mon, 25 Feb 2019 14:52:53 +0500 Subject: [PATCH] added Example of publishing topic --- .idea/workspace.xml | 13 ++++++------- Readme.md | 31 +++++++++++++++++++++++++++++++ src/config/mqtt.php | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b5f2e80..95389e6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,6 @@ - - @@ -204,8 +203,8 @@ - - + + diff --git a/Readme.md b/Readme.md index 46666ba..58b0bb1 100644 --- a/Readme.md +++ b/Readme.md @@ -10,4 +10,35 @@ It uses [bluerhinos/phpMQTT](https://github.com/bluerhinos/phpMQTT) as a base. * Certificate Protection for end to end encryption * Enable Debug mode to make it easier for debugging +## Config.php +``` +'host' => env('mqtt_host','127.0.0.1'), + 'password' => env('mqtt_password',''), + 'username' => env('mqtt_username',''), + 'certfile' => env('mqtt_cert_file',''), + 'port' => env('mqtt_port','1883'), + 'debug' => env('mqtt_debug',false) //Optional Parameter to enable debuging set it to True +``` +#### Publishing topic + +``` +use Salman\Mqtt\MqttClass\Mqtt; + +public function SendMsgViaMqtt($topic, $message) +{ + $mqtt = new Mqtt(); + $final_topic = $serial.'/'.$topic; + $output = $mqtt->ConnectAndSendMessage($msg,$final_topic); + + if ($output === true) + { + return true; + } + + return false; +} +``` + ### Tested on php 7.3 and laravel 5.7 + +# Full documentation Coming Soon \ No newline at end of file diff --git a/src/config/mqtt.php b/src/config/mqtt.php index 99a1499..bf31245 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) //Optional Parameter to enable debuging set it to True + 'debug' => env('mqtt_debug',false) //Optional Parameter to enable debugging set it to True ];