mirror of https://github.com/ARMmbed/mbed-os.git
Unit Test Fixes for LoRaWAN
Missing methods are added. Logic was broken at various places which needed to be fixed.pull/8405/head
parent
0a9417299b
commit
3bfef7f43f
|
@ -558,3 +558,12 @@ TEST_F(Test_LoRaMac, get_current_slot)
|
|||
object->get_current_slot();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_QOS_level)
|
||||
{
|
||||
EXPECT_EQ(1, object->get_QOS_level());
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_prev_QOS_level)
|
||||
{
|
||||
EXPECT_EQ(1, object->get_prev_QOS_level());
|
||||
}
|
||||
|
|
|
@ -430,7 +430,7 @@ TEST_F(Test_LoRaPHY, link_ADR_request)
|
|||
//verify adr with p.adr_enabled = false
|
||||
EXPECT_TRUE(0 == object->link_ADR_request(&p, &i, &j, &k, &l));
|
||||
|
||||
p.current_nb_rep = 0;
|
||||
p.current_nb_trans = 0;
|
||||
EXPECT_TRUE(0 == object->link_ADR_request(&p, &i, &j, &k, &l));
|
||||
|
||||
p.adr_enabled = true;
|
||||
|
|
|
@ -201,7 +201,7 @@ TEST_F(Test_LoRaWANInterface, add_app_callbacks)
|
|||
|
||||
TEST_F(Test_LoRaWANInterface, set_device_class)
|
||||
{
|
||||
object->set_device_class(CLASS_A);
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_device_class(CLASS_A));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaWANInterface, get_tx_metadata)
|
||||
|
|
|
@ -350,6 +350,9 @@ TEST_F(Test_LoRaWANStack, handle_tx)
|
|||
cb.events = events_cb;
|
||||
cb.link_check_resp = lc_resp;
|
||||
cb.battery_level = batt_lvl;
|
||||
struct equeue_event ptr;
|
||||
equeue_stub.void_ptr = &ptr;
|
||||
equeue_stub.call_cb_immediately = true;
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_lora_callbacks(&cb));
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_link_check_request());
|
||||
|
||||
|
@ -394,6 +397,10 @@ TEST_F(Test_LoRaWANStack, handle_rx)
|
|||
LoRaMac_stub::status_value = LORAWAN_STATUS_OK;
|
||||
EXPECT_TRUE(LORAWAN_STATUS_NO_ACTIVE_SESSIONS == object->handle_rx(NULL, 0, port, flags, false));
|
||||
|
||||
struct equeue_event ptr;
|
||||
equeue_stub.void_ptr = &ptr;
|
||||
equeue_stub.call_cb_immediately = true;
|
||||
|
||||
lorawan_connect_t conn;
|
||||
conn.connect_type = LORAWAN_CONNECTION_ABP;
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->connect(conn));
|
||||
|
@ -410,14 +417,13 @@ TEST_F(Test_LoRaWANStack, handle_rx)
|
|||
my_LoRaPHY phy;
|
||||
object->bind_phy_and_radio_driver(radio, phy);
|
||||
|
||||
struct equeue_event ptr;
|
||||
equeue_stub.void_ptr = &ptr;
|
||||
equeue_stub.call_cb_immediately = true;
|
||||
loramac_mcps_confirm_t conf;
|
||||
conf.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::mcps_conf_ptr = &conf;
|
||||
radio._ev->tx_done();
|
||||
|
||||
loramac_mcps_indication_t ind;
|
||||
ind.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::mcps_ind_ptr = &ind;
|
||||
|
||||
loramac_mlme_confirm_t mlme;
|
||||
|
@ -429,7 +435,7 @@ TEST_F(Test_LoRaWANStack, handle_rx)
|
|||
conf.req_type = MCPS_PROPRIETARY;
|
||||
|
||||
ind.pending = true;
|
||||
LoRaMac_stub::dev_class_value = CLASS_C;
|
||||
LoRaMac_stub::dev_class_value = CLASS_A;
|
||||
|
||||
loramac_mlme_indication_t mlme_ind;
|
||||
mlme_ind.pending = false;
|
||||
|
@ -546,11 +552,6 @@ TEST_F(Test_LoRaWANStack, set_device_class)
|
|||
EXPECT_TRUE(LORAWAN_STATUS_UNSUPPORTED == object->set_device_class(CLASS_B));
|
||||
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_device_class(CLASS_A));
|
||||
|
||||
//Visit callback
|
||||
if (LoRaMac_stub::_ack_expiry_handler_for_class_c) {
|
||||
LoRaMac_stub::_ack_expiry_handler_for_class_c.call();
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaWANStack, acquire_tx_metadata)
|
||||
|
@ -574,9 +575,13 @@ TEST_F(Test_LoRaWANStack, acquire_tx_metadata)
|
|||
equeue_stub.void_ptr = &ptr;
|
||||
equeue_stub.call_cb_immediately = true;
|
||||
loramac_mcps_confirm_t conf;
|
||||
conf.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::mcps_conf_ptr = &conf;
|
||||
radio._ev->tx_done();
|
||||
|
||||
LoRaMac_stub::slot_value = RX_SLOT_WIN_2;
|
||||
radio._ev->rx_timeout();
|
||||
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->acquire_tx_metadata(data));
|
||||
}
|
||||
|
||||
|
@ -601,13 +606,16 @@ TEST_F(Test_LoRaWANStack, acquire_rx_metadata)
|
|||
equeue_stub.void_ptr = &ptr;
|
||||
equeue_stub.call_cb_immediately = true;
|
||||
loramac_mcps_confirm_t conf;
|
||||
conf.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::mcps_conf_ptr = &conf;
|
||||
radio._ev->tx_done();
|
||||
|
||||
loramac_mcps_indication_t ind;
|
||||
ind.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::mcps_ind_ptr = &ind;
|
||||
|
||||
loramac_mlme_confirm_t mlme;
|
||||
mlme.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::mlme_conf_ptr = &mlme;
|
||||
mlme.pending = true;
|
||||
mlme.req_type = MLME_JOIN;
|
||||
|
@ -631,6 +639,7 @@ TEST_F(Test_LoRaWANStack, acquire_rx_metadata)
|
|||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_lora_callbacks(&cb));
|
||||
mlme.req_type = MLME_LINK_CHECK;
|
||||
mlme.status = LORAMAC_EVENT_INFO_STATUS_OK;
|
||||
LoRaMac_stub::bool_true_counter = true;
|
||||
radio._ev->rx_done(NULL, 0, 0, 0);
|
||||
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->acquire_rx_metadata(data));
|
||||
|
@ -851,7 +860,7 @@ TEST_F(Test_LoRaWANStack, process_reception)
|
|||
|
||||
conf.req_type = MCPS_UNCONFIRMED;
|
||||
LoRaMac_stub::dev_class_value = CLASS_A;
|
||||
LoRaMac_stub::bool_value = true;
|
||||
LoRaMac_stub::bool_true_counter++;
|
||||
mlme_ind.pending = true;
|
||||
mlme_ind.indication_type = MLME_SCHEDULE_UPLINK;
|
||||
conf.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
|
|
|
@ -26,6 +26,7 @@ int LoRaMac_stub::bool_false_counter = 0;
|
|||
int LoRaMac_stub::bool_true_counter = 0;
|
||||
bool LoRaMac_stub::bool_value = false;
|
||||
int LoRaMac_stub::int_value = 0;
|
||||
uint8_t LoRaMac_stub::uint8_value = 1;
|
||||
rx_slot_t LoRaMac_stub::slot_value = RX_SLOT_WIN_1;
|
||||
lorawan_status_t LoRaMac_stub::status_value = LORAWAN_STATUS_OK;
|
||||
loramac_mcps_confirm_t *LoRaMac_stub::mcps_conf_ptr = NULL;
|
||||
|
@ -33,10 +34,8 @@ loramac_mcps_indication_t *LoRaMac_stub::mcps_ind_ptr = NULL;
|
|||
loramac_mlme_confirm_t *LoRaMac_stub::mlme_conf_ptr = NULL;
|
||||
loramac_mlme_indication_t *LoRaMac_stub::mlme_ind_ptr = NULL;
|
||||
device_class_t LoRaMac_stub::dev_class_value = CLASS_A;
|
||||
mbed::Callback<void(void)> LoRaMac_stub::_ack_expiry_handler_for_class_c = NULL;
|
||||
mbed::Callback<void(void)> LoRaMac_stub::_scheduling_failure_handler = NULL;
|
||||
|
||||
|
||||
LoRaMac::LoRaMac()
|
||||
: _lora_time(),
|
||||
_lora_phy(NULL),
|
||||
|
@ -334,9 +333,8 @@ device_class_t LoRaMac::get_device_class() const
|
|||
}
|
||||
|
||||
void LoRaMac::set_device_class(const device_class_t &device_class,
|
||||
mbed::Callback<void(void)>ack_expiry_handler)
|
||||
mbed::Callback<void(void)>rx2_would_be_closure_handler)
|
||||
{
|
||||
LoRaMac_stub::_ack_expiry_handler_for_class_c = ack_expiry_handler;
|
||||
}
|
||||
|
||||
void LoRaMac::setup_link_check_request()
|
||||
|
@ -456,3 +454,13 @@ lorawan_status_t LoRaMac::multicast_channel_unlink(multicast_params_t *channel_p
|
|||
void LoRaMac::bind_phy(LoRaPHY &phy)
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t LoRaMac::get_QOS_level(void)
|
||||
{
|
||||
return LoRaMac_stub::uint8_value;
|
||||
}
|
||||
|
||||
uint8_t LoRaMac::get_prev_QOS_level(void)
|
||||
{
|
||||
return LoRaMac_stub::uint8_value;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ extern bool bool_value;
|
|||
extern int bool_false_counter;
|
||||
extern int bool_true_counter;
|
||||
extern int int_value;
|
||||
extern uint8_t uint8_value;
|
||||
extern rx_slot_t slot_value;
|
||||
extern lorawan_status_t status_value;
|
||||
extern loramac_mcps_confirm_t *mcps_conf_ptr;
|
||||
|
@ -35,6 +36,5 @@ extern loramac_mcps_indication_t *mcps_ind_ptr;
|
|||
extern loramac_mlme_confirm_t *mlme_conf_ptr;
|
||||
extern loramac_mlme_indication_t *mlme_ind_ptr;
|
||||
extern device_class_t dev_class_value;
|
||||
extern mbed::Callback<void(void)> _ack_expiry_handler_for_class_c;
|
||||
extern mbed::Callback<void(void)> _scheduling_failure_handler;
|
||||
}
|
||||
|
|
|
@ -186,8 +186,14 @@ void LoRaWANStack::process_transmission(void)
|
|||
{
|
||||
}
|
||||
|
||||
void LoRaWANStack::handle_ack_expiry_for_class_c(void)
|
||||
void post_process_tx_with_reception(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void post_process_tx_no_reception(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LoRaWANStack::handle_scheduling_failure(void)
|
||||
|
@ -295,4 +301,3 @@ void LoRaWANStack::process_idle_state(lorawan_status_t &op_status)
|
|||
void LoRaWANStack::process_uninitialized_state(lorawan_status_t &op_status)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue