mirror of https://github.com/ARMmbed/mbed-os.git
commit
03ad9d63ec
|
@ -277,14 +277,16 @@ lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled)
|
|||
|
||||
lorawan_status_t LoRaWANStack::stop_sending(void)
|
||||
{
|
||||
if (_device_current_state == DEVICE_STATE_NOT_INITIALIZED) {
|
||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
if (_loramac.clear_tx_pipe() == LORAWAN_STATUS_OK) {
|
||||
if (_device_current_state == DEVICE_STATE_SENDING) {
|
||||
_ctrl_flags &= ~TX_DONE_FLAG;
|
||||
_ctrl_flags &= ~TX_ONGOING_FLAG;
|
||||
_loramac.set_tx_ongoing(false);
|
||||
_device_current_state = DEVICE_STATE_IDLE;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
_ctrl_flags &= ~TX_DONE_FLAG;
|
||||
_ctrl_flags &= ~TX_ONGOING_FLAG;
|
||||
_loramac.set_tx_ongoing(false);
|
||||
_device_current_state = DEVICE_STATE_IDLE;
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
return LORAWAN_STATUS_BUSY;
|
||||
|
|
|
@ -839,6 +839,7 @@ lorawan_status_t LoRaMac::handle_retransmission()
|
|||
void LoRaMac::on_backoff_timer_expiry(void)
|
||||
{
|
||||
Lock lock(*this);
|
||||
_lora_time.stop(_params.timers.backoff_timer);
|
||||
lorawan_status_t status = schedule_tx();
|
||||
MBED_ASSERT(status == LORAWAN_STATUS_OK);
|
||||
(void) status;
|
||||
|
@ -1012,7 +1013,13 @@ int LoRaMac::get_backoff_timer_event_id(void)
|
|||
lorawan_status_t LoRaMac::clear_tx_pipe(void)
|
||||
{
|
||||
// check if the event is not already queued
|
||||
if (_ev_queue->time_left(get_backoff_timer_event_id()) > 0) {
|
||||
const int id = get_backoff_timer_event_id();
|
||||
if (id == 0) {
|
||||
// No queued send request
|
||||
return LORAWAN_STATUS_OK;
|
||||
}
|
||||
|
||||
if (_ev_queue->time_left(id) > 0) {
|
||||
_lora_time.stop(_params.timers.backoff_timer);
|
||||
_lora_time.stop(_params.timers.ack_timeout_timer);
|
||||
memset(_params.tx_buffer, 0, sizeof _params.tx_buffer);
|
||||
|
@ -1020,9 +1027,10 @@ lorawan_status_t LoRaMac::clear_tx_pipe(void)
|
|||
reset_ongoing_tx(true);
|
||||
tr_debug("Sending Cancelled");
|
||||
return LORAWAN_STATUS_OK;
|
||||
} else {
|
||||
// Event is already being dispatched so it cannot be cancelled
|
||||
return LORAWAN_STATUS_BUSY;
|
||||
}
|
||||
|
||||
return LORAWAN_STATUS_BUSY;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMac::schedule_tx()
|
||||
|
|
Loading…
Reference in New Issue