Fix ttn_wait_for_idle for MAC cmd processing

This commit is contained in:
Manuel Bl
2021-09-28 22:38:05 +02:00
parent e71d584fca
commit 0130928601
6 changed files with 78 additions and 74 deletions

View File

@ -391,7 +391,12 @@ TickType_t hal_esp32_get_timer_duration(void)
return 1; // busy, not waiting
if (alarm_time != 0)
return pdMS_TO_TICKS((alarm_time - get_current_time() + 999) / 1000);
{
TickType_t dur = pdMS_TO_TICKS((alarm_time - get_current_time() + 999) / 1000);
if (dur > pdMS_TO_TICKS(30000))
dur = pdMS_TO_TICKS(200);
return dur;
}
return 0; // waiting indefinitely

View File

@ -337,6 +337,7 @@ bool ttn_is_provisioned(void)
void ttn_prepare_for_deep_sleep(void)
{
ttn_rtc_save();
stop();
}
@ -357,8 +358,8 @@ TickType_t ttn_busy_duration(void)
if (duration != 0)
return duration; // busy or timer scheduled
if (current_rx_tx_window != TTN_WINDOW_IDLE)
return pdMS_TO_TICKS(100); // within TX/RX window
if ((LMIC.opmode & (OP_JOINING | OP_TXDATA | OP_POLL | OP_TXRXPEND)) != 0)
return pdMS_TO_TICKS(100); // pending action
return 0; // idle
}