Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

device-mqtt

1.0.11 • Public • Published

device-mqtt

client

  • constructor arguments:

    • host: required - MQTT broker host
    • port: required - MQTT broker port
    • clientId: required - MQTT clientId
    • tls: optional - refer to MQTT.js library for arguments
    • extraOpts: optional - refer to MQTT.js library for extra connection options
  • connect arguments:

    • will: optional - MQTT will
  • destroy arguments:

    • cb: callback is called when MQTT connection is closed
  • client events:

    • connected, triggered when the client is connected. Returns the socket in the callback.
    • error, triggered when there is an error.
    • reconnecting, triggered when the client tries to reconnect to the MQTT broker

socket

  • send arguments:

    • message: required - The message must have parameters: {action, dest, payload}
    • resultCb: required - (error, result)
    • mqttCb: optional - (error, result)
  • createCollection arguments:

    • collectionName: required - The name of the collection
    • localState: required - The local variable where the state will be stored
    • collectionObjectCb: required - Returns the collection object used to query the 'MQTT' database
  • createGlobalCollection arguments:

    • collectionName: required - The name of the collection
    • localState: required - The local variable where the state will be stored
    • collectionObjectCb: required - Returns the collection object used to query the 'MQTT' database
  • customPublish arguments:

    • { topic, message, opts }
    • cb
  • customSubscribe arguments:

  • { topic, opts }

  • cb

Usage

  devicemqtt = require 'device-mqtt'
 
  client = devicemqtt host, port, 'client'
 
  client.on 'connected', (socket) ->
    socket.send(
      {action, dest, payload}
    , (error, response) ->
 
    , (error, ack) ->
 
    )

Keywords

none

install

npm i device-mqtt

Downloadsweekly downloads

0

version

1.0.11

license

ISC

repository

githubgithub

last publish

collaborators

  • avatar
  • avatar