diff --git a/BresserWeatherSensorLW.ino b/BresserWeatherSensorLW.ino index b956122..8fe967d 100644 --- a/BresserWeatherSensorLW.ino +++ b/BresserWeatherSensorLW.ino @@ -775,18 +775,6 @@ void setup() LoraEncoder encoder(uplinkPayload); - // Note: - // This should be enabled by a LoRaWAN downlink command if required. - // // LoRaWAN node status flags - // encoder.writeBitmap(0, - // 0, - // 0, - // 0, - // 0, - // longSleep, - // 0, - // 0); - appLayer.getPayloadStage1(1, encoder); int16_t state = 0; // return value for calls to RadioLib @@ -972,7 +960,7 @@ void setup() // Did we get a downlink with data for us if (downlinkSize > 0) { - log_i("Downlink data: "); + log_i("Downlink port %u, data: ", downlinkDetails.fPort); arrayDump(downlinkPayload, downlinkSize); if (downlinkDetails.fPort > 0) diff --git a/BresserWeatherSensorLWCmd.h b/BresserWeatherSensorLWCmd.h index 99eb58c..687cf42 100644 --- a/BresserWeatherSensorLWCmd.h +++ b/BresserWeatherSensorLWCmd.h @@ -40,6 +40,7 @@ // 20240603 Added CMD_GET_SENSORS_STAT // 20240606 Added CMD_GET_STATUS_INTERVAL/CMD_SET_STATUS_INTERVAL // 20240608 Added CMD_GET_LW_STATUS +// 20240609 Refactored command encoding // // ToDo: // - @@ -59,7 +60,7 @@ // CMD_GET_DATETIME // ----------------- -#define CMD_GET_DATETIME 0x86 +#define CMD_GET_DATETIME 0x20 // Downlink (command): // byte0: 0x00 @@ -75,7 +76,7 @@ // CMD_SET_DATETIME // ----------------- // Port: CMD_SET_DATETIME -#define CMD_SET_DATETIME 0x88 +#define CMD_SET_DATETIME 0x21 // Downlink (command): // byte0: unixtime[31:24] @@ -89,7 +90,7 @@ // ----------------------- // Note: Set normal sleep interval in seconds // Port: CMD_SET_SLEEP_INTERVAL -#define CMD_SET_SLEEP_INTERVAL 0xA8 +#define CMD_SET_SLEEP_INTERVAL 0x31 // Downlink (command): // byte0: sleep_interval[15:8] @@ -101,7 +102,7 @@ // ---------------------------- // Note: Set long sleep interval in seconds (energy saving mode) // Port: CMD_SET_SLEEP_INTERVAL_LONG -#define CMD_SET_SLEEP_INTERVAL_LONG 0xA9 +#define CMD_SET_SLEEP_INTERVAL_LONG 0x33 // Downlink (command): // byte0: sleep_interval_long[15:8] @@ -112,7 +113,7 @@ // CMD_GET_LW_CONFIG // ------------------ // Port: CMD_GET_LW_CONFIG -#define CMD_GET_LW_CONFIG 0xB1 +#define CMD_GET_LW_CONFIG 0x36 // Downlink (command): // byte0: 0x00 @@ -127,7 +128,7 @@ // ------------------ // Port: CMD_GET_LW_STATUS // Note: Get LoRaWAN device status -#define CMD_GET_LW_STATUS 0xB2 +#define CMD_GET_LW_STATUS 0x38 // Downlink (command): // byte0: 0x00 @@ -141,6 +142,101 @@ // -- Application layer -- // ----------------------- +// CMD_GET_STATUS_INTERVAL +// ------------------------ +// Note: Get status interval in frame counts +// Port: CMD_GET_STATUS_INTERVAL +#define CMD_GET_STATUS_INTERVAL 0x40 + +// Downlink (command): +// byte0: 0x00 + +// Uplink (response): +// byte0: status_interval[7:0] + +// CMD_SET_STATUS_INTERVAL +// ------------------------ +// Note: Set status interval in frame counts +// Port: CMD_SET_STATUS_INTERVAL +#define CMD_SET_STATUS_INTERVAL 0x41 + +// Downlink (command): +// byte0: status_interval[7:0] + +// Uplink: n.a. + +// CMD_GET_SENSORS_STAT +// --------------------- +// Port: CMD_GET_SENSORS_STAT +#define CMD_GET_SENSORS_STAT 0x42 + +// CMD_GET_APP_PAYLOAD_CFG +// ----------------------- +// Port: CMD_GET_APP_PAYLOAD_CFG +#define CMD_GET_APP_PAYLOAD_CFG 0x46 + +// Downlink (command): +// byte0: 0x00 + +// Response: n.a. +// Uplink (command): +// byte00: type00[7:0] +// byte01: type01[7:0] +// byte02: type02[7:0] +// byte03: type03[7:0] +// byte04: type04[7:0] +// byte05: type05[7:0] +// byte06: type06[7:0] +// byte07: type07[7:0] +// byte08: type08[7:0] +// byte09: type09[7:0] +// byte10: type10[7:0] +// byte11: type11[7:0] +// byte12: type12[7:0] +// byte13: type13[7:0] +// byte14: type14[7:0] +// byte15: type15[7:0] +// byte16: onewire[15:8] +// byte17: onewire[7:0] +// byte18: analog[15:8] +// byte19: analog[7:0] +// byte20: digital[31:24] +// byte21: digital[23:16] +// byte22: digital[15:8] +// byte23: digital[7:0] + +// CMD_SET_APP_PAYLOAD_CFG +// Port: CMD_SET_APP_PAYLOAD_CFG +#define CMD_SET_APP_PAYLOAD_CFG 0x47 + +// Uplink (command): +// byte00: type00[7:0] +// byte01: type01[7:0] +// byte02: type02[7:0] +// byte03: type03[7:0] +// byte04: type04[7:0] +// byte05: type05[7:0] +// byte06: type06[7:0] +// byte07: type07[7:0] +// byte08: type08[7:0] +// byte09: type09[7:0] +// byte10: type10[7:0] +// byte11: type11[7:0] +// byte12: type12[7:0] +// byte13: type13[7:0] +// byte14: type14[7:0] +// byte15: type15[7:0] +// byte16: onewire[15:8] +// byte17: onewire[7:0] +// byte18: analog[15:8] +// byte19: analog[7:0] +// byte20: digital[31:24] +// byte21: digital[23:16] +// byte22: digital[15:8] +// byte23: digital[7:0] + +// Response: n.a. + // CMD_GET_WS_TIMEOUT // ------------------- // Note: Get weather sensor RX timeout in seconds @@ -177,39 +273,11 @@ // Reset Lightning??? // ------------------- -// CMD_GET_SENSORS_STAT -// --------------------- -// Port: CMD_GET_SENSORS_STAT -#define CMD_GET_SENSORS_STAT 0xD0 - -// CMD_GET_STATUS_INTERVAL -// ------------------------ -// Note: Get status interval in frame counts -// Port: CMD_GET_STATUS_INTERVAL -#define CMD_GET_STATUS_INTERVAL 0xD2 - -// Downlink (command): -// byte0: 0x00 - -// Uplink (response): -// byte0: status_interval[7:0] - -// CMD_SET_STATUS_INTERVAL -// ------------------------ -// Note: Set status interval in frame counts -// Port: CMD_SET_STATUS_INTERVAL -#define CMD_SET_STATUS_INTERVAL 0xD3 - -// Downlink (command): -// byte0: status_interval[7:0] - -// Uplink: n.a. - // CMD_GET_SENSORS_INC // -------------------- // Note: Get sensors include list (0...12 IDs) // Port: CMD_GET_SENSORS_INC -#define CMD_GET_SENSORS_INC 0xC4 +#define CMD_GET_SENSORS_INC 0xC6 // Downlink (command): // byte0: 0x00 @@ -225,7 +293,7 @@ // -------------------- // Note: Set sensors include list (0...12 IDs) // Port: CMD_SET_SENSORS_INC -#define CMD_SET_SENSORS_INC 0xC5 +#define CMD_SET_SENSORS_INC 0xC7 // Downlink (command): // byte0: sensors_inc0[31:24] @@ -240,7 +308,7 @@ // -------------------- // Note: Get sensors exclude list (0...12 * 4 bytes) // Port: CMD_GET_SENSORS_EXC -#define CMD_GET_SENSORS_EXC 0xC6 +#define CMD_GET_SENSORS_EXC 0xC8 // Downlink (command): // byte0: 0x00 @@ -256,7 +324,7 @@ // -------------------- // Note: Set sensors exclude list (0...12 * 4 bytes) // Port: CMD_SET_SENSORS_EXC -#define CMD_SET_SENSORS_EXC 0xC7 +#define CMD_SET_SENSORS_EXC 0xC9 // Downlink (command): // byte0: sensors_exc0[31:24] @@ -270,7 +338,7 @@ // CMD_GET_SENSORS_CFG // -------------------- // Port: CMD_GET_SENSORS_CFG -#define CMD_GET_SENSORS_CFG 0xCC +#define CMD_GET_SENSORS_CFG 0xCA // Downlink (command): // byte0: 0x00 @@ -283,7 +351,7 @@ // CMD_SET_SENSORS_CFG // -------------------- // Port: CMD_SET_SENSORS_CFG -#define CMD_SET_SENSORS_CFG 0xCD +#define CMD_SET_SENSORS_CFG 0xCB // Downlink (command): // byte0: max_sensors @@ -292,11 +360,36 @@ // Uplink: n.a. +// CMD_GET_BLE_CONFIG +// ------------------- +// Note: Scan time in seconds +// Port: CMD_GET_BLE_CONFIG +#define CMD_GET_BLE_CONFIG 0xD0 + +// Downlink (command): +// byte0: 0x00 + +// Uplink (response): +// byte0: 0x01 (active scan) / 0x00 (passive scan) +// byte1: scan_time[7:0] + +// CMD_SET_BLE_CONFIG +// ------------------- +// Note: Scan time in seconds +// Port: CMD_SET_BLE_CONFIG +#define CMD_SET_BLE_CONFIG 0xD1 + +// Uplink (command): +// byte0: active_scan - 0x01 (active scan) / 0x00 (passive scan) +// byte1: scan_time[7:0] + +// Response: n.a. + // CMD_GET_BLE_ADDR // ----------------- // Note: Get BLE sensors MAC addresses (0..8 * 6 bytes) // Port: CMD_GET_BLE_ADDR -#define CMD_GET_BLE_ADDR 0xC8 +#define CMD_GET_BLE_ADDR 0xD2 // Downlink (command): // byte0: 0x00 @@ -314,7 +407,7 @@ // ----------------- // Note: Set BLE sensors MAC addresses (0..8 * 6 bytes) // Port: CMD_SET_BLE_ADDR -#define CMD_SET_BLE_ADDR 0xC9 +#define CMD_SET_BLE_ADDR 0xD3 // Downlink (command): // byte0: ble_addr0[47:24] @@ -327,98 +420,5 @@ // Response: n.a. -// CMD_GET_BLE_CONFIG -// ------------------- -// Note: Scan time in seconds -// Port: CMD_GET_BLE_CONFIG -#define CMD_GET_BLE_CONFIG 0xCA - -// Downlink (command): -// byte0: 0x00 - -// Uplink (response): -// byte0: 0x01 (active scan) / 0x00 (passive scan) -// byte1: scan_time[7:0] - -// CMD_SET_BLE_CONFIG -// ------------------- -// Note: Scan time in seconds -// Port: CMD_SET_BLE_CONFIG -#define CMD_SET_BLE_CONFIG 0xCB - -// Uplink (command): -// byte0: active_scan - 0x01 (active scan) / 0x00 (passive scan) -// byte1: scan_time[7:0] - -// Response: n.a. - -// CMD_GET_APP_PAYLOAD_CFG -// ----------------------- -// Port: CMD_GET_APP_PAYLOAD_CFG -#define CMD_GET_APP_PAYLOAD_CFG 0xCE - -// Downlink (command): -// byte0: 0x00 - -// Response: n.a. -// Uplink (command): -// byte00: type00[7:0] -// byte01: type01[7:0] -// byte02: type02[7:0] -// byte03: type03[7:0] -// byte04: type04[7:0] -// byte05: type05[7:0] -// byte06: type06[7:0] -// byte07: type07[7:0] -// byte08: type08[7:0] -// byte09: type09[7:0] -// byte10: type10[7:0] -// byte11: type11[7:0] -// byte12: type12[7:0] -// byte13: type13[7:0] -// byte14: type14[7:0] -// byte15: type15[7:0] -// byte16: onewire[15:8] -// byte17: onewire[7:0] -// byte18: analog[15:8] -// byte19: analog[7:0] -// byte20: digital[31:24] -// byte21: digital[23:16] -// byte22: digital[15:8] -// byte23: digital[7:0] - -// CMD_SET_APP_PAYLOAD_CFG -// Port: CMD_SET_APP_PAYLOAD_CFG -#define CMD_SET_APP_PAYLOAD_CFG 0xCF - -// Uplink (command): -// byte00: type00[7:0] -// byte01: type01[7:0] -// byte02: type02[7:0] -// byte03: type03[7:0] -// byte04: type04[7:0] -// byte05: type05[7:0] -// byte06: type06[7:0] -// byte07: type07[7:0] -// byte08: type08[7:0] -// byte09: type09[7:0] -// byte10: type10[7:0] -// byte11: type11[7:0] -// byte12: type12[7:0] -// byte13: type13[7:0] -// byte14: type14[7:0] -// byte15: type15[7:0] -// byte16: onewire[15:8] -// byte17: onewire[7:0] -// byte18: analog[15:8] -// byte19: analog[7:0] -// byte20: digital[31:24] -// byte21: digital[23:16] -// byte22: digital[15:8] -// byte23: digital[7:0] - -// Response: n.a. - - // =========================== #endif \ No newline at end of file diff --git a/README.md b/README.md index 5127f8f..27c2f3c 100644 --- a/README.md +++ b/README.md @@ -417,45 +417,46 @@ Many software parameters can be defined at compile time, i.e. in [BresserWeather | Command | Port | Downlink | Uplink | | ----------------------------- | ---------- | ------------------------------------------------------------------------- | -------------- | -| CMD_GET_DATETIME | 0x86 (134) | 0x00 | epoch[31:24]
epoch[23:16]
epoch[15:8]
epoch[7:0]
rtc_source[7:0] | -| CMD_SET_DATETIME | 0x88 (136) | epoch[31:24]
epoch[23:16]
epoch[15:8]
epoch[7:0] | n.a. | -| CMD_SET_SLEEP_INTERVAL | 0xA8 (168) | sleep_interval[15:8]
sleep_interval[7:0] | n.a. | -| CMD_SET_SLEEP_INTERVAL_LONG | 0xA9 (169) | sleep_interval_long[15:8]
sleep_interval_long[7:0] | n.a. | -| CMD_GET_LW_CONFIG | 0xB1 (177) | 0x00 | sleep_interval[15:8]
sleep_interval[7:0]
sleep_interval_long[15:8]
sleep_interval_long[7:0] | -| CMD_GET_LW_STATUS | 0xB2 (178) | 0x00 | ubatt_mv[15:8]
ubatt_mv[7:0]
long_sleep[7:0] | +| CMD_GET_DATETIME | 0x20 (32) | 0x00 | epoch[31:24]
epoch[23:16]
epoch[15:8]
epoch[7:0]
rtc_source[7:0] | +| CMD_SET_DATETIME | 0x21 (33) | epoch[31:24]
epoch[23:16]
epoch[15:8]
epoch[7:0] | n.a. | +| CMD_SET_SLEEP_INTERVAL | 0x31 (49) | sleep_interval[15:8]
sleep_interval[7:0] | n.a. | +| CMD_SET_SLEEP_INTERVAL_LONG | 0x33 (51) | sleep_interval_long[15:8]
sleep_interval_long[7:0] | n.a. | +| CMD_GET_LW_CONFIG | 0x36 (54) | 0x00 | sleep_interval[15:8]
sleep_interval[7:0]
sleep_interval_long[15:8]
sleep_interval_long[7:0] | +| CMD_GET_LW_STATUS | 0x38 (56) | 0x00 | ubatt_mv[15:8]
ubatt_mv[7:0]
long_sleep[7:0] | +| CMD_GET_STATUS_INTERVAL | 0x40 (64) | 0x00 | status_interval[7:0] | +| CMD_SET_STATUS_INTERVAL | 0x41 (65) | status_interval[7:0] | n.a. | +| CMD_GET_SENSORS_STAT | 0x42 (66) | 0x00 | type00_st[7:0]
type01_st[7:0]
...
type15_st[7:0]
onewire_st[15:8]
onewire_st[7:0]
analog_st[15:8]
analog_st[7:0]
digital_st[31:24]
digital_st[23:16]
digital_st[15:8]
digital_st[7:0]
ble_st[15:8]
ble_st[7:0] | +| CMD_GET_APP_PAYLOAD_CFG | 0x46 (70) | 0x00 | type00[7:0]
type01[7:0]
...
type15[7:0]
onewire[15:8]
onewire[7:0]
analog[15:8]
analog[7:0]
digital[31:24]
digital[23:16]
digital[15:8]
digital[7:0] | +| CMD_SET_APP_PAYLOAD_CFG | 0x47 (71) | type00[7:0]
type01[7:0]
...
type15[7:0]
onewire[15:8]
onewire[7:0]
analog[15:8]
analog[7:0]
digital[31:24]
digital[23:16]
digital[15:8]
digital[7:0] | n.a. | | CMD_GET_WS_TIMEOUT | 0xC0 (192) | 0x00 | ws_timeout[7:0] | | CMD_SET_WS_TIMEOUT | 0xC1 (193) | ws_timeout[7:0] | n.a. | | CMD_RESET_RAINGAUGE | 0xC3 (195) | flags[7:0] | n.a. | -| CMD_GET_STATUS_INTERVAL | 0xD2 (210) | 0x00 | status_interval[7:0] | -| CMD_SET_STATUS_INTERVAL | 0xD3 (211) | status_interval[7:0] | n.a. | -| CMD_GET_SENSORS_STAT | 0xD0 (208) | 0x00 | type00_st[7:0]
type01_st[7:0]
...
type15_st[7:0]
onewire_st[15:8]
onewire_st[7:0]
analog_st[15:8]
analog_st[7:0]
digital_st[31:24]
digital_st[23:16]
digital_st[15:8]
digital_st[7:0]
ble_st[15:8]
ble_st[7:0] | -| CMD_GET_SENSORS_INC | 0xC4 (196) | 0x00 | sensors_inc0[31:24]
sensors_inc0[23:15]
sensors_inc0[16:8]
sensors_inc0[7:0]
... | -| CMD_SET_SENSORS_INC | 0xC5 (197) | sensors_inc0[31:24]
sensors_inc0[23:15]
sensors_inc0[16:8]
sensors_inc0[7:0]
... | n.a. | -| CMD_GET_SENSORS_EXC | 0xC6 (198) | 0x00 | sensors_exc0[31:24]
sensors_exc0[23:15]
sensors_exc0[16:8]
sensors_exc0[7:0]
... | -| CMD_SET_SENSORS_EXC | 0xC7 (199) | sensors_exc0[31:24]
sensors_exc0[23:15]
sensors_exc0[16:8]
sensors_exc0[7:0]
... | n.a. | -| CMD_GET_SENSORS_CFG | 0xCC (204) | 0x00 | max_sensors[7:0]
rx_flags[7:0]
en_decoders<7:0> | -| CMD_SET_SENSORS_CFG | 0xCD (205) | max_sensors[7:0]
rx_flags[7:0]
en_decoders<7:0> | n.a. | -| CMD_GET_BLE_ADDR | 0xC8 (200) | 0x00 | ble_addr0[47:40]
ble_addr0[39:32]
ble_addr0[31:24]
ble_addr0[23:15]
ble_addr0[16:8]
ble_addr0[7:0]
... | -| CMD_SET_BLE_ADDR | 0xC9 (201) | ble_addr0[47:40]
ble_addr0[39:32]
ble_addr0[31:24]
ble_addr0[23:15]
ble_addr0[16:8]
ble_addr0[7:0]
... | n.a. | -| CMD_GET_BLE_CONFIG | 0xCA (202) | 0x00 | ble_active[7:0]
ble_scantime[7:0] | -| CMD_SET_BLE_CONFIG | 0xCB (203) | ble_active[7:0]
ble_scantime[7:0] | n.a. | -| CMD_GET_APP_PAYLOAD_CFG | 0xCE (206) | 0x00 | type00[7:0]
type01[7:0]
...
type15[7:0]
onewire[15:8]
onewire[7:0]
analog[15:8]
analog[7:0]
digital[31:24]
digital[23:16]
digital[15:8]
digital[7:0] | -| CMD_SET_APP_PAYLOAD_CFG | 0xCF (207) | type00[7:0]
type01[7:0]
...
type15[7:0]
onewire[15:8]
onewire[7:0]
analog[15:8]
analog[7:0]
digital[31:24]
digital[23:16]
digital[15:8]
digital[7:0] | n.a. | +| CMD_GET_SENSORS_INC | 0xC6 (198) | 0x00 | sensors_inc0[31:24]
sensors_inc0[23:15]
sensors_inc0[16:8]
sensors_inc0[7:0]
... | +| CMD_SET_SENSORS_INC | 0xC7 (199) | sensors_inc0[31:24]
sensors_inc0[23:15]
sensors_inc0[16:8]
sensors_inc0[7:0]
... | n.a. | +| CMD_GET_SENSORS_EXC | 0xC8 (200) | 0x00 | sensors_exc0[31:24]
sensors_exc0[23:15]
sensors_exc0[16:8]
sensors_exc0[7:0]
... | +| CMD_SET_SENSORS_EXC | 0xC9 (201) | sensors_exc0[31:24]
sensors_exc0[23:15]
sensors_exc0[16:8]
sensors_exc0[7:0]
... | n.a. | +| CMD_GET_SENSORS_CFG | 0xCA (202) | 0x00 | max_sensors[7:0]
rx_flags[7:0]
en_decoders<7:0> | +| CMD_SET_SENSORS_CFG | 0xCB (203) | max_sensors[7:0]
rx_flags[7:0]
en_decoders<7:0> | n.a. | +| CMD_GET_BLE_CONFIG | 0xD0 (208) | 0x00 | ble_active[7:0]
ble_scantime[7:0] | +| CMD_SET_BLE_CONFIG | 0xD1 (209) | ble_active[7:0]
ble_scantime[7:0] | n.a. | +| CMD_GET_BLE_ADDR | 0xD2 (210) | 0x00 | ble_addr0[47:40]
ble_addr0[39:32]
ble_addr0[31:24]
ble_addr0[23:15]
ble_addr0[16:8]
ble_addr0[7:0]
... | +| CMD_SET_BLE_ADDR | 0xD3 (211) | ble_addr0[47:40]
ble_addr0[39:32]
ble_addr0[31:24]
ble_addr0[23:15]
ble_addr0[16:8]
ble_addr0[7:0]
... | n.a. | + #### The Things Network Examples ##### Example 1: Set SLEEP_INTERVAL to 360 seconds -1. Set port for CMD_SET_SLEEP_INTERVAL to 168 +1. Set port for CMD_SET_SLEEP_INTERVAL to 49 2. Convert interval to hex: 300 = 0x012C 3. Set payload to 0x01 0x2C 4. Send downlink via The Things Network Console -![TTN Downlink as Hex](https://github.com/matthias-bs/BresserWeatherSensorLW/assets/83612361/4b616cd9-4f50-4407-8032-44d240abc09b) +![TTN Downlink as Hex](https://github.com/matthias-bs/BresserWeatherSensorLW/assets/83612361/ad66a77d-1aae-4083-8d62-d09c89c3f180) ##### Example 2: Set Date/Time -1. Set port for CMD_SET_DATETIME to 136 +1. Set port for CMD_SET_DATETIME to 33 2. Get epoch (e.g. from https://www.epochconverter.com/hex) (Example: 0x63B2BC32); add an offset (estimated) for time until received (Example: + 64 / 0x40 seconds => 0x63B2BC**7**2) 3. Set payload to 0x63 0xB2 0xBC 0x72 4. Send downlink via The Things Network Console @@ -470,24 +471,24 @@ Many software parameters can be defined at compile time, i.e. in [BresserWeather | CMD_SET_SLEEP_INTERVAL_LONG | {"sleep_interval_long": } | n.a. | | CMD_GET_LW_CONFIG | {"cmd": "CMD_GET_LW_CONFIG"} | {"sleep_interval": , "sleep_interval_long": } | | CMD_GET_LW_STATUS | {"cmd": "CMD_GET_LW_STATUS"} | {"ubatt_mv": , "long_sleep": } | -| CMD_GET_WS_TIMEOUT | {"cmd": "CMD_GET_WS_TIMEOUT"} | {"ws_timeout": } | -| CMD_SET_WS_TIMEOUT | {"ws_timeout": } | n.a. | -| CMD_RESET_RAINGAUGE | {"reset_flags": } | n.a. | | CMD_GET_STATUS_INTERVAL | {"cmd": "CMD_GET_STATUS_INTERVAL"} | {"status_interval": } | | CMD_SET_STATUS_INTERVAL | {"status_interval": } | n.a. | | CMD_GET_SENSORS_STAT | {"cmd": "CMD_GET_SENSORS_STAT"} | "sensor_status": {"ble": , "bresser": [, ..., ]} | +| CMD_GET_APP_PAYLOAD_CFG | {"cmd": "CMD_GET_APP_PAYLOAD_CFG"} | {"bresser": [\, \, ..., \], "onewire": \, "analog": \, "digital": \} | +| CMD_SET_APP_PAYLOAD_CFG | {"bresser": [\, \, ..., \], "onewire": \, "analog": \, "digital": \} | n.a. | +| CMD_GET_WS_TIMEOUT | {"cmd": "CMD_GET_WS_TIMEOUT"} | {"ws_timeout": } | +| CMD_SET_WS_TIMEOUT | {"ws_timeout": } | n.a. | +| CMD_RESET_RAINGAUGE | {"reset_flags": } | n.a. | | CMD_GET_SENSORS_INC | {"cmd": "CMD_GET_SENSORS_INC"} | {"sensors_inc": [, ..., ]} | | CMD_SET_SENSORS_INC | {"sensors_inc": [, ..., ]} | n.a. | | CMD_GET_SENSORS_EXC | {"cmd": "CMD_GET_SENSORS_EXC"} | {"sensors_exc": [, ..., ]} | | CMD_SET_SENSORS_EXC | {"sensors_exc": [, ..., ]} | n.a. | | CMD_GET_SENSORS_CFG | {"cmd": "CMD_GET_SENSORS_CFG"} | {"max_sensors": , "rx_flags": , "en_decoders": } | | CMD_SET_SENSORS_CFG | {"max_sensors": , "rx_flags": , "en_decoders": } | n.a. | -| CMD_GET_BLE_ADDR | {"cmd": "CMD_GET_BLE_ADDR"} | {"ble_addr": [, ..., ]} | -| CMD_SET_BLE_ADDR | {"ble_addr": [, ..., ]} | n.a. | | CMD_GET_BLE_CONFIG | {"cmd": "CMD_GET_BLE_CONFIG"} | {"ble_active": , "ble_scantime": } | | CMD_SET_BLE_CONFIG | {"ble_active": , "ble_scantime": } | n.a. | -| CMD_GET_APP_PAYLOAD_CFG | {"cmd": "CMD_GET_APP_PAYLOAD_CFG"} | {"bresser": [\, \, ..., \], "onewire": \, "analog": \, "digital": \} | -| CMD_SET_APP_PAYLOAD_CFG | {"bresser": [\, \, ..., \], "onewire": \, "analog": \, "digital": \} | n.a. | +| CMD_GET_BLE_ADDR | {"cmd": "CMD_GET_BLE_ADDR"} | {"ble_addr": [, ..., ]} | +| CMD_SET_BLE_ADDR | {"ble_addr": [, ..., ]} | n.a. | #### The Things Network Examples diff --git a/extras/confighelper/confighelper.html b/extras/confighelper/confighelper.html index 9148082..2b389c2 100644 --- a/extras/confighelper/confighelper.html +++ b/extras/confighelper/confighelper.html @@ -46,6 +46,8 @@ // 20240531 Fixed getLightningconfig() // 20240606 Changed lightning signal names // 20240607 Added maximum payload size input, info and modified check for size limit +// 20240610 Changed Weather Sensor configuration according to modification +// of PayloadBresser (assign to configArray[1]) // // ToDo: // - @@ -449,7 +451,7 @@ // Update the size field document.getElementById('size').value = totalSize; - configArray[0] = weatherValue; + configArray[1] = weatherValue; // Get the current JSON output let jsonOutput = JSON.parse(document.getElementById('jsonOutput').value); diff --git a/scripts/downlink_formatter.js b/scripts/downlink_formatter.js index 0bdc72d..f51d1f8 100644 --- a/scripts/downlink_formatter.js +++ b/scripts/downlink_formatter.js @@ -126,6 +126,7 @@ // 20240603 Added CMD_GET_SENSORS_STAT // 20240607 Added CMD_GET_STATUS_INTERVAL/CMD_SET_STATUS_INTERVAL // 20240608 Added CMD_GET_LW_STATUS +// 20240609 Refactored command encoding // // ToDo: // - @@ -133,30 +134,30 @@ /////////////////////////////////////////////////////////////////////////////// // Commands -const CMD_SET_SLEEP_INTERVAL = 0xA8; -const CMD_SET_SLEEP_INTERVAL_LONG = 0xA9; -const CMD_GET_DATETIME = 0x86; -const CMD_SET_DATETIME = 0x88; -const CMD_GET_LW_CONFIG = 0xB1; -const CMD_GET_LW_STATUS = 0xB2; +const CMD_GET_DATETIME = 0x20; +const CMD_SET_DATETIME = 0x21; +const CMD_SET_SLEEP_INTERVAL = 0x31; +const CMD_SET_SLEEP_INTERVAL_LONG = 0x33; +const CMD_GET_LW_CONFIG = 0x36; +const CMD_GET_LW_STATUS = 0x38; +const CMD_GET_STATUS_INTERVAL = 0x40; +const CMD_SET_STATUS_INTERVAL = 0x41; +const CMD_GET_SENSORS_STAT = 0x42; +const CMD_GET_APP_PAYLOAD_CFG = 0x46; +const CMD_SET_APP_PAYLOAD_CFG = 0x47; const CMD_GET_WS_TIMEOUT = 0xC0; const CMD_SET_WS_TIMEOUT = 0xC1; const CMD_RESET_RAINGAUGE = 0xC3; -const CMD_GET_STATUS_INTERVAL = 0xD2; -const CMD_SET_STATUS_INTERVAL = 0xD3; -const CMD_GET_SENSORS_STAT = 0xD0; -const CMD_GET_SENSORS_INC = 0xC4; -const CMD_SET_SENSORS_INC = 0xC5; -const CMD_GET_SENSORS_EXC = 0xC6; -const CMD_SET_SENSORS_EXC = 0xC7; -const CMD_GET_SENSORS_CFG = 0xCC; -const CMD_SET_SENSORS_CFG = 0xCD; -const CMD_GET_APP_PAYLOAD_CFG = 0xCE; -const CMD_SET_APP_PAYLOAD_CFG = 0xCF; -const CMD_GET_BLE_ADDR = 0xC8; -const CMD_SET_BLE_ADDR = 0xC9; -const CMD_GET_BLE_CONFIG = 0xCA; -const CMD_SET_BLE_CONFIG = 0xCB; +const CMD_GET_SENSORS_INC = 0xC6; +const CMD_SET_SENSORS_INC = 0xC7; +const CMD_GET_SENSORS_EXC = 0xC8; +const CMD_SET_SENSORS_EXC = 0xC9; +const CMD_GET_SENSORS_CFG = 0xCA; +const CMD_SET_SENSORS_CFG = 0xCB; +const CMD_GET_BLE_CONFIG = 0xD0; +const CMD_SET_BLE_CONFIG = 0xD1; +const CMD_GET_BLE_ADDR = 0xD2; +const CMD_SET_BLE_ADDR = 0xD3; // Source of Real Time Clock setting diff --git a/scripts/uplink_formatter.js b/scripts/uplink_formatter.js index 9158109..9207eef 100644 --- a/scripts/uplink_formatter.js +++ b/scripts/uplink_formatter.js @@ -135,6 +135,9 @@ // 20240606 Changed naming of post-processed lightning data // 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: // - @@ -150,18 +153,18 @@ function decoder(bytes, port) { // Compatibility mode: create "status" as in BresserweatherSensorTTN const COMPATIBILITY_MODE = true; - const CMD_GET_DATETIME = 0x86; - const CMD_GET_LW_CONFIG = 0xB1; - const CMD_GET_LW_STATUS = 0xB2; + const CMD_GET_DATETIME = 0x20; + const CMD_GET_LW_CONFIG = 0x36; + const CMD_GET_LW_STATUS = 0x38; + const CMD_GET_STATUS_INTERVAL = 0x40; + const CMD_GET_SENSORS_STAT = 0x42; + const CMD_GET_APP_PAYLOAD_CFG = 0x46; const CMD_GET_WS_TIMEOUT = 0xC0; - const CMD_GET_SENSORS_INC = 0xC4; - const CMD_GET_SENSORS_EXC = 0xC6; - const CMD_GET_SENSORS_CFG = 0xCC; - const CMD_GET_BLE_ADDR = 0xC8; - const CMD_GET_BLE_CONFIG = 0xCA; - const CMD_GET_APP_PAYLOAD_CFG = 0xCE; - const CMD_GET_SENSORS_STAT = 0xD0; - const CMD_GET_STATUS_INTERVAL = 0xD2; + const CMD_GET_SENSORS_INC = 0xC6; + const CMD_GET_SENSORS_EXC = 0xC8; + const CMD_GET_SENSORS_CFG = 0xCA; + const CMD_GET_BLE_CONFIG = 0xD0; + const CMD_GET_BLE_ADDR = 0xD2; const rtc_source_code = { 0x00: "GPS", @@ -222,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'); @@ -538,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, @@ -647,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' ] @@ -667,7 +681,7 @@ function decoder(bytes, port) { return decode( port, bytes, - [uint8, uint8 + [bits8, bits8 ], ['ble_active', 'ble_scantime'] ); @@ -683,7 +697,7 @@ function decoder(bytes, port) { return decode( port, bytes, - [uint8 + [bits8 ], ['status_interval' ] diff --git a/src/AppLayer.cpp b/src/AppLayer.cpp index f56268a..233c40e 100644 --- a/src/AppLayer.cpp +++ b/src/AppLayer.cpp @@ -86,17 +86,6 @@ void AppLayer::getPayloadStage1(uint8_t port, LoraEncoder &encoder) log_i("--- Uplink Data ---"); - // TODO: Handle battery status flags in PayloadBresser - // // Sensor status flags - // encoder.writeBitmap(0, - // mithermometer_valid, - // (ls > -1) ? weatherSensor.sensor[ls].valid : false, - // (ls > -1) ? weatherSensor.sensor[ls].battery_ok : false, - // (s1 > -1) ? weatherSensor.sensor[s1].valid : false, - // (s1 > -1) ? weatherSensor.sensor[s1].battery_ok : false, - // (ws > -1) ? weatherSensor.sensor[ws].valid : false, - // (ws > -1) ? weatherSensor.sensor[ws].battery_ok : false); - encodeBresser(appPayloadCfg, appStatus, encoder); #ifdef ONEWIRE_EN