miro
LogiButton
Payload Format
1. Overview
The payload of up and downlink messages consists of an arbitrary number of data structs (DS) of different types and lengths.
DS 1 | DS 2 | … | DS n |
---|
Each data struct is a combination of a header and the actual data payload:
L | T | payload |
---|
The header consits of two fields:
Field | Description |
---|---|
L |
Length of data struct, 1 byte, not including the length byte itself |
T |
Data struct type, 1 byte |
2. Uplinks
There are three distinct uplink payloads:
-
Regular Status Message
All uplinks are sent to LoRaWAN port 15.
2.1. Event message
On every qualifying button press an event message is sent to the network. The event message gets sent when the user interacts with the button. Specifically when the user orders, cancels or confirms a transaction.
It contains the following data: event, button count, temperature, battery-voltage.
Byte | 0 | 1 | 2 | 3:4 | 5:6 | 7 |
---|---|---|---|---|---|---|
Field |
Length |
Type |
Event |
Button count |
Temperature |
Battery-Voltage |
Lenght |
8-bit unsigned integer |
7 |
Type |
8-bit unsigned integer |
2 |
Event |
8-bit unsigned integer |
0: Order event |
Button count |
16-bit unsigned integer |
Number of button presses since last reset |
Temperature |
16-bit signed integer |
Temperature in 1/100°C (if enabled) |
Battery-Voltage |
8-bit unsigned integer |
Voltage in 1/100V - offset (170) |
07:02:01:00:03:0b:b4:79
Event |
1 : Cancel |
Button count |
3 |
Temperature |
2996 - > 29.96°C |
Battery-Voltage |
121 - > 121+170 = 2.91 V |
2.2. Status Message
The device sends a regular status messages at a configurable interval. The status message is always unconfirmed, regardless of the settings.
The status message consists of the following data structs. Please note, depending on the LoRaWAN region not all data structs may be present.
Byte | 0 | 1 | 2:3 | 4:5 | 6 |
---|---|---|---|---|---|
Field |
Lenght |
Type |
Button count |
Temperature |
Battery-Voltage |
Lenght |
8-bit unsigned integer |
6 |
Type |
8-bit unsigned integer |
1 |
Button count |
16-bit unsigned integer |
Number of button presses since last reset |
Temperature |
16-bit signed integer |
Temperature in 1/100°C (if enabled) |
Battery-Voltage |
8-bit unsigned integer |
Voltage in 1/100V - offset (170) |
06:01:00:0a:09:cd:7a
Button count |
10 |
Temperature |
2509 - > 25.09°C |
Battery-Voltage |
122 - > 122+170 = 2.92 V |
3. Downlinks
Downlink messages are used to change the configuration of the device. They use the same general payload format as uplinks.
All downlinks must be sent on the LoRaWAN port 3! |
3.1. Device Configuration
Configuration of every option with a separate type and length. Messages can be concatenated.
Byte | 0 | 1 | 2:X |
---|---|---|---|
Field |
Length |
Type |
Value |
The default values, and unit descriptions can be found on the Settings page. The message type of each individual setting can be found in the table below.
Variable |
Message Type |
Length (Byte) |
Possible range |
Unit |
flags |
128 |
1 |
||
product_name |
129 |
Max 10 characters |
0 - 10 characters |
Text |
text_transportmode |
130 |
Max 10 characters |
0 - 10 characters |
Text |
text_joining |
131 |
Max 10 characters |
0 - 10 characters |
Text |
text_joined |
132 |
Max 10 characters |
0 - 10 characters |
Text |
text_ordered |
133 |
Max 10 characters |
0 - 10 characters |
Text |
text_order |
134 |
Max 10 characters |
0 - 10 characters |
Text |
text_successful |
135 |
Max 10 characters |
0 - 10 characters |
Text |
text_cancel |
136 |
Max 10 characters |
0 - 10 characters |
Text |
text_confirm |
137 |
Max 10 characters |
0 - 10 characters |
Text |
duration_magnet |
138 |
1 |
10-100 |
100ms |
duration_button_1 |
139 |
2 |
1 - 10 |
100ms |
duration_button_2 |
140 |
2 |
1 - 10 |
100ms |
duration_button_3 |
141 |
2 |
20 - 100 |
100ms |
duration_joined_timeout |
142 |
1 |
20-100 |
100ms |
interval_status |
143 |
2 |
1 - 65535 |
Minutes |
interval_temperature |
144 |
2 |
1 - 65535 |
Seconds |
temperature_enabled |
145 |
1 |
0 - 1 |
0: disabled, |
only_order |
146 |
1 |
0 - 1 |
0: disabled, |
0B:85:4f:4e:20:54:48:45:20:57:41:59:03:8D:14:64:02:91:01
0B:85:4f:4e:20:54:48:45:20:57:41:59
Length |
11 |
Type |
133 - > text_ordered |
Value |
"ON THE WAY" |
03:8D:14:64
Length |
3 |
Type |
141 - > duration_button_3 |
Value |
20, 100: |
02:91:01
Length |
2 |
Type |
145 - > temperature_enabled |
Value |
1 - >enabled |
4. Decoder example
function getEventText(num) {
var ret = "unknown";
switch(num) {
case 0:
ret = "Order";
break;
case 1:
ret = "Cancel";
break;
case 2:
ret = "Confirm";
break;
default:
break;
}
return ret;
}
function twosComplement(val, bits) {
if (val > 1<<bits) {
return -(1<<(bits+1) - val)
} else {
return val
}
}
function decodeMiroLogiButton(port, bytes) {
decoded = {}
if (port == 15) {
idx = 0;
total = bytes.length;
while (idx < total) {
length = bytes[idx];
switch(bytes[idx+1]) {
case 2:
decoded.event = bytes[idx+2];
decoded.eventText = getEventText(decoded.event);
decoded.buttonCnt = ((bytes[idx+3]<<8)+bytes[idx+4])
decoded.temperature_c = twosComplement((bytes[idx+5]<<8)+bytes[idx+6], 16)/100
decoded.battery_v = (bytes[idx+7]+170)/100
break;
case 1:
decoded.buttonCnt = ((bytes[idx+2]<<8)+bytes[idx+3])
decoded.temperature_c = twosComplement((bytes[idx+4]<<8)+bytes[idx+5], 16)/100
decoded.battery_v = (bytes[idx+6]+170)/100
break;
default:
break;
}
idx += length+1;
}
}
return decoded;
}