# Modules

Broker
Mails
MQTTClient
rateLimiter
RoleManager
Server

# Broker

# Broker.publish(packet) ⇒ function

Convert payload before publish

Kind: static method of Broker
Returns: function - broker.instance.publish

Param Type Description
packet object MQTT Packet

# Broker.start() ⇒ boolean

Setup broker connection

Kind: static method of Broker
Returns: boolean - status

# Broker.stop() ⇒ Promise.<boolean>

Stop broker and update models status

Kind: static method of Broker

# Broker.init() ⇒ function

Init MQTT and WS Broker with new Aedes instance

Kind: static method of Broker
Returns: function - broker.start

# Broker~preConnect(client, cb) ⇒ cb

Aedes preConnect hook

Check client connection details

Kind: inner method of Broker

Param Type Description
client object MQTT client
cb aedesCallback

# Broker~authenticate(client, [username], [password], cb) ⇒ aedesCallback

Aedes authentification hook

Kind: inner method of Broker

Param Type Description
client object MQTT client
[username] string MQTT username
[password] object MQTT password
cb aedesCallback

# Broker~authorizePublish(client, packet, cb) ⇒ aedesCallback

Aedes publish authorization callback

Kind: inner method of Broker

Param Type Description
client object MQTT client
packet object MQTT packet
cb aedesCallback

# Broker~authorizeSubscribe(client, packet, cb) ⇒ aedesCallback

Aedes subscribe authorization callback

Kind: inner method of Broker

Param Type Description
client object MQTT client
packet object MQTT packet
cb aedesCallback

# Broker~authorizeForward(client, packet) ⇒ object

Aedes forward authorization hook

Kind: inner method of Broker
Returns: object - packet

Param Type Description
client object MQTT client
packet object MQTT packet

# Broker~published(packet, client, cb) ⇒ aedesCallback

Aedes publised hook

Kind: inner method of Broker

Param Type Description
packet object MQTT packet
client object MQTT client
cb aedesCallback

# Broker~persistence(config) ⇒ function

Aedes persistence layer

Kind: inner method of Broker
Returns: function - aedesPersistence | aedesPersistenceRedis

Param Type Description
config object Environment variables

# Broker~emitter(config) ⇒ function

Aedes event emitter

Kind: inner method of Broker
Returns: function - MQEmitter | MQEmitterRedis

Param Type Description
config object Environment variables

# Broker~initServers(brokerInterfaces, brokerInstance) ⇒ object

Initialize servers that will be attached to Broker instance

Kind: inner method of Broker
Returns: object - tcpServer, wsServer

Param Type
brokerInterfaces object
brokerInstance object

# Broker~getClientProps(client) ⇒ object

Transform circular MQTT client in JSON

Kind: inner method of Broker
Returns: object - client

Param Type Description
client object MQTT client

# Broker~getClients(broker, [id]) ⇒ array | object

Find clients connected to the broker

Kind: inner method of Broker

Param Type Description
broker object MQTT broker
[id] string Client id

# Broker~getClientsByTopic(broker, topic) ⇒ Promise.<array>

Find in cache client ids subscribed to a specific topic pattern

Kind: inner method of Broker

Param Type Description
broker object MQTT broker
topic string Topic pattern

# Broker~pickRandomClient(broker, clientIds) ⇒ object

Give an array of clientIds, return a connected client

Kind: inner method of Broker
Returns: object - client

Param Type Description
broker object MQTT broker
clientIds Array.<string> MQTT client Ids

# Broker~authentificationRequest(credentials) ⇒ Promise.<object>

HTTP request to Aloes to validate credentials

Kind: inner method of Broker

Param Type Description
credentials object Client instance and credentials

# Broker~onAuthenticate(client, [username], [password]) ⇒ Promise.<number>

Check client credentials and update client properties

Kind: inner method of Broker
Returns: Promise.<number> - status - CONNACK code

  • 0 - Accepted
  • 1 - Unacceptable protocol version
  • 2 - Identifier rejected
  • 3 - Server unavailable
  • 4 - Bad user name or password
  • 5 - Not authorized
Param Type Description
client object MQTT client
[username] string MQTT username
[password] object MQTT password

# Broker~onAuthorizePublish(client, packet) ⇒ boolean

Check client properties for publish access

Kind: inner method of Broker

Param Type Description
client object MQTT client
packet object MQTT packet

# Broker~onAuthorizeSubscribe(client, packet) ⇒ boolean

Check client properties for subscribe access

Kind: inner method of Broker

Param Type Description
client object MQTT client
packet object MQTT packet

# Broker~updateClientStatus(broker, client, status) ⇒ Promise.<object>

Update client's status

Triggered after clientConnect and clientDisconnect events

Kind: inner method of Broker
Returns: Promise.<object> - client

Param Type Description
broker object MQTT broker
client object MQTT client
status boolean Client status

# Broker~onInternalPublished(broker, packet) ⇒ object

Parse message coming from aloes MQTT clients

Kind: inner method of Broker
Returns: object - packet

Param Type Description
broker object MQTT broker
packet object MQTT packet

