How do I encode a General Configuration Downlink message?

How do I encode a General Configuration Downlink message?

A downlink message is one that is sent to the sensor from the cloud and is used to configure the sensor itself. 
Messages cannot be initiated from the cloud since the sensor is typically sleeping and the radio is turned off, so the sensor itself must initiate a downlink message. 
The supervisory, reset, and tamper-open (not tamper close) messages all request a downlink message as a response, and the response must be received within 30 seconds of the request.

There are two types of downlink messages which apply to all sensor types: General Configuration and Rate Limit Configuration.

NOTE:  All downlinks must contain a total of (8) bytes, padded with zeros at the end when necessary.

General Configuration Message: 0x01 
      Byte            Description      
      0                 Disable Sensor Events (Events Enabled = 0x00,  Events Disabled = 0x01)
      1                  Radio Configuration * (Normal Operation = 0x00, Adaptive Data Rate = 0x01)
      2                 Supervisory period (default = 19 hours)

      * Adaptive Data Rate applies to LoRaWAN only and is available in firmware v1.4 and above.

Supervisory Period Configuration: 
      Bit 7            Bits 6:0
      0                  Period defined in hours (1-127 hours)
      1           Period defined in minutes (1-127 minutes)
      Note that prior to firmware version 1.3, only hourly reporting is available. 
      The firmware version can be found in the reset message and is logged on the Radio Bridge console.


The Rate Limit is the number of messages allowed between supervisory messages.
This is a protection mechanism to ensure the sensors do not flood the wireless network with messages.

Rate Limit Configuration Message: 0xFC
      Byte            Description      
      0                 Maximum Messages Between Supervisory Messages (disabled = 0x00, default = 100 = 0x64)


General Configuration Downlink Example:

      01 00 00 30 00 00 00 00

      01            Downlink Message Type (General Configuration = 0x01)
      00           Events Enabled (Disabling Off = 0x00)
      00           Adaptive Data Rate (Disabled = 0x00)
      30           Supervisory Period (48 hours = 0x30)
      00....      Zero padding to make up 8 bytes.

Rate Limit Configuration Downlink Example:

      FC C8 00 00 00 00 00 00

      FC          Downlink Message Type (Rate Limit Configuration = 0xFC)
      C8          Max Number of Messages Between Supervisory Messages (200 = 0xC8)
      00....      Zero padding to make up 8 bytes.


If the configuration is successful the sensor will respond with a Downlink Acknowledge uplink message:

      1 0 FF 02

      1                    Protocol Version (currently always 0x1)
      0                   Packet Counter, increments by 1 each message and wraps from 0xF to 0x0
      FF                 Message Type (Downlink ACK = 0xFF)
      02                 Downlink Message Valid (Invalid/Undefined = 0x01, Valid = 0x02)

See Also: