commit
637add2ec9
@ -37,6 +37,7 @@ void os_getDevEui(u1_t *buf);
|
|||||||
void lora_send(void *pvParameters);
|
void lora_send(void *pvParameters);
|
||||||
void lora_enqueuedata(MessageBuffer_t *message);
|
void lora_enqueuedata(MessageBuffer_t *message);
|
||||||
void lora_queuereset(void);
|
void lora_queuereset(void);
|
||||||
|
void lora_waitforidle(uint16_t timeout_sec);
|
||||||
uint32_t lora_queuewaiting(void);
|
uint32_t lora_queuewaiting(void);
|
||||||
void myEventCallback(void *pUserData, ev_t ev);
|
void myEventCallback(void *pUserData, ev_t ev);
|
||||||
void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
|
void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
|
||||||
|
@ -54,7 +54,7 @@ extra_scripts = pre:build.py
|
|||||||
otakeyfile = ota.conf
|
otakeyfile = ota.conf
|
||||||
lorakeyfile = loraconf.h
|
lorakeyfile = loraconf.h
|
||||||
lmicconfigfile = lmic_config.h
|
lmicconfigfile = lmic_config.h
|
||||||
platform_espressif32 = espressif32@5.2.0
|
platform_espressif32 = espressif32@5.3.0
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 115200 ; set by build.py and taken from hal file
|
upload_speed = 115200 ; set by build.py and taken from hal file
|
||||||
lib_deps_lora =
|
lib_deps_lora =
|
||||||
|
@ -18,7 +18,7 @@ extra_scripts = pre:build.py
|
|||||||
otakeyfile = ota.conf
|
otakeyfile = ota.conf
|
||||||
lorakeyfile = loraconf.h
|
lorakeyfile = loraconf.h
|
||||||
lmicconfigfile = lmic_config.h
|
lmicconfigfile = lmic_config.h
|
||||||
platform_espressif32 = espressif32@5.2.0
|
platform_espressif32 = espressif32@5.3.0
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 115200 ; set by build.py and taken from hal file
|
upload_speed = 115200 ; set by build.py and taken from hal file
|
||||||
lib_deps_all =
|
lib_deps_all =
|
||||||
|
@ -332,6 +332,18 @@ uint32_t lora_queuewaiting(void) {
|
|||||||
return uxQueueMessagesWaiting(LoraSendQueue);
|
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
|
// LMIC loop task
|
||||||
void lmictask(void *pvParameters) {
|
void lmictask(void *pvParameters) {
|
||||||
_ASSERT((uint32_t)pvParameters == 1);
|
_ASSERT((uint32_t)pvParameters == 1);
|
||||||
|
@ -85,7 +85,6 @@ 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;
|
||||||
int i;
|
|
||||||
|
|
||||||
// validate wake up pin, if we have
|
// validate wake up pin, if we have
|
||||||
if (!GPIO_IS_VALID_GPIO(wakeup_gpio))
|
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
|
// wait a while (max 100 sec) to clear send queues
|
||||||
ESP_LOGI(TAG, "Waiting until send queues are empty...");
|
ESP_LOGI(TAG, "Waiting until send queues are empty...");
|
||||||
for (i = 100; i > 0; i--) {
|
for (int i = 100; i > 0; i--) {
|
||||||
if (allQueuesEmtpy())
|
if (allQueuesEmtpy())
|
||||||
break;
|
break;
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// wait until LMIC is idle
|
// wait up to 100secs until LMIC is idle
|
||||||
#if (HAS_LORA)
|
#if (HAS_LORA)
|
||||||
ESP_LOGI(TAG, "Waiting until LMIC is idle...");
|
lora_waitforidle(100);
|
||||||
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;
|
|
||||||
}
|
|
||||||
#endif // (HAS_LORA)
|
#endif // (HAS_LORA)
|
||||||
|
|
||||||
// shutdown MQTT safely
|
// shutdown MQTT safely
|
||||||
|
Loading…
Reference in New Issue
Block a user