Skip to content

Commit 34fd640

Browse files
author
Cruz Monrreal
authored
Merge pull request #7344 from hasnainvirk/tx_timeout_fix
LoRaWAN: Fixing transport of fatal TX timeout event
2 parents cb000ce + 7ce434b commit 34fd640

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

features/lorawan/LoRaWANStack.cpp

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,14 @@ void LoRaWANStack::process_transmission_timeout()
557557
// this is a fatal error and should not happen
558558
tr_debug("TX Timeout");
559559
_loramac.on_radio_tx_timeout();
560-
_ctrl_flags |= TX_ONGOING_FLAG;
560+
_ctrl_flags &= ~TX_ONGOING_FLAG;
561561
_ctrl_flags &= ~TX_DONE_FLAG;
562-
state_controller(DEVICE_STATE_STATUS_CHECK);
562+
if (_device_current_state == DEVICE_STATE_JOINING) {
563+
mlme_confirm_handler();
564+
} else {
565+
state_controller(DEVICE_STATE_STATUS_CHECK);
566+
}
567+
563568
state_machine_run_to_completion();
564569
}
565570

@@ -888,21 +893,33 @@ void LoRaWANStack::mlme_confirm_handler()
888893
}
889894
}
890895
}
891-
} else if (_loramac.get_mlme_confirmation()->req_type == MLME_JOIN) {
892-
if (_loramac.get_mlme_confirmation()->status == LORAMAC_EVENT_INFO_STATUS_OK) {
893-
state_controller(DEVICE_STATE_CONNECTED);
894-
} else {
895-
tr_error("Joining error: %d", _loramac.get_mlme_confirmation()->status);
896-
if (_loramac.get_mlme_confirmation()->status == LORAMAC_EVENT_INFO_STATUS_CRYPTO_FAIL) {
896+
}
897+
898+
if (_loramac.get_mlme_confirmation()->req_type == MLME_JOIN) {
899+
900+
switch (_loramac.get_mlme_confirmation()->status) {
901+
case LORAMAC_EVENT_INFO_STATUS_OK:
902+
state_controller(DEVICE_STATE_CONNECTED);
903+
break;
904+
905+
case LORAMAC_EVENT_INFO_STATUS_CRYPTO_FAIL:
897906
// fatal error
898907
_device_current_state = DEVICE_STATE_IDLE;
908+
tr_error("Joining abandoned: CRYPTO_ERROR");
899909
send_event_to_application(CRYPTO_ERROR);
900-
} else {
910+
break;
911+
912+
case LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT:
913+
// fatal error
914+
_device_current_state = DEVICE_STATE_IDLE;
915+
tr_error("Joining abandoned: Radio failed to transmit");
916+
send_event_to_application(TX_TIMEOUT);
917+
break;
918+
919+
default:
901920
// non-fatal, retry if possible
902921
_device_current_state = DEVICE_STATE_AWAITING_JOIN_ACCEPT;
903922
state_controller(DEVICE_STATE_JOINING);
904-
}
905-
906923
}
907924
}
908925
}
@@ -917,9 +934,8 @@ void LoRaWANStack::mcps_confirm_handler()
917934
}
918935

919936
// failure case
920-
tr_error("mcps_confirmation: Error code = %d", _loramac.get_mcps_confirmation()->status);
921-
922937
if (_loramac.get_mcps_confirmation()->status == LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT) {
938+
tr_error("Fatal Error, Radio failed to transmit");
923939
send_event_to_application(TX_TIMEOUT);
924940
return;
925941
}

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,6 @@ void LoRaMac::on_radio_tx_timeout(void)
727727
_mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter;
728728
_mcps_confirmation.ack_received = false;
729729
_mcps_confirmation.tx_toa = 0;
730-
731-
post_process_mcps_req();
732730
}
733731

734732
void LoRaMac::on_radio_rx_timeout(bool is_timeout)

0 commit comments

Comments
 (0)