# Broker~onExternalPublished(broker, packet, client) ⇒ Promise.<object>

Parse message coming from external MQTT clients

Kind: inner method of Broker
Returns: Promise.<object> - packet

Param Type Description
broker object MQTT broker
packet object MQTT packet
client object MQTT client

# Broker~onPublished(broker, packet, client) ⇒ Promise.<(function()|null)>

Parse message sent to Aedes broker

Kind: inner method of Broker
Returns: Promise.<(function()|null)> - Broker~onInternalPublished | Broker~onExternalPublished

Param Type Description
broker object MQTT broker
packet object MQTT packet
client object MQTT client

# "client" (client) ⇒ Promise.<function()>

On client connected to Aedes broker

Kind: event emitted by Broker
Returns: Promise.<function()> - Broker~updateClientStatus

Param Type Description
client object MQTT client

# "clientDisconnect" (client) ⇒ Promise.<function()>

On client disconnected from Aedes broker

Kind: event emitted by Broker
Returns: Promise.<function()> - Broker~updateClientStatus

Param Type Description
client object MQTT client

# "keepaliveTimeout" (client)

When client keep alive timeout

Kind: event emitted by Broker

Param Type Description
client object MQTT client

# "clientError" (client, err)

When client action creates an error

Kind: event emitted by Broker

Param Type Description
client object MQTT client
err object MQTT Error

# "clientError" (client, err)

When client contains no Id

Kind: event emitted by Broker

Param Type Description
client object MQTT client
err object MQTT Error

# "ack" (packet, client)

When a packet with qos=1|2 is delivered successfully

Kind: event emitted by Broker

Param Type Description
packet object MQTT original packet
client object MQTT client

# Broker~aedesCallback : function

Error callback

Kind: inner typedef of Broker

Param Type
ErrorObject error
result

# Mails

# Mails.send(options) ⇒ Promise.<object>

Generate HTML template and send email

Kind: static method of Mails
Returns: Promise.<object> - result - Mail result

Param Type Description
options object Mail options

# Mails.verifyEmail(user) ⇒ Promise.<object>

Sending a verification email to confirm account creation

Kind: static method of Mails
Returns: Promise.<object> - response

Param Type Description
user object Account created

# Mails.sendResetPasswordMail(options) ⇒ Promise.<object>

Sending a mail to set a new password

Kind: static method of Mails
Returns: Promise.<object> - response

Param Type
options object

# Mails.sendContactForm(options) ⇒ Promise.<object>

Sending a mail to admin

Kind: static method of Mails
Returns: Promise.<object> - response

Param Type
options object

# Mails.sendMailInvite(options) ⇒ Promise.<object>

Sending a mail invitation to new user

Kind: static method of Mails
Returns: Promise.<object> - response

Param Type
options object

# Mails~sendMail() ⇒ Promise.<object>

Promise wrapper to send email using Email datasource

Kind: inner method of Mails

# Mails~verifyUser() ⇒ Promise.<object>

Promise wrapper to send verification email after user registration

Kind: inner method of Mails

# MQTTClient

# MQTTClient.publish(topic, payload) ⇒ Promise.<boolean>

Convert payload and topic before publish

Kind: static method of MQTTClient
Returns: Promise.<boolean> - status

Param Type Description
topic string Packet topic
payload any Packet payload

# "start" ⇒ Promise.<function()>

Event reporting that MQTTClient has to start.

Kind: event emitted by MQTTClient
Returns: Promise.<function()> - MQTTClient~startClient

# "init" (app, config) ⇒ Promise.<function()>

Event reporting that MQTTClient has to init.

Kind: event emitted by MQTTClient
Returns: Promise.<function()> - MQTTClient~initClient

Param Type Description
app object Loopback app
config object Formatted config.

# "stop" ⇒ Promise.<function()>

Event reporting that MQTTClient has to stop.

Kind: event emitted by MQTTClient
Returns: Promise.<function()> - MQTTClient~stopClient

# MQTTClient~updateModelsStatus(app, client, status)

Update models status from MQTT connection status and client properties

Kind: inner method of MQTTClient

Param Type Description
app object Loopback app
client object MQTT client
status boolean MQTT conection status

# MQTTClient~findPattern(app, packet, client) ⇒ Promise.<(object|null)>

Retrieve pattern from packet.topic

Kind: inner method of MQTTClient
Returns: Promise.<(object|null)> - pattern

Param Type Description
app object Loopback app
packet object MQTT packet
client object MQTT client

# MQTTClient~redirectMessage(packet, client, pattern) ⇒ string

Redirect parsed message to corresponding Loopback model

Kind: inner method of MQTTClient
Returns: string - modelName

Param Type Description
packet object MQTT packet
client object MQTT client
pattern object IoTAgent extracted pattern

# MQTTClient~onStatus(app, topic, payload) ⇒ boolean

Called when status message has been detected

Kind: inner method of MQTTClient
Returns: boolean - status

Param Type Description
app object Loopback app
topic object MQTT topic
payload object MQTT payload

