luzhuqun/laravel-mqtt-publish is a Laravel package for a simple laravel 5 mqtt publisher.
It currently has 21 GitHub stars and 9.856 downloads on Packagist.
Install it with composer require luzhuqun/laravel-mqtt-publish.
Discover more Laravel packages by luzhuqun
or browse all Laravel packages to compare alternatives.
Last updated
Mqtt is used to publish messages from backend to andriod.
composer require luzhuqun/laravel-mqtt-publish
use Lzq\Mqtt\SamMessage;
use Lzq\Mqtt\SamConnection;
$conn = new SAMConnection();//create a new connection object
$conn->connect('mqtt', array('SAM_HOST' => '192.168.10.147', 'SAM_PORT' => '1883'));//start initialise the connection
$msgCpu = new SAMMessage('hehe');//create a new MQTT message with the output of the shell command as the body
$conn->send('topic://'.'tokudu/ab7867d9fd60db65', $msgCpu);//send the message on the topic cpu
$conn->disconnect();
A complet mqtt service incluede publisher, service and subscriber.