Skip to content

Commit cf53494

Browse files
author
Antti Kauppila
committed
Compliance test errors fixed
1 parent aab3ade commit cf53494

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

UNITTESTS/features/lorawan/loramac/Test_LoRaMac.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ void exp_cb()
215215
TEST_F(Test_LoRaMac, set_device_class)
216216
{
217217
object->set_device_class(CLASS_B, exp_cb);
218+
219+
my_phy phy;
220+
object->bind_phy(phy);
221+
object->set_device_class(CLASS_C, exp_cb);
218222
}
219223

220224
TEST_F(Test_LoRaMac, setup_link_check_request)

features/lorawan/LoRaWANStack.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ int16_t LoRaWANStack::handle_tx(const uint8_t port, const uint8_t *data,
310310
if (_link_check_requested) {
311311
_loramac.setup_link_check_request();
312312
}
313+
_qos_cnt = 1;
313314

314315
lorawan_status_t status;
315316

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ LoRaMac::LoRaMac()
8080
_can_cancel_tx(true),
8181
_continuous_rx2_window_open(false),
8282
_device_class(CLASS_A),
83-
_prev_qos_level(LORAWAN_DEFAULT_QOS)
83+
_prev_qos_level(LORAWAN_DEFAULT_QOS),
84+
_demod_ongoing(false)
8485
{
8586
memset(&_params, 0, sizeof(_params));
8687
_params.keys.dev_eui = NULL;
@@ -99,7 +100,6 @@ LoRaMac::LoRaMac()
99100
_params.rx_buffer_len = 0;
100101
_params.ul_frame_counter = 0;
101102
_params.dl_frame_counter = 0;
102-
_params.is_ul_frame_counter_fixed = false;
103103
_params.is_rx_window_enabled = true;
104104
_params.adr_ack_counter = 0;
105105
_params.is_node_ack_requested = false;
@@ -166,21 +166,17 @@ void LoRaMac::post_process_mcps_req()
166166
_params.is_node_ack_requested = false;
167167
_mcps_confirmation.ack_received = false;
168168
_mcps_indication.is_ack_recvd = false;
169-
if (_params.is_ul_frame_counter_fixed == false) {
170-
_params.ul_frame_counter++;
171-
_params.adr_ack_counter++;
172-
}
169+
_params.ul_frame_counter++;
170+
_params.adr_ack_counter++;
173171
} else {
174172
_mcps_confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
175173
}
176174
} else {
177175
//UNCONFIRMED or PROPRIETARY
178-
if (_params.is_ul_frame_counter_fixed == false) {
179-
_params.ul_frame_counter++;
180-
_params.adr_ack_counter++;
181-
if (_params.sys_params.nb_trans > 1) {
182-
_mcps_confirmation.nb_retries = _params.ul_nb_rep_counter;
183-
}
176+
_params.ul_frame_counter++;
177+
_params.adr_ack_counter++;
178+
if (_params.sys_params.nb_trans > 1) {
179+
_mcps_confirmation.nb_retries = _params.ul_nb_rep_counter;
184180
}
185181
}
186182
}
@@ -650,8 +646,8 @@ void LoRaMac::on_radio_tx_done(lorawan_time_t timestamp)
650646

651647
if ((_mcps_confirmation.req_type == MCPS_UNCONFIRMED)
652648
&& (_params.sys_params.nb_trans > 1)) {
649+
//MBED_ASSERT(_params.ul_nb_rep_counter <= _params.sys_params.nb_trans);
653650
_params.ul_nb_rep_counter++;
654-
MBED_ASSERT(_params.ul_nb_rep_counter <= _params.sys_params.nb_trans);
655651
}
656652

657653
if (_params.is_rx_window_enabled == true) {
@@ -696,6 +692,7 @@ void LoRaMac::on_radio_tx_done(lorawan_time_t timestamp)
696692
void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size,
697693
int16_t rssi, int8_t snr)
698694
{
695+
_demod_ongoing = false;
699696
if (_device_class == CLASS_C && !_continuous_rx2_window_open) {
700697
_lora_time.stop(_rx2_closure_timer_for_class_c);
701698
open_rx2_window();
@@ -765,6 +762,7 @@ void LoRaMac::on_radio_tx_timeout(void)
765762

766763
void LoRaMac::on_radio_rx_timeout(bool is_timeout)
767764
{
765+
_demod_ongoing = false;
768766
if (_device_class == CLASS_A) {
769767
_lora_phy->put_radio_to_sleep();
770768
}
@@ -887,6 +885,7 @@ void LoRaMac::on_backoff_timer_expiry(void)
887885
void LoRaMac::open_rx1_window(void)
888886
{
889887
Lock lock(*this);
888+
_demod_ongoing = true;
890889
_continuous_rx2_window_open = false;
891890
_lora_time.stop(_params.timers.rx_window1_timer);
892891
_params.rx_slot = RX_SLOT_WIN_1;
@@ -912,6 +911,10 @@ void LoRaMac::open_rx1_window(void)
912911

913912
void LoRaMac::open_rx2_window()
914913
{
914+
if (_demod_ongoing) {
915+
tr_info("RX1 Demodulation ongoing, skip RX2 window opening");
916+
return;
917+
}
915918
Lock lock(*this);
916919
_continuous_rx2_window_open = true;
917920
_lora_time.stop(_params.timers.rx_window2_timer);
@@ -1243,6 +1246,8 @@ void LoRaMac::reset_mac_parameters(void)
12431246
}
12441247
_params.channel = 0;
12451248
_params.last_channel_idx = _params.channel;
1249+
1250+
_demod_ongoing = false;
12461251
}
12471252

12481253
uint8_t LoRaMac::get_default_tx_datarate()

features/lorawan/lorastack/mac/LoRaMac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ class LoRaMac {
696696
device_class_t _device_class;
697697

698698
uint8_t _prev_qos_level;
699+
700+
bool _demod_ongoing;
699701
};
700702

701703
#endif // MBED_LORAWAN_MAC_H__

features/lorawan/system/lorawan_data_structures.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,12 +1127,6 @@ typedef struct {
11271127
*/
11281128
bool is_repeater_supported;
11291129

1130-
/*!
1131-
* IsPacketCounterFixed enables the MIC field tests by fixing the
1132-
* ul_frame_counter value
1133-
*/
1134-
bool is_ul_frame_counter_fixed;
1135-
11361130
/*!
11371131
* Used for test purposes. Disables the opening of the reception windows.
11381132
*/

0 commit comments

Comments
 (0)