# MQTTClient~onReceive(app, topic, payload) ⇒ Promise.<object>

Event called when message arrived from the broker

Will be redirected to the right Model

Kind: inner method of MQTTClient
Returns: Promise.<object> - packet
Emits: Application.event:publish, Device.event:publish

Param Type Description
app object Loopback app
topic object MQTT topic
payload object MQTT payload

# MQTTClient~onMessage(app, topic, payload) ⇒ Promise.<(function()|null)>

Parse the message arriving from the broker

Kind: inner method of MQTTClient
Returns: Promise.<(function()|null)> - MQTTClient~onStatus | MQTTClient~onReceive

Param Type Description
app object Loopback app
topic object MQTT topic
payload object MQTT payload

# MQTTClient~startClient() ⇒ Promise.<boolean>

Setup MQTT client listeners

Kind: inner method of MQTTClient
Returns: Promise.<boolean> - status

# MQTTClient~initClient(app, config) ⇒ Promise.<boolean>

Setup MQTT client connection

Kind: inner method of MQTTClient
Returns: Promise.<boolean> - status

Param Type Description
app object Loopback app
config object Environment variables

# MQTTClient~stopClient() ⇒ Promise.<boolean>

Stop MQTT client and unsubscribe

Kind: inner method of MQTTClient
Returns: Promise.<boolean> - status

# rateLimiter

# rateLimiter.getAuthLimiter(ip, username, [clientId]) ⇒ Promise.<object>

Check if Rate limits exist by Ip and/or username

optionnally use a clientId to limit reconnections

Kind: static method of rateLimiter
Returns: Promise.<object> - retrySecs, userIpLimit, ipLimit, usernameIPkey

Param Type
ip string
username string
[clientId] string

# rateLimiter.setAuthLimiter(ip, username) ⇒ Promise.<object>

Consume 1 point from limiters on wrong attempt and block if limits are reached

Count failed attempts by Username + IP only for registered users

Kind: static method of rateLimiter

Param Type
ip string
username string

# rateLimiter.cleanAuthLimiter(ip, username) ⇒ Promise.<boolean>

Reset exisiting limiters for user/ip on successful authorisation

Kind: static method of rateLimiter

Param Type
ip string
username string

# RoleManager

# Server

# Server.publish() ⇒ Promise.<function()>

Emit publish event

Kind: static method of Server
Returns: Promise.<function()> - MQTTClient.publish

# Server.start(config) ⇒ boolean

Init HTTP server with new Loopback instance

Init external services ( MQTT broker )

Kind: static method of Server
Emits: Server.event:started

Param Type Description
config object Parsed env variables

# Server.init(config)

Bootstrap the application, configure models, datasources and middleware.

Kind: static method of Server

Param Type Description
config object Parsed env variables

# Server.stop(signal) ⇒ boolean

Close the app and services

Kind: static method of Server
Emits: MQTTClient.event:stop, Scheduler.event:stopped, Application.event:stopped, Device.event:stopped, Client.event:stopped

Param Type Description
signal string process signal

# Server~userAuth(username, password) ⇒ Promise.<object>

Authenticate with User method

Kind: inner method of Server

Param Type Description
username string MQTT client username
password string MQTT client password

# Server~deviceAuth(username, password) ⇒ Promise.<object>

Authenticate with Device method

Kind: inner method of Server

Param Type Description
username string MQTT client username
password string MQTT client password

# Server~applicationAuth(username, password) ⇒ Promise.<object>

Authenticate with Application method

Kind: inner method of Server

Param Type Description
username string MQTT client username
password string MQTT client password

# Server~authenticateModels(username, password, [model]) ⇒ Promise.<string>

Iterate over each model to try authentication

Kind: inner method of Server
Returns: Promise.<string> - Client details and status

Param Type
username string
password string
[model] string

# Server~authenticateInstance(client, username, password) ⇒ Promise.<object>

Init HTTP server with new Loopback instance

Init external services ( MQTT broker )

Kind: inner method of Server

Param Type Description
client object Parsed MQTT client
username string MQTT client username
password string MQTT client password

# "publish" (topic, payload, [retain], [qos]) ⇒ Promise.<function()>

Event reporting that a/several sensor instance(s) will be deleted.

Kind: event emitted by Server
Returns: Promise.<function()> - Server.publish

Param Type Description
topic string MQTT topic
payload any MQTT payload
[retain] boolean
[qos] number

# "start" (config) ⇒ Promise.<function()>

Event reporting that the application and all subservices should start.

Kind: event emitted by Server
Returns: Promise.<function()> - Server.init

Param Type Description
config object Parsed env variables

# "started" (config)

Event reporting that the application and all subservices have started.

Kind: event emitted by Server
Emits: MQTTClient.event:init, Device.event:started, Scheduler.event:started, Sensor.event:started

Param Type Description
config object application config

# "stop" (signal) ⇒ Promise.<function()>

Event reporting that the application and all subservice should stop.

Kind: event emitted by Server
Returns: Promise.<function()> - Server.stop

Param Type Description
signal string process signal