fpm-plugin-mqtt-client
v1.1.1
Published
A Plugin Named [fpm-plugin-mqtt-client] For YF-FPM-SERVER~
Downloads
3
Readme
FPM-PLUGIN-MQTT-CLIENT
用于 mqtt-client 的插件
Install
npm add fpm-plugin-mqtt-client --save
Useage
config
{ "mqttserver":{ "host": "localhost", "port": 1883, "username": "admin", "password": "123123123", "clientId": "foo", } }
docker enviroment
MQTT_HOST: mqttserver MQTT_PORT: 1883 MQTT_USER: 'admin' MQTT_PASS: '123123123' MQTT_CLIENTID: 'client-foo'
subscribe
// subscribe a topic fpm.execute('mqttclient.subscribe', { topic: '$d2s/a111' }); // subscribe topics fpm.execute('mqttclient.subscribe', { topic: '$d2s/a111,$test' }); // or fpm.execute('mqttclient.subscribe', { topic: [ '$d2s/a111', '$test'] }); // handle the message. fpm.subscribe('$d2s/a111', (topic, payload) => { console.log(topic, payload); });
other