Merge pull request #925 from cyberman54/development

Development
This commit is contained in:
Verkehrsrot 2022-12-31 19:35:30 +01:00 committed by GitHub
commit 637add2ec9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 13 deletions

View File

@ -37,6 +37,7 @@ void os_getDevEui(u1_t *buf);
void lora_send(void *pvParameters);
void lora_enqueuedata(MessageBuffer_t *message);
void lora_queuereset(void);
void lora_waitforidle(uint16_t timeout_sec);
uint32_t lora_queuewaiting(void);
void myEventCallback(void *pUserData, ev_t ev);
void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,

View File

@ -54,7 +54,7 @@ extra_scripts = pre:build.py
otakeyfile = ota.conf
lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@5.2.0
platform_espressif32 = espressif32@5.3.0
monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_lora =

View File

@ -18,7 +18,7 @@ extra_scripts = pre:build.py
otakeyfile = ota.conf
lorakeyfile = loraconf.h
lmicconfigfile = lmic_config.h
platform_espressif32 = espressif32@5.2.0
platform_espressif32 = espressif32@5.3.0
monitor_speed = 115200
upload_speed = 115200 ; set by build.py and taken from hal file
lib_deps_all =

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);

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