1.0.1 • Published 5 years ago

simple-mqtt-client v1.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

Simple MQTT Client

A simple MQTT client that allows you to link your subscriptions directly to callback functions.

How to use?

First, install the lib:

npm i --save simple-mqtt-client

Then use it as follows:

    const mqttProvider = require('simple-mqtt-client')
    
    mqttProvider.new().init("https://iot.eclipse.org/ws", "", "", "simple-mqtt-client/test", (mqttClient) => {
            
        mqttClient.subscribe("simpleTest", (msg) => {
            console.log("message:", msg.text)
        })

        mqttClient.publish("simpleTest", { text: "HelloWorld!" })

    });

The parameters you provide to the init function are:

  • mqttBrokerHost: MQTT broker to connect; it can be a TCP address connection (mqtt://), Websocket (http://) or Websocket Secure (https://)
  • mqttUserName: Used if your broker requires authentication
  • mqttPassord: Used if your broker requires authentication
  • baseTopic: A base topic to append to the topic passed as parameter to every publish, subscribe or unsubscribe invocation
  • readyCallback(mqttClient): callback function invoked when the MqttClient is prepared
1.0.1

5 years ago

1.0.0

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago