2.0.0 • Published 5 years ago
mqttsngw-dtls v2.0.0
MQTT-SN Gateway: DTLS
This module is part of mqttsngw. It is responsible for handling incoming DTLS connections from the sensor network and parsing and generating MQTT-SN packets.
All packet conversions are handled by mqttsn-packet.
Factory
const DTLS = require('mqttsngw-dtls');
mqttsngw.attach(DTLS(opts));Creates a new DTLS factory and attaches it to an existing instance of mqttsngw. opts has the following fields:
log: Optional. An object containing logging callbacks for all log levels (error,warn,info,debug). Every callback is called with a human-readable message as the first argument followed by an object containing more information regarding the event:{ error: (msg, info) => { ... }, ...}.guard: Optional. Callback function that is called for every parsed ingress packet:(peer, certInfo, packet) => { ... }. Returnstrueif the packet shall pass andfalseif it shall not pass. Arguments for decision-making:peer: Object containingaddressandportof the sensor.certInfo: Objection containing further details of the client certificate if presented.packet: Packet parsed by mqttsn-packet.
bind:optionsof the Node.js Dgram bind method- All other options accepted by the createServer method of openssl-dtls
Events
All in all just two events are consumed and emitted by the DTLS module on the event bus.
Consumed
| Event | Description |
|---|---|
| snUnicastOutgress,*,* | A packet shall be sent to a sensor |
Emitted
| Event | Description |
|---|---|
| snUnicastIngress,*,* | A packet has been received from a sensor |