Skip to content

Commit a14acfa

Browse files
author
Hasnain Virk
committed
Updating unit tests
Updating unit test in response to the change in the link ADR related APIs.
1 parent 726eff9 commit a14acfa

File tree

5 files changed

+23
-1
lines changed

5 files changed

+23
-1
lines changed

UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ TEST_F(Test_LoRaPHYAU915, link_ADR_request)
181181
uint8_t nb_rep_out = 0;
182182
uint8_t nb_bytes_parsed = 0;
183183

184+
uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4};
185+
params.payload = payload;
186+
params.payload_size = 5;
187+
184188
LoRaPHY_stub::uint8_value = 1;
185189
LoRaPHY_stub::ch_mask_value = 6;
186190
LoRaPHY_stub::adr_parse_count = 2;

UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ TEST_F(Test_LoRaPHYCN470, link_ADR_request)
206206
uint8_t nb_rep_out = 0;
207207
uint8_t nb_bytes_parsed = 0;
208208

209+
uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4};
210+
params.payload = payload;
211+
params.payload_size = 5;
212+
209213
LoRaPHY_stub::uint8_value = 1;
210214
LoRaPHY_stub::ch_mask_value = 6;
211215
LoRaPHY_stub::adr_parse_count = 2;

UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,22 @@ TEST_F(Test_LoRaPHYUS915, tx_config)
177177

178178
TEST_F(Test_LoRaPHYUS915, link_ADR_request)
179179
{
180+
uint8_t payload [] = {SRV_MAC_LINK_ADR_REQ, 1, 2, 3, 4};
180181
adr_req_params_t params;
181182
memset(&params, 0, sizeof(params));
182183
int8_t dr_out = 0;
183184
int8_t tx_power_out = 0;
184185
uint8_t nb_rep_out = 0;
185186
uint8_t nb_bytes_parsed = 0;
186187

187-
EXPECT_TRUE(0 == object->link_ADR_request(&params, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed));
188+
params.payload = payload;
189+
params.payload_size = 4;
188190

191+
uint8_t status = object->link_ADR_request(&params, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed);
192+
193+
EXPECT_TRUE(0 == nb_bytes_parsed);
194+
195+
params.payload_size = 5;
189196
LoRaPHY_stub::uint8_value = 1;
190197
LoRaPHY_stub::ch_mask_value = 6;
191198
LoRaPHY_stub::adr_parse_count = 2;

UNITTESTS/features/lorawan/lorawanstack/Test_LoRaWANStack.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,10 @@ TEST_F(Test_LoRaWANStack, handle_rx)
494494
ind.buffer = ind_buf;
495495
ind.buffer_size = 150;
496496
ind.type = MCPS_UNCONFIRMED;
497+
ind.port = 15;
498+
ind.is_data_recvd = true;
499+
ind.fpending_status = false;
500+
LoRaMac_stub::dev_class_value = CLASS_A;
497501
radio._ev->rx_done(NULL, 0, 0, 0);
498502

499503
//data == NULL || LENGTH == 0 (2 cases)

UNITTESTS/stubs/LoRaPHY_stub.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
151151
}
152152

153153
uint8_t LoRaPHY::parse_link_ADR_req(const uint8_t *payload,
154+
uint8_t payload_size,
154155
link_adr_params_t *params)
155156
{
156157
params->ch_mask_ctrl = LoRaPHY_stub::ch_mask_value;
158+
params->channel_mask = 0;
159+
params->datarate = 0;
157160

158161
if (LoRaPHY_stub::adr_parse_count) {
159162
return --LoRaPHY_stub::adr_parse_count;

0 commit comments

Comments
 (0)