mqtt-sn
A UDP MQTT-SN library to replace the freematics server.
mqtt-sn
A UDP MQTT-SN library to replace the freematics server.
WebSocket support in Pub/Sub works by encapsulating MQTT packets (Pub/Sub’s underlying native protocol) within WebSocket framesExternal link icon
```js // Ensure MQTT.js is installed first // > npm install mqtt import * as mqtt from "mqtt"
// Where 'url' is "mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:8884" function example(url) { let client = mqtt.connect(url, { protocolVersion: 5, reconnectPeriod: 0, username: 'anything', password: jwt, // pass this from a form field in your app clientId: '', })
client.on('connect', function () {
client.subscribe(topic, function (err) {
if (err) {
client.end();
} else {
console.log(subscribed to ${topic}
)
}
})
client.on('message', function (topic, message) { let line = (new Date()).toLocaleString('en-US') + ": " + message.toString() + "\n"; console.log(line) }) } ```
dt/<application>/<context>/<thing-name>/<dt-type>
Suggested topic structure
Prefix your MQTT topics to distinguish data topics from command topics
What if topic prefixed by device first? is device-1/{cmd|data)
?
Useful recipes to design MQTT setups.
Enphase Envoy with MQTT
MQTT
Message Queuing Telemetry Transport MQTT protocol -> publish-subscribe network protocol that transports messages between devices, usually through TCP/IP
Protocol defines 2 network entities:
Everything you need to know about MQTTWe wrote this series to bring anybody up to speed with MQTT without requiring to read the whole MQTT specification. It explains the core of MQTT concepts, its features and other essential information.