Creates a Duplex stream (in object mode) which reads and writes to a LoRa radio link.

It can perform over-the-air activation of devices it knows about on behalf of your application.

Messages received from the radio link are made available to read from the Duplex and have the following properties:

  • nwk_addr (Buffer) - Unique network address of the sending device.
  • dev_eui (Buffer) - Unique global device identifier (IEEE EUI64) of the sending device.
  • dev_addr (Buffer) - Combined identifier of your network (7 most significant bits) and the unique network address of the sending device (i.e. nwk_addr, 25 least significant bits).
  • payload (Buffer) - The data which the sending device sent to your application.
  • msg (Object) - The raw packet received by packet_forwarder_shared. The format is described here.
  • packet (Object) - The decoded packet. Anthony Kirby's excellent lora-packet is used to do the decoding.
  • reply (Object) - This contains nearly everything needed to reply to the message. Your application just has to set the payload.
    • header (Object) - The metadata required by packet_forwarder_shared to send the reply. See section 6 of here.
    • encoding (Object) - The fields required by lora-packet to encode the reply.
    • payload (undefined) - Your application must set this property to a Buffer containing the data you want to send back to the device.

If your application wants to reply to the message, set reply.payload to the data that should be sent and then write reply to the Duplex.

new Link(Model: class, uplink: stream.Duplex, downlink: stream.Duplex, options: Object)

Extends stream.Duplex

Parameters
Model (class) The Objection.js Model class , or a subclass of it, already configured for your database using Knex.js .
uplink (stream.Duplex) lora-comms uplink stream . Your application must start the lora-comms module first and then retrieve the uplink.
downlink (stream.Duplex) lora-comms downlink stream . Your application must start the lora-comms module first and then retrieve the downlink.
options (Object) Configuration options.
Name Description
options.appid Buffer 8-byte identifier of your application in the IEEE EUI64 address space. This is also known as the AppEUI and your OTAA devices must use the same value.
options.netid Buffer 3-byte identifier of your network. The 7 least significant bits must be unique for neighbouring or overlapping networks.
Instance Members
nwk_addr_to_dev_addr(nwk_addr)
dev_addr_to_nwk_addr(dev_addr)
dev_addr_to_deveui(dev_addr)