fix sleep mode oddities
This commit is contained in:
parent
73c02dea56
commit
fa1d29c627
@ -518,7 +518,7 @@ Send for example `83` `86` as Downlink on Port 2 to get battery status and time/
|
|||||||
0x19 set sleep cycle
|
0x19 set sleep cycle
|
||||||
|
|
||||||
bytes 1..2 = device sleep cycle in seconds/10 (MSB), 1 ... 255
|
bytes 1..2 = device sleep cycle in seconds/10 (MSB), 1 ... 255
|
||||||
e.g. {0x04, 0xB0} -> device sleeps 20 minutes after each send cycle [default = 0]
|
e.g. {0x04, 0xB0} -> device sleeps 200 minutes after each send cycle [default = 0]
|
||||||
|
|
||||||
0x20 load device configuration
|
0x20 load device configuration
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ extern char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer
|
|||||||
|
|
||||||
esp_err_t lmic_init(void);
|
esp_err_t lmic_init(void);
|
||||||
void lora_setupForNetwork(bool preJoin);
|
void lora_setupForNetwork(bool preJoin);
|
||||||
void SaveLMICToRTC(int deepsleep_sec);
|
void SaveLMICToRTC(uint32_t deepsleep_sec);
|
||||||
void LoadLMICFromRTC();
|
void LoadLMICFromRTC();
|
||||||
void lmictask(void *pvParameters);
|
void lmictask(void *pvParameters);
|
||||||
void gen_lora_deveui(uint8_t *pdeveui);
|
void gen_lora_deveui(uint8_t *pdeveui);
|
||||||
|
@ -14,8 +14,7 @@
|
|||||||
void reset_rtc_vars(void);
|
void reset_rtc_vars(void);
|
||||||
void do_reset(bool warmstart);
|
void do_reset(bool warmstart);
|
||||||
void do_after_reset(void);
|
void do_after_reset(void);
|
||||||
void enter_deepsleep(const uint64_t wakeup_sec = 60,
|
void enter_deepsleep(const uint32_t wakeup_sec, const gpio_num_t wakeup_gpio);
|
||||||
const gpio_num_t wakeup_gpio = GPIO_NUM_MAX);
|
|
||||||
unsigned long long uptime(void);
|
unsigned long long uptime(void);
|
||||||
|
|
||||||
enum runmode_t {
|
enum runmode_t {
|
||||||
|
@ -76,9 +76,9 @@ void irqHandler(void *pvParameters) {
|
|||||||
// goto sleep if we have a sleep cycle
|
// goto sleep if we have a sleep cycle
|
||||||
if (cfg.sleepcycle)
|
if (cfg.sleepcycle)
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
enter_deepsleep(cfg.sleepcycle * 10, (gpio_num_t)HAS_BUTTON);
|
enter_deepsleep(cfg.sleepcycle * 10UL, (gpio_num_t)HAS_BUTTON);
|
||||||
#else
|
#else
|
||||||
enter_deepsleep(cfg.sleepcycle * 10);
|
enter_deepsleep(cfg.sleepcycle * 10UL, GPIO_NUM_MAX);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // for
|
} // for
|
||||||
|
@ -501,7 +501,7 @@ bool ttn_rtc_restore() {
|
|||||||
// following code includes snippets taken from
|
// following code includes snippets taken from
|
||||||
// https://github.com/JackGruber/ESP32-LMIC-DeepSleep-example/blob/master/src/main.cpp
|
// https://github.com/JackGruber/ESP32-LMIC-DeepSleep-example/blob/master/src/main.cpp
|
||||||
|
|
||||||
void SaveLMICToRTC(int deepsleep_sec) {
|
void SaveLMICToRTC(uint32_t deepsleep_sec) {
|
||||||
// ESP32 can't track millis during DeepSleep and no option to advance
|
// ESP32 can't track millis during DeepSleep and no option to advance
|
||||||
// millis after DeepSleep. Therefore reset DutyCyles before saving LMIC struct
|
// millis after DeepSleep. Therefore reset DutyCyles before saving LMIC struct
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ void AXP192_powerevent_IRQ(void) {
|
|||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
// short press -> esp32 deep sleep mode, must be exited by user button
|
// short press -> esp32 deep sleep mode, must be exited by user button
|
||||||
if (pmu.isPekeyShortPressIrq())
|
if (pmu.isPekeyShortPressIrq())
|
||||||
enter_deepsleep(0, HAS_BUTTON);
|
enter_deepsleep(0UL, HAS_BUTTON);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pmu.clearIrqStatus();
|
pmu.clearIrqStatus();
|
||||||
|
@ -84,7 +84,7 @@ void do_after_reset(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enter_deepsleep(const uint64_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
void enter_deepsleep(const uint32_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
||||||
ESP_LOGI(TAG, "Preparing to sleep...");
|
ESP_LOGI(TAG, "Preparing to sleep...");
|
||||||
|
|
||||||
RTC_runmode = RUNMODE_SLEEP;
|
RTC_runmode = RUNMODE_SLEEP;
|
||||||
|
Loading…
Reference in New Issue
Block a user