NIS-UL UltraSonic Sensor - Frame Format v0.x
Following descibe old format of Frame for NIS-UL Ultrasonic Sensor
1 Version 0.1
1.1 Uplink data Frame format
The uplink payload contains multiple fields: <mask>: bit field on 1 byte indicating the presence of other fields. Bit 7 is always to 1 because the mask is never extended on next byte. Least significant bit (bit 0) indicates the presence of <usonic_dist> field, bit 1 indicates the presence of <voltage>, bit 2 indicates the presence of <temp>.
Whatever the <mask> value, the field <nb_meas> follows it and applies to all measures. Thus, the frame starts with <mask><nb_meas>.
- <nb_meas>: 1 byte containing the number of measures which follow.
if (mask.bit0 == 1) :
- <usonic_dist>: 2*<nb_meas> bytes containing the distances measured by the ultrasonic sensor in centimeters (1 to 600 cm in big endian).
if (mask.bit1 == 1) :
- <voltage>: 2*<nb_meas> bytes containing the voltages measured by the sensor in millivolts (in big endian).
if (mask.bit2 == 1) :
- <temp>: 1*<nb_meas> bytes containing the measured temperatures (signed integer)
Thus the uplink frame format is <mask><nb_meas><usonic_dist1>...<usonic_distN><voltage1>...<voltageN><temp1>...<tempN>
Default <mask> value is 0x85 which means that the default frame is <mask><nb_meas><usonic_dist1>...<usonic_distN><temp1>...<tempN> (the voltage is not present)
Some examples (in hexadecimal):
- “8502009700981f19”: the frame indicates two measurements of 151cm and 152cm followed by two temperatures of 31°C and 25°C.
- “810100a0”: the frame indicates a single measurement of 160cm without temperature.
- “84011e”: the frame indicates one temperature of 30°C.
- “fd02009c009c1c19xxxxxxxxxxxx”: the frame indicates two measurements of 156cm and 156cm with two temperatures of 28°C and 25°C followed by private data (used for debug).
1.2 Downlink Frame format
The sensor configuration contains the following fields:
- <up_frame_mask>: the mask identifying the different fields present in uplink frames (possible values are described in “Uplink data Frame format” section)
- <nb_meas_for_tx>: the number of measures required to trigger a transmission (possible values are [1..8]
- <meas_period>: the period of the measures in <perdiod_unit> seconds(possible values are [600..65535]
- <period_unit>: the unit of <meas_period> in seconds, the resulting period is <meas_perios>*<period_unit> seconds
It is possible to change the sensor configuration using the Nemeus downlink protocol. The downlink frame must be sent on the MS006 LoRaWAN port (8).
The downlink frame has the following format:
<cmd>: 1 byte containing WRITE_CFG_CMD=0x02
<mask>: bit field on 1 byte indicating the presence of other fields. Most significant bit (bit7) is always to 1 because the mask is never extended on next byte. Least significant bit (bit0) indicates the presence of <up_frame_mask> field, bit1 indicates the presence of <nb_meas_for_tx>, bit2 indicates the presence of <meas_period> and bit3 indicates the presence of <period_unit>
If (mask.bit0 == 1):
- <up_frame_mask>: 1 byte containing the uplink frame mask
If (mask.bit1 == 1):
- <nb_meas_for_tx>: 1 byte containing the number of measures required to trigger a transmission
If (mask.bit2 == 1):
- <meas_period>: 2 bytes in little endian (LSB first) containing the period of measures in seconds
If (mask.bit3 == 1):
- <period_unit>: 1 byte containing the unit of <meas_period> in seconds (default value is 1 second)
Thus the downlink frame format is <cmd><mask><up_frame_mask><nb_meas_for_tx><meas_period><period_unit>.
Some examples in hexadecimal:
- “028181”: set the <up_frame_mask> to 0x81 => the next uplink frames will include the <usonic_dist> field only (no <voltage> field and no <temp> field)
- “028E04605401”: set <nb_meas_for_tx> to 4, <meas_period> to 21600*<period_unit> seconds and <period_unit> to 1 second => one measure every 6 hours and one transmission every 4 measures (every day). Each uplink frame will include 4 measures