diff --git a/README.md b/README.md index c624bc1d..1af14989 100644 --- a/README.md +++ b/README.md @@ -530,8 +530,8 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat 0x19 set sleep cycle - 0 ... 255 device sleep cycle in seconds/2 - e.g. 120 -> device sleeps 240 seconds after each send cycle [default = 0] + bytes 1..2 = device sleep cycle in seconds/10 (MSB) + e.g. {0x04, 0xB0} -> device sleeps 20 minutes after each send cycle [default = 0] 0x20 load device configuration @@ -585,7 +585,7 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat 0x88 set time/date - bytes 1..4 = time/date to set in UTC epoch seconds (LSB, e.g. https://www.epochconverter.com/hex) + bytes 1..4 = time/date to set in UTC epoch seconds (MSB, e.g. https://www.epochconverter.com/hex) # License diff --git a/include/globals.h b/include/globals.h index 950d21b1..3c7ae9ea 100644 --- a/include/globals.h +++ b/include/globals.h @@ -75,7 +75,7 @@ typedef struct __attribute__((packed)) { uint8_t countermode; // 0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed int16_t rssilimit; // threshold for rssilimiter, negative value! uint8_t sendcycle; // payload send cycle [seconds/2] - uint8_t sleepcycle; // sleep cycle [seconds/2] + uint16_t sleepcycle; // sleep cycle [seconds/10] uint8_t wifichancycle; // wifi channel switch cycle [seconds/100] uint8_t blescantime; // BLE scan cycle duration [seconds] uint8_t blescan; // 0=disabled, 1=enabled diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 5ef3c41f..ceccfcdc 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -42,7 +42,7 @@ static void defaultConfig(configData_t *myconfig) { COUNTERMODE; // 0=cyclic, 1=cumulative, 2=cyclic confirmed myconfig->rssilimit = 0; // threshold for rssilimiter, negative value! myconfig->sendcycle = SENDCYCLE; // payload send cycle [seconds/2] - myconfig->sleepcycle = SLEEPCYCLE; // sleep cycle [seconds/2] + myconfig->sleepcycle = SLEEPCYCLE; // sleep cycle [seconds/10] myconfig->wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100] myconfig->blescantime = diff --git a/src/irqhandler.cpp b/src/irqhandler.cpp index 244910ad..89bd4c23 100644 --- a/src/irqhandler.cpp +++ b/src/irqhandler.cpp @@ -90,9 +90,9 @@ void irqHandler(void *pvParameters) { // goto sleep if we have a sleep cycle if (cfg.sleepcycle) #ifdef HAS_BUTTON - enter_deepsleep(cfg.sleepcycle * 2, (gpio_num_t)HAS_BUTTON); + enter_deepsleep(cfg.sleepcycle * 10, (gpio_num_t)HAS_BUTTON); #else - enter_deepsleep(cfg.sleepcycle * 2); + enter_deepsleep(cfg.sleepcycle * 10); #endif } } // for diff --git a/src/paxcounter_orig.conf b/src/paxcounter_orig.conf index 05246eab..3140b45f 100644 --- a/src/paxcounter_orig.conf +++ b/src/paxcounter_orig.conf @@ -14,7 +14,7 @@ // Payload send cycle and encoding #define SENDCYCLE 30 // payload send cycle [seconds/2], 0 .. 255 -#define SLEEPCYCLE 0 // sleep time after a send cycle [seconds/2], 0 .. 255; 0 means no sleep [default = 0] +#define SLEEPCYCLE 0 // sleep time after a send cycle [seconds/10], 0 .. 65535; 0 means no sleep [default = 0] #define PAYLOAD_ENCODER 2 // payload encoder: 1=Plain, 2=Packed, 3=Cayenne LPP dynamic, 4=Cayenne LPP packed #define COUNTERMODE 0 // 0=cyclic, 1=cumulative, 2=cyclic confirmed diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 454102cf..0fd2c933 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -68,9 +68,11 @@ void set_sendcycle(uint8_t val[]) { } void set_sleepcycle(uint8_t val[]) { - cfg.sleepcycle = val[0]; + // swap byte order from msb to lsb, note: this is a platform dependent hack + uint16_t t = __builtin_bswap16(*(uint16_t *)(val)); + cfg.sleepcycle = t; ESP_LOGI(TAG, "Remote command: set sleep cycle to %d seconds", - cfg.sleepcycle * 2); + cfg.sleepcycle * 10); } void set_wifichancycle(uint8_t val[]) { @@ -435,7 +437,7 @@ static const cmd_t table[] = { {0x13, set_sensor, 2}, {0x14, set_payloadmask, 1}, {0x15, set_bme, 1}, {0x16, set_batt, 1}, {0x17, set_wifiscan, 1}, {0x18, set_enscount, 1}, - {0x19, set_sleepcycle, 1}, {0x20, set_loadconfig, 0}, + {0x19, set_sleepcycle, 2}, {0x20, set_loadconfig, 0}, {0x21, set_saveconfig, 0}, {0x80, get_config, 0}, {0x81, get_status, 0}, {0x83, get_batt, 0}, {0x84, get_gps, 0}, {0x85, get_bme, 0},