Skip to content

Commit

Permalink
Fixed CMD_GET_SENSORS_CFG and CMD_GET_APP_PAYLOAD_CFG, decode functio…
Browse files Browse the repository at this point in the history
…n 'bits8'
  • Loading branch information
matthias-bs committed Jun 10, 2024
1 parent ae9939d commit 4993b52
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions scripts/uplink_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
// 20240607 Added CMD_GET_STATUS_INTERVAL
// 20240608 Added CMD_GET_LW_STATUS
// 20240609 Refactored command encoding
// 20240610 Fixed CMD_GET_SENSORS_CFG and CMD_GET_APP_PAYLOAD_CFG,
// decode function 'bits8'
//
// ToDo:
// -
Expand All @@ -156,7 +158,7 @@ function decoder(bytes, port) {
const CMD_GET_LW_STATUS = 0x38;
const CMD_GET_STATUS_INTERVAL = 0x40;
const CMD_GET_SENSORS_STAT = 0x42;
const CMD_GET_APP_PAYLOAD_CFG = 0x47;
const CMD_GET_APP_PAYLOAD_CFG = 0x46;
const CMD_GET_WS_TIMEOUT = 0xC0;
const CMD_GET_SENSORS_INC = 0xC6;
const CMD_GET_SENSORS_EXC = 0xC8;
Expand Down Expand Up @@ -223,6 +225,16 @@ function decoder(bytes, port) {
};
uint8.BYTES = 1;

// Same as uint8, but 0xFF is not converted to NaN
var bits8 = function (bytes) {
if (bytes.length !== bits8.BYTES) {
throw new Error('bits8 must have exactly 1 byte');
}
let res = bytesToInt(bytes);
return res;
};
bits8.BYTES = 1;

var uint8fp1 = function (bytes) {
if (bytes.length !== uint8fp1.BYTES) {
throw new Error('int must have exactly 1 byte');
Expand Down Expand Up @@ -539,6 +551,7 @@ function decoder(bytes, port) {
bitmap_sensors: bitmap_sensors,
sensor_status: sensor_status,
rawfloat: rawfloat,
bits8: bits8,
uint8fp1: uint8fp1,
uint16fp1: uint16fp1,
rtc_source: rtc_source,
Expand Down Expand Up @@ -648,9 +661,9 @@ function decoder(bytes, port) {
);
} else if (port === CMD_GET_SENSORS_CFG) {
return decode(
bytes,
port,
[uint8, uint8, uint8
bytes,
[bits8, bits8, bits8
],
['max_sensors', 'rx_flags', 'en_decoders'
]
Expand All @@ -668,7 +681,7 @@ function decoder(bytes, port) {
return decode(
port,
bytes,
[uint8, uint8
[bits8, bits8
],
['ble_active', 'ble_scantime']
);
Expand All @@ -684,7 +697,7 @@ function decoder(bytes, port) {
return decode(
port,
bytes,
[uint8
[bits8
],
['status_interval'
]
Expand Down

0 comments on commit 4993b52

Please sign in to comment.