From 241a19148b6fad0b2a9793d44903fbe00b8c2d2b Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 9 Jan 2021 23:52:08 +0100 Subject: [PATCH] fix bitshift in payload + configmask --- include/globals.h | 32 ++++++++++++++++---------------- src/TTN/packed_decoder.js | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/globals.h b/include/globals.h index c8755412..1818b976 100644 --- a/include/globals.h +++ b/include/globals.h @@ -22,24 +22,24 @@ #define _bitl(b) (1UL << (b)) // bits in payloadmask for filtering payload data -#define COUNT_DATA _bit(1) -#define ALARM_DATA _bit(2) -#define MEMS_DATA _bit(3) -#define GPS_DATA _bit(4) -#define SENSOR1_DATA _bit(5) -#define SENSOR2_DATA _bit(6) -#define SENSOR3_DATA _bit(7) -#define BATT_DATA _bit(8) +#define COUNT_DATA _bit(0) +#define ALARM_DATA _bit(1) +#define MEMS_DATA _bit(2) +#define GPS_DATA _bit(3) +#define SENSOR1_DATA _bit(4) +#define SENSOR2_DATA _bit(5) +#define SENSOR3_DATA _bit(6) +#define BATT_DATA _bit(7) // bits in configmask for device runmode control -#define GPS_MODE _bit(1) -#define ALARM_MODE _bit(2) -#define BEACON_MODE _bit(3) -#define UPDATE_MODE _bit(4) -#define FILTER_MODE _bit(5) -#define ANTENNA_MODE _bit(6) -#define BLE_MODE _bit(7) -#define SCREEN_MODE _bit(8) +#define GPS_MODE _bit(0) +#define ALARM_MODE _bit(1) +#define BEACON_MODE _bit(2) +#define UPDATE_MODE _bit(3) +#define FILTER_MODE _bit(4) +#define ANTENNA_MODE _bit(5) +#define BLE_MODE _bit(6) +#define SCREEN_MODE _bit(7) // length of display buffer for lmic event messages #define LMIC_EVENTMSG_LEN 17 diff --git a/src/TTN/packed_decoder.js b/src/TTN/packed_decoder.js index ee61706e..e8666a02 100644 --- a/src/TTN/packed_decoder.js +++ b/src/TTN/packed_decoder.js @@ -262,7 +262,7 @@ var bitmap2 = function (byte) { } var i = bytesToInt(byte); var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean); - return ['battery', 'sensor3', 'sensor2', 'sensor1', 'counter', 'bme', 'alarm', 'gps'] + return ['battery', 'sensor3', 'sensor2', 'sensor1', 'gps', 'bme', 'alarm', 'counter'] .reduce(function (obj, pos, index) { obj[pos] = +bm[index]; return obj;