@@ -170,7 +170,6 @@ void LoRaMac::post_process_mcps_req()
170
170
_params.ul_frame_counter ++;
171
171
}
172
172
}
173
-
174
173
} else {
175
174
// UNCONFIRMED or PROPRIETARY
176
175
if (_params.is_ul_frame_counter_fixed == false ) {
@@ -548,6 +547,10 @@ void LoRaMac::handle_data_frame(const uint8_t* const payload,
548
547
return ;
549
548
}
550
549
550
+ // message is intended for us and MIC have passed, stop RX2 Window
551
+ // Spec: 3.3.4 Receiver Activity during the receive windows
552
+ _lora_time.stop (_params.timers .rx_window2_timer );
553
+
551
554
_mcps_confirmation.ack_received = false ;
552
555
_mcps_indication.is_ack_recvd = false ;
553
556
_mcps_indication.pending = true ;
@@ -662,7 +665,6 @@ void LoRaMac::on_radio_rx_done(const uint8_t* const payload, uint16_t size,
662
665
{
663
666
// on reception turn off queued timers
664
667
_lora_time.stop (_params.timers .rx_window1_timer );
665
- _lora_time.stop (_params.timers .rx_window2_timer );
666
668
667
669
if (_device_class == CLASS_C) {
668
670
open_rx2_window ();
@@ -847,6 +849,7 @@ void LoRaMac::on_backoff_timer_expiry(void)
847
849
void LoRaMac::open_rx1_window (void )
848
850
{
849
851
Lock lock (*this );
852
+ tr_debug (" Opening RX1 Window" );
850
853
_lora_time.stop (_params.timers .rx_window1_timer );
851
854
_params.rx_slot = RX_SLOT_WIN_1;
852
855
@@ -871,6 +874,7 @@ void LoRaMac::open_rx1_window(void)
871
874
void LoRaMac::open_rx2_window ()
872
875
{
873
876
Lock lock (*this );
877
+ tr_debug (" Opening RX2 Window" );
874
878
_lora_time.stop (_params.timers .rx_window2_timer );
875
879
876
880
_params.rx_window2_config .channel = _params.channel ;
@@ -925,14 +929,17 @@ void LoRaMac::check_to_disable_ack_timeout(bool node_ack_requested,
925
929
void LoRaMac::on_ack_timeout_timer_event (void )
926
930
{
927
931
Lock lock (*this );
928
- _params.ack_timeout_retry_counter ++;
932
+ tr_debug (" ACK_TIMEOUT Elapses, Retrying ..." );
933
+ _lora_time.stop (_params.timers .ack_timeout_timer );
929
934
930
935
// reduce data rate
931
936
if ((_params.ack_timeout_retry_counter % 2 )) {
932
937
_params.sys_params .channel_data_rate = _lora_phy.get_next_lower_tx_datarate (
933
938
_params.sys_params .channel_data_rate );
934
939
}
935
940
941
+ _mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter ;
942
+
936
943
// Schedule a retry
937
944
if (handle_retransmission () != LORAWAN_STATUS_OK) {
938
945
// In a case when enabled channels are not found, PHY layer
@@ -943,12 +950,13 @@ void LoRaMac::on_ack_timeout_timer_event(void)
943
950
_mac_commands.clear_command_buffer ();
944
951
_params.is_node_ack_requested = false ;
945
952
_mcps_confirmation.ack_received = false ;
946
- _mcps_confirmation.nb_retries = _params.ack_timeout_retry_counter ;
947
953
948
954
// now that is a critical failure
949
955
lorawan_status_t status = handle_retransmission ();
950
956
MBED_ASSERT (status==LORAWAN_STATUS_OK);
951
957
}
958
+
959
+ _params.ack_timeout_retry_counter ++;
952
960
}
953
961
954
962
bool LoRaMac::validate_payload_length (uint16_t length,
@@ -1062,15 +1070,15 @@ lorawan_status_t LoRaMac::schedule_tx()
1062
1070
return status;
1063
1071
case LORAWAN_STATUS_DUTYCYCLE_RESTRICTED:
1064
1072
if (backoff_time != 0 ) {
1065
- tr_debug (" Next Transmission in %lu ms" , backoff_time);
1073
+ tr_debug (" DC enforced: Transmitting in %lu ms" , backoff_time);
1066
1074
_lora_time.start (_params.timers .backoff_timer , backoff_time);
1067
1075
}
1068
1076
return LORAWAN_STATUS_OK;
1069
1077
default :
1070
1078
break ;
1071
1079
}
1072
1080
1073
- tr_debug (" Next Channel Idx =%d, DR=%d" , _params.channel , next_channel.current_datarate );
1081
+ tr_debug (" TX: Channel=%d, DR=%d" , _params.channel , next_channel.current_datarate );
1074
1082
1075
1083
uint8_t dr_offset = _lora_phy.apply_DR_offset (_params.sys_params .channel_data_rate ,
1076
1084
_params.sys_params .rx1_dr_offset );
@@ -1271,9 +1279,7 @@ lorawan_status_t LoRaMac::send_ongoing_tx()
1271
1279
_params.is_last_tx_join_request = false ;
1272
1280
int8_t datarate = _params.sys_params .channel_data_rate ;
1273
1281
1274
- // TODO: The comment is different than the code???
1275
- // Apply the minimum possible datarate.
1276
- // Some regions have limitations for the minimum datarate.
1282
+ // This prohibits the data rate going below the minimum value.
1277
1283
datarate = MAX (datarate, (int8_t )_lora_phy.get_minimum_tx_datarate ());
1278
1284
1279
1285
loramac_mhdr_t machdr;
0 commit comments