added Example of publishing topic

This commit is contained in:
Salman Zafar 2019-02-25 14:52:53 +05:00
parent 305c0bd011
commit 28e50e2080
3 changed files with 38 additions and 8 deletions

View File

@ -2,7 +2,6 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3ec4327d-fa62-4d8e-bb03-c6240e4c966c" name="Default Changelist" comment=""> <list default="true" id="3ec4327d-fa62-4d8e-bb03-c6240e4c966c" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Readme.md" beforeDir="false" afterPath="$PROJECT_DIR$/Readme.md" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Readme.md" beforeDir="false" afterPath="$PROJECT_DIR$/Readme.md" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -38,8 +37,8 @@
<entry file="file://$PROJECT_DIR$/Readme.md"> <entry file="file://$PROJECT_DIR$/Readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="364"> <first_editor relative-caret-position="392">
<caret line="13" lean-forward="true" selection-start-line="13" selection-end-line="13" /> <caret line="14" column="1" lean-forward="true" selection-start-line="14" selection-start-column="1" selection-end-line="14" selection-end-column="1" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>
@ -126,12 +125,12 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1551080016687</updated> <updated>1551080016687</updated>
<workItem from="1551080018112" duration="3663000" /> <workItem from="1551080018112" duration="3663000" />
<workItem from="1551086427460" duration="592000" /> <workItem from="1551086427460" duration="1287000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="4255000" /> <option name="totallyTimeSpent" value="4950000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="67" y="25" width="1853" height="1055" extended-state="6" /> <frame x="67" y="25" width="1853" height="1055" extended-state="6" />
@ -204,8 +203,8 @@
<entry file="file://$PROJECT_DIR$/Readme.md"> <entry file="file://$PROJECT_DIR$/Readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="364"> <first_editor relative-caret-position="392">
<caret line="13" lean-forward="true" selection-start-line="13" selection-end-line="13" /> <caret line="14" column="1" lean-forward="true" selection-start-line="14" selection-start-column="1" selection-end-line="14" selection-end-column="1" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>

View File

@ -10,4 +10,35 @@ It uses [bluerhinos/phpMQTT](https://github.com/bluerhinos/phpMQTT) as a base.
* 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
## 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 ### Tested on php 7.3 and laravel 5.7
# Full documentation Coming Soon

View File

@ -13,5 +13,5 @@ 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 debuging set it to True 'debug' => env('mqtt_debug',false) //Optional Parameter to enable debugging set it to True
]; ];