Merge pull request #925 from cyberman54/development

Development
This commit is contained in:
Verkehrsrot authored and GitHub committed 2022-12-31 19:35:30 +01:00
commit 637add2ec9
5 files changed
+18 -13

No files matched your search

+12
View File
@@ -332,6 +332,18 @@ uint32_t lora_queuewaiting(void) {
return uxQueueMessagesWaiting(LoraSendQueue);
}
// blocking wait until LMIC is idle
void lora_waitforidle(uint16_t timeout_sec) {
ESP_LOGI(TAG, "Waiting until LMIC is idle...");
for (int i = timeout_sec; i > 0; i--) {
if ((LMIC.opmode & (OP_JOINING | OP_TXDATA | OP_POLL | OP_TXRXPEND)) ||
os_queryTimeCriticalJobs(sec2osticks(timeout_sec)))
vTaskDelay(pdMS_TO_TICKS(1000));
else
break;
}
}
// LMIC loop task
void lmictask(void *pvParameters) {
_ASSERT((uint32_t)pvParameters == 1);
+3 -11
View File
@@ -85,7 +85,6 @@ void enter_deepsleep(const uint32_t wakeup_sec, gpio_num_t wakeup_gpio) {
ESP_LOGI(TAG, "Preparing to sleep...");
RTC_runmode = RUNMODE_SLEEP;
int i;
// validate wake up pin, if we have
if (!GPIO_IS_VALID_GPIO(wakeup_gpio))
@@ -100,22 +99,15 @@ void enter_deepsleep(const uint32_t wakeup_sec, gpio_num_t wakeup_gpio) {
// wait a while (max 100 sec) to clear send queues
ESP_LOGI(TAG, "Waiting until send queues are empty...");
for (i = 100; i > 0; i--) {
for (int i = 100; i > 0; i--) {
if (allQueuesEmtpy())
break;
vTaskDelay(pdMS_TO_TICKS(1000));
}
/// wait until LMIC is idle
// wait up to 100secs until LMIC is idle
#if (HAS_LORA)
ESP_LOGI(TAG, "Waiting until LMIC is idle...");
for (i = 100; i > 0; i--) {
if ((LMIC.opmode & (OP_JOINING | OP_TXDATA | OP_POLL | OP_TXRXPEND)) ||
os_queryTimeCriticalJobs(sec2osticks(wakeup_sec)))
vTaskDelay(pdMS_TO_TICKS(1000));
else
break;
}
lora_waitforidle(100);
#endif // (HAS_LORA)
// shutdown MQTT safely