mirror of https://github.com/ARMmbed/mbed-os.git
LoRaMac unittested
parent
8bed43e4f8
commit
18a1e66ebc
|
@ -17,9 +17,22 @@
|
|||
|
||||
#include "gtest/gtest.h"
|
||||
#include "LoRaMac.h"
|
||||
#include "LoRaPHY_stub.h"
|
||||
#include "LoRaMacCrypto_stub.h"
|
||||
#include "LoRaMacCommand_stub.h"
|
||||
#include "LoRaWANTimer_stub.h"
|
||||
#include "EventQueue_stub.h"
|
||||
|
||||
using namespace events;
|
||||
|
||||
class my_phy : public LoRaPHY
|
||||
{
|
||||
public:
|
||||
my_phy(){};
|
||||
|
||||
virtual ~my_phy(){};
|
||||
};
|
||||
|
||||
class Test_LoRaMac : public testing::Test {
|
||||
protected:
|
||||
LoRaMac *object;
|
||||
|
@ -47,7 +60,501 @@ void my_cb()
|
|||
|
||||
TEST_F(Test_LoRaMac, initialize)
|
||||
{
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
|
||||
lorawan_connect_t conn;
|
||||
uint8_t key[16];
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = key;
|
||||
conn.connection_u.otaa.nb_trials = 2;
|
||||
object->prepare_join(&conn, true);
|
||||
|
||||
LoRaWANTimer_stub::call_cb_immediately = true;
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->initialize(NULL, my_cb));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, disconnect)
|
||||
{
|
||||
object->disconnect();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, nwk_joined)
|
||||
{
|
||||
EXPECT_EQ(false, object->nwk_joined());
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, add_channel_plan)
|
||||
{
|
||||
lorawan_channelplan_t plan;
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->add_channel_plan(plan));
|
||||
|
||||
object->set_tx_ongoing(true);
|
||||
EXPECT_EQ(LORAWAN_STATUS_BUSY, object->add_channel_plan(plan));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, remove_channel_plan)
|
||||
{
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->remove_channel_plan());
|
||||
|
||||
object->set_tx_ongoing(true);
|
||||
EXPECT_EQ(LORAWAN_STATUS_BUSY, object->remove_channel_plan());
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_channel_plan)
|
||||
{
|
||||
lorawan_channelplan_t plan;
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->get_channel_plan(plan));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, remove_single_channel)
|
||||
{
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->remove_single_channel(1));
|
||||
|
||||
object->set_tx_ongoing(true);
|
||||
EXPECT_EQ(LORAWAN_STATUS_BUSY, object->remove_single_channel(1));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, multicast_channel_link)
|
||||
{
|
||||
multicast_params_t p;
|
||||
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->multicast_channel_link(NULL));
|
||||
|
||||
object->set_tx_ongoing(true);
|
||||
EXPECT_EQ(LORAWAN_STATUS_BUSY, object->multicast_channel_link(&p));
|
||||
|
||||
object->set_tx_ongoing(false);
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->multicast_channel_link(&p));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, multicast_channel_unlink)
|
||||
{
|
||||
multicast_params_t p;
|
||||
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->multicast_channel_unlink(NULL));
|
||||
|
||||
object->set_tx_ongoing(true);
|
||||
EXPECT_EQ(LORAWAN_STATUS_BUSY, object->multicast_channel_unlink(&p));
|
||||
|
||||
object->set_tx_ongoing(false);
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->multicast_channel_unlink(&p));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, send)
|
||||
{
|
||||
loramac_mhdr_t mac_hdr;
|
||||
uint8_t buf[15];
|
||||
mac_hdr.bits.mtype = FRAME_TYPE_DATA_CONFIRMED_UP;
|
||||
object->send(&mac_hdr, 1, buf, 15);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_default_tx_datarate)
|
||||
{
|
||||
object->get_default_tx_datarate();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, enable_adaptive_datarate)
|
||||
{
|
||||
object->enable_adaptive_datarate(true);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, set_channel_data_rate)
|
||||
{
|
||||
object->set_channel_data_rate(8);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, tx_ongoing)
|
||||
{
|
||||
object->tx_ongoing();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, set_tx_ongoing)
|
||||
{
|
||||
object->set_tx_ongoing(true);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, reset_ongoing_tx)
|
||||
{
|
||||
object->reset_ongoing_tx(true);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, prepare_ongoing_tx)
|
||||
{
|
||||
uint8_t buf[16];
|
||||
object->prepare_ongoing_tx(1, buf, 16, 1, 0);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, send_ongoing_tx)
|
||||
{
|
||||
object->send_ongoing_tx();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_device_class)
|
||||
{
|
||||
object->get_device_class();
|
||||
}
|
||||
|
||||
void exp_cb()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, set_device_class)
|
||||
{
|
||||
object->set_device_class(CLASS_B, exp_cb);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, setup_link_check_request)
|
||||
{
|
||||
object->setup_link_check_request();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, prepare_join)
|
||||
{
|
||||
lorawan_connect_t conn;
|
||||
object->prepare_join(&conn, false);
|
||||
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->join(false));
|
||||
|
||||
uint8_t key[16];
|
||||
conn.connection_u.otaa.app_key = NULL;
|
||||
conn.connection_u.otaa.app_eui = NULL;
|
||||
conn.connection_u.otaa.dev_eui = NULL;
|
||||
conn.connection_u.otaa.nb_trials = 0;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, true));
|
||||
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = NULL;
|
||||
conn.connection_u.otaa.dev_eui = NULL;
|
||||
conn.connection_u.otaa.nb_trials = 0;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, true));
|
||||
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = NULL;
|
||||
conn.connection_u.otaa.nb_trials = 0;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, true));
|
||||
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = key;
|
||||
conn.connection_u.otaa.nb_trials = 0;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, true));
|
||||
|
||||
LoRaPHY_stub::bool_table[0] = false;
|
||||
LoRaPHY_stub::bool_counter = 0;
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = key;
|
||||
conn.connection_u.otaa.nb_trials = 2;
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->prepare_join(&conn, true));
|
||||
|
||||
conn.connection_u.abp.dev_addr = 0;
|
||||
conn.connection_u.abp.nwk_id = 0;
|
||||
conn.connection_u.abp.nwk_skey = NULL;
|
||||
conn.connection_u.abp.app_skey = NULL;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, false));
|
||||
|
||||
conn.connection_u.abp.dev_addr = 1;
|
||||
conn.connection_u.abp.nwk_id = 0;
|
||||
conn.connection_u.abp.nwk_skey = NULL;
|
||||
conn.connection_u.abp.app_skey = NULL;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, false));
|
||||
|
||||
conn.connection_u.abp.dev_addr = 1;
|
||||
conn.connection_u.abp.nwk_id = 2;
|
||||
conn.connection_u.abp.nwk_skey = NULL;
|
||||
conn.connection_u.abp.app_skey = NULL;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, false));
|
||||
|
||||
conn.connection_u.abp.dev_addr = 1;
|
||||
conn.connection_u.abp.nwk_id = 2;
|
||||
conn.connection_u.abp.nwk_skey = key;
|
||||
conn.connection_u.abp.app_skey = NULL;
|
||||
EXPECT_EQ(LORAWAN_STATUS_PARAMETER_INVALID, object->prepare_join(&conn, false));
|
||||
|
||||
conn.connection_u.abp.dev_addr = 1;
|
||||
conn.connection_u.abp.nwk_id = 2;
|
||||
conn.connection_u.abp.nwk_skey = key;
|
||||
conn.connection_u.abp.app_skey = key;
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->prepare_join(&conn, false));
|
||||
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->prepare_join(NULL, false));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, join)
|
||||
{
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->join(false));
|
||||
|
||||
lorawan_connect_t conn;
|
||||
uint8_t key[16];
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = key;
|
||||
conn.connection_u.otaa.nb_trials = 2;
|
||||
object->prepare_join(&conn, true);
|
||||
EXPECT_EQ(LORAWAN_STATUS_CONNECT_IN_PROGRESS, object->join(true));
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, on_radio_tx_done)
|
||||
{
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
object->on_radio_tx_done(100);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, on_radio_rx_done)
|
||||
{
|
||||
uint8_t buf[16];
|
||||
object->on_radio_rx_done(buf, 16, 0, 0);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, on_radio_tx_timeout)
|
||||
{
|
||||
object->on_radio_tx_timeout();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, on_radio_rx_timeout)
|
||||
{
|
||||
object->on_radio_rx_timeout(true);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, continue_joining_process)
|
||||
{
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
lorawan_connect_t conn;
|
||||
uint8_t key[16];
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = key;
|
||||
conn.connection_u.otaa.nb_trials = 2;
|
||||
object->prepare_join(&conn, true);
|
||||
object->continue_joining_process();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, continue_sending_process)
|
||||
{
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
object->continue_sending_process();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_mcps_confirmation)
|
||||
{
|
||||
object->get_mcps_confirmation();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_mcps_indication)
|
||||
{
|
||||
object->get_mcps_indication();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_mlme_confirmation)
|
||||
{
|
||||
object->get_mlme_confirmation();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_mlme_indication)
|
||||
{
|
||||
object->get_mlme_indication();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, post_process_mcps_req)
|
||||
{
|
||||
uint8_t data[16];
|
||||
LoRaPHY_stub::bool_counter = 0;
|
||||
LoRaPHY_stub::bool_table[0] = true;
|
||||
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
object->join(false);
|
||||
|
||||
object->prepare_ongoing_tx(1, data, 15, 0x01, 2);
|
||||
object->send_ongoing_tx();
|
||||
object->post_process_mcps_req();
|
||||
|
||||
LoRaPHY_stub::bool_counter = 0;
|
||||
object->prepare_ongoing_tx(1, data, 15, 0x02, 2);
|
||||
object->send_ongoing_tx();
|
||||
object->post_process_mcps_req();
|
||||
|
||||
//_mcps_confirmation.ack_received missing here
|
||||
uint8_t payload[16] = {};
|
||||
LoRaPHY_stub::uint16_value = 5;
|
||||
payload[0] = FRAME_TYPE_DATA_CONFIRMED_DOWN << 5;
|
||||
payload[5] = 1 << 5;
|
||||
|
||||
//address != _params.dev_addr
|
||||
payload[2] = 2;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
object->post_process_mcps_req();
|
||||
|
||||
payload[2] = 0;
|
||||
//mic failure
|
||||
payload[13] = 2;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
object->post_process_mcps_req();
|
||||
|
||||
payload[13] = 0;
|
||||
//crypto failure
|
||||
LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
LoRaMacCrypto_stub::int_table[0] = 4;
|
||||
LoRaMacCrypto_stub::int_table[1] = 4;
|
||||
// LoRaPHY_stub::uint16_value = 0;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
object->post_process_mcps_req();
|
||||
|
||||
//process_mac_commands failure
|
||||
LoRaMacCommand_stub::status_value = LORAWAN_STATUS_BUSY;
|
||||
LoRaMacCrypto_stub::int_table[0] = 0;
|
||||
LoRaMacCrypto_stub::int_table[1] = 0;
|
||||
payload[7] = 1;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
object->post_process_mcps_req();
|
||||
|
||||
//FOpts_len != 0
|
||||
payload[5] = (1 << 5) + 1;
|
||||
payload[7] = 0;
|
||||
LoRaMacCommand_stub::status_value = LORAWAN_STATUS_OK;
|
||||
payload[0] = FRAME_TYPE_DATA_UNCONFIRMED_DOWN << 5;
|
||||
|
||||
object->on_radio_rx_done(payload, 13, 0, 0);
|
||||
|
||||
//_mac_commands.process_mac_commands fails
|
||||
LoRaMacCommand_stub::status_value = LORAWAN_STATUS_DATARATE_INVALID;
|
||||
object->on_radio_rx_done(payload, 13, 0, 0);
|
||||
|
||||
object->post_process_mcps_req();
|
||||
|
||||
payload[9] = 1;
|
||||
LoRaMacCommand_stub::status_value = LORAWAN_STATUS_OK;
|
||||
payload[0] = FRAME_TYPE_PROPRIETARY << 5;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
object->post_process_mcps_req();
|
||||
|
||||
payload[9] = 0;
|
||||
payload[5] = 1 << 5;
|
||||
LoRaMacCommand_stub::status_value = LORAWAN_STATUS_OK;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
object->post_process_mcps_req();
|
||||
|
||||
LoRaPHY_stub::bool_counter = 0;
|
||||
object->prepare_ongoing_tx(1, data, 15, 0x04, 2);
|
||||
object->send_ongoing_tx();
|
||||
object->post_process_mcps_req();
|
||||
|
||||
LoRaPHY_stub::bool_counter = 0;
|
||||
object->prepare_ongoing_tx(1, data, 15, 0x08, 2);
|
||||
object->send_ongoing_tx();
|
||||
object->post_process_mcps_req();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, handle_join_accept_frame)
|
||||
{
|
||||
LoRaPHY_stub::bool_counter = 0;
|
||||
LoRaPHY_stub::bool_table[0] = true;
|
||||
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
|
||||
uint8_t payload[16] = {};
|
||||
LoRaPHY_stub::uint16_value = 5;
|
||||
payload[0] = FRAME_TYPE_JOIN_ACCEPT << 5;
|
||||
payload[5] = 1 << 5;
|
||||
|
||||
LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
LoRaMacCrypto_stub::int_table[0] = 4;
|
||||
LoRaMacCrypto_stub::int_table[1] = 4;
|
||||
LoRaMacCrypto_stub::int_table[2] = 4;
|
||||
LoRaMacCrypto_stub::int_table[3] = 4;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
|
||||
LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
LoRaMacCrypto_stub::int_table[0] = 0;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
|
||||
LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
LoRaMacCrypto_stub::int_table[1] = 0;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
|
||||
//mic failure case
|
||||
payload[13] = 17;
|
||||
LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
|
||||
payload[13] = 0;
|
||||
LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
LoRaMacCrypto_stub::int_table[2] = 0;
|
||||
object->on_radio_rx_done(payload, 16, 0, 0);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, post_process_mcps_ind)
|
||||
{
|
||||
object->post_process_mcps_ind();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, post_process_mlme_request)
|
||||
{
|
||||
object->post_process_mlme_request();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, post_process_mlme_ind)
|
||||
{
|
||||
object->post_process_mlme_ind();
|
||||
}
|
||||
|
||||
uint8_t batt_cb()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, set_batterylevel_callback)
|
||||
{
|
||||
object->set_batterylevel_callback(batt_cb);
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_backoff_timer_event_id)
|
||||
{
|
||||
object->get_backoff_timer_event_id();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, clear_tx_pipe)
|
||||
{
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->clear_tx_pipe()); //timer id == 0
|
||||
|
||||
my_phy phy;
|
||||
object->bind_phy(phy);
|
||||
|
||||
lorawan_connect_t conn;
|
||||
uint8_t key[16];
|
||||
conn.connection_u.otaa.app_key = key;
|
||||
conn.connection_u.otaa.app_eui = key;
|
||||
conn.connection_u.otaa.dev_eui = key;
|
||||
conn.connection_u.otaa.nb_trials = 2;
|
||||
object->prepare_join(&conn, true);
|
||||
|
||||
EXPECT_TRUE(LORAWAN_STATUS_OK == object->initialize(NULL, my_cb));
|
||||
EventQueue_stub::int_value = 0;
|
||||
EXPECT_EQ(LORAWAN_STATUS_BUSY, object->clear_tx_pipe());
|
||||
|
||||
EventQueue_stub::int_value = 1;
|
||||
EXPECT_EQ(LORAWAN_STATUS_OK, object->clear_tx_pipe());
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_current_time)
|
||||
{
|
||||
object->get_current_time();
|
||||
}
|
||||
|
||||
TEST_F(Test_LoRaMac, get_current_slot)
|
||||
{
|
||||
object->get_current_slot();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ set(unittest-includes ${unittest-includes}
|
|||
set(unittest-test-sources
|
||||
../features/lorawan/loraphy/Test_LoRaPHY.cpp
|
||||
stubs/LoRaWANTimer_stub.cpp
|
||||
|
||||
stubs/mbed_assert_stub.c
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ set(unittest-test-sources
|
|||
../features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/LoRaWANTimer_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ set(unittest-test-sources
|
|||
../features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/LoRaWANTimer_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ set(unittest-test-sources
|
|||
../features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/LoRaWANTimer_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ set(unittest-includes ${unittest-includes}
|
|||
set(unittest-test-sources
|
||||
../features/lorawan/loraphycn779/Test_LoRaPHYCN779.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ set(unittest-includes ${unittest-includes}
|
|||
set(unittest-test-sources
|
||||
../features/lorawan/loraphyeu433/Test_LoRaPHYEU433.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ set(unittest-includes ${unittest-includes}
|
|||
set(unittest-test-sources
|
||||
../features/lorawan/loraphyeu868/Test_LoRaPHYEU868.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ set(unittest-includes ${unittest-includes}
|
|||
set(unittest-test-sources
|
||||
../features/lorawan/loraphyin865/Test_LoRaPHYIN865.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ set(unittest-test-sources
|
|||
../features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/LoRaWANTimer_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ set(unittest-test-sources
|
|||
../features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp
|
||||
stubs/LoRaPHY_stub.cpp
|
||||
stubs/LoRaWANTimer_stub.cpp
|
||||
stubs/mbed_assert_stub.c
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -17,9 +17,13 @@
|
|||
|
||||
#include "EventQueue.h"
|
||||
#include "Callback.h"
|
||||
#include "EventQueue_stub.h"
|
||||
|
||||
using namespace mbed;
|
||||
|
||||
int EventQueue_stub::int_value = 0;
|
||||
unsigned EventQueue_stub::unsigned_value = 0;
|
||||
|
||||
namespace events {
|
||||
|
||||
EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer)
|
||||
|
@ -40,7 +44,7 @@ void EventQueue::break_dispatch()
|
|||
|
||||
unsigned EventQueue::tick()
|
||||
{
|
||||
return 0;
|
||||
return EventQueue_stub::unsigned_value;
|
||||
}
|
||||
|
||||
void EventQueue::cancel(int id)
|
||||
|
@ -49,7 +53,7 @@ void EventQueue::cancel(int id)
|
|||
|
||||
int EventQueue::time_left(int id)
|
||||
{
|
||||
return 0;
|
||||
return EventQueue_stub::int_value;
|
||||
}
|
||||
|
||||
void EventQueue::background(Callback<void(int)> update)
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) , Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace EventQueue_stub
|
||||
{
|
||||
extern int int_value;
|
||||
extern unsigned unsigned_value;
|
||||
}
|
||||
|
|
@ -18,6 +18,12 @@
|
|||
#include "LoRaMacCommand.h"
|
||||
#include "LoRaMac.h"
|
||||
|
||||
#include "LoRaMacCommand_stub.h"
|
||||
|
||||
lorawan_status_t LoRaMacCommand_stub::status_value = LORAWAN_STATUS_OK;
|
||||
bool LoRaMacCommand_stub::bool_value = false;
|
||||
uint8_t LoRaMacCommand_stub::uint8_value = 0;
|
||||
int32_t LoRaMacCommand_stub::int32_value = 0;
|
||||
|
||||
LoRaMacCommand::LoRaMacCommand()
|
||||
{
|
||||
|
@ -29,12 +35,12 @@ void LoRaMacCommand::clear_command_buffer()
|
|||
|
||||
uint8_t LoRaMacCommand::get_mac_cmd_length() const
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCommand_stub::uint8_value;
|
||||
}
|
||||
|
||||
uint8_t *LoRaMacCommand::get_mac_commands_buffer()
|
||||
{
|
||||
return NULL;
|
||||
return &LoRaMacCommand_stub::uint8_value;
|
||||
}
|
||||
|
||||
void LoRaMacCommand::parse_mac_commands_to_repeat()
|
||||
|
@ -52,7 +58,7 @@ void LoRaMacCommand::copy_repeat_commands_to_buffer()
|
|||
|
||||
uint8_t LoRaMacCommand::get_repeat_commands_length() const
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCommand_stub::uint8_value;
|
||||
}
|
||||
|
||||
void LoRaMacCommand::clear_sticky_mac_cmd()
|
||||
|
@ -61,7 +67,7 @@ void LoRaMacCommand::clear_sticky_mac_cmd()
|
|||
|
||||
bool LoRaMacCommand::has_sticky_mac_cmd() const
|
||||
{
|
||||
return false;
|
||||
return LoRaMacCommand_stub::bool_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, uint8_t mac_index,
|
||||
|
@ -70,12 +76,12 @@ lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, ui
|
|||
lora_mac_system_params_t &mac_sys_params,
|
||||
LoRaPHY &lora_phy)
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
int32_t LoRaMacCommand::cmd_buffer_remaining() const
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCommand_stub::int32_value;
|
||||
}
|
||||
|
||||
void LoRaMacCommand::set_batterylevel_callback(mbed::Callback<uint8_t(void)> battery_level)
|
||||
|
@ -84,45 +90,45 @@ void LoRaMacCommand::set_batterylevel_callback(mbed::Callback<uint8_t(void)> bat
|
|||
|
||||
lorawan_status_t LoRaMacCommand::add_link_check_req()
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_link_adr_ans(uint8_t status)
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_duty_cycle_ans()
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_rx_param_setup_ans(uint8_t status)
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_dev_status_ans(uint8_t battery, uint8_t margin)
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_new_channel_ans(uint8_t status)
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_rx_timing_setup_ans()
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_tx_param_setup_ans()
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMacCommand::add_dl_channel_ans(uint8_t status)
|
||||
{
|
||||
return LORAWAN_STATUS_OK;
|
||||
return LoRaMacCommand_stub::status_value;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) , Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "lorawan_types.h"
|
||||
|
||||
namespace LoRaMacCommand_stub
|
||||
{
|
||||
extern lorawan_status_t status_value;
|
||||
extern bool bool_value;
|
||||
extern uint8_t uint8_value;
|
||||
extern int32_t int32_value;
|
||||
}
|
|
@ -21,6 +21,10 @@
|
|||
#include "LoRaMacCrypto.h"
|
||||
#include "system/lorawan_data_structures.h"
|
||||
|
||||
#include "LoRaMacCrypto_stub.h"
|
||||
|
||||
int LoRaMacCrypto_stub::int_table_idx_value = 0;
|
||||
int LoRaMacCrypto_stub::int_table[20] = {};
|
||||
|
||||
LoRaMacCrypto::LoRaMacCrypto()
|
||||
{
|
||||
|
@ -29,34 +33,34 @@ LoRaMacCrypto::LoRaMacCrypto()
|
|||
int LoRaMacCrypto::compute_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t,
|
||||
uint8_t dir, uint32_t, uint32_t *)
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++];
|
||||
}
|
||||
|
||||
int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t,
|
||||
uint8_t , uint32_t , uint8_t *)
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++];
|
||||
}
|
||||
|
||||
int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t,
|
||||
uint8_t , uint32_t , uint8_t *)
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++];
|
||||
}
|
||||
|
||||
int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t *)
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++];
|
||||
}
|
||||
|
||||
int LoRaMacCrypto::decrypt_join_frame(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint8_t *)
|
||||
int LoRaMacCrypto::decrypt_join_frame(const uint8_t *in, uint16_t size, const uint8_t *, uint32_t, uint8_t *out)
|
||||
{
|
||||
return 0;
|
||||
memcpy(out, in, size);
|
||||
return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++];
|
||||
}
|
||||
|
||||
int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *, uint32_t, const uint8_t *, uint16_t ,
|
||||
uint8_t *, uint8_t *)
|
||||
{
|
||||
return 0;
|
||||
return LoRaMacCrypto_stub::int_table[LoRaMacCrypto_stub::int_table_idx_value++];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) , Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace LoRaMacCrypto_stub
|
||||
{
|
||||
extern int int_table_idx_value;
|
||||
extern int int_table[20];
|
||||
}
|
|
@ -15,11 +15,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "mbed_assert.h"
|
||||
#include "LoRaWANTimer.h"
|
||||
|
||||
#include "LoRaWANTimer_stub.h"
|
||||
|
||||
lorawan_time_t LoRaWANTimer_stub::time_value = 0;
|
||||
bool LoRaWANTimer_stub::call_cb_immediately = false;
|
||||
|
||||
LoRaWANTimeHandler::LoRaWANTimeHandler()
|
||||
: _queue(NULL)
|
||||
|
@ -46,6 +48,10 @@ lorawan_time_t LoRaWANTimeHandler::get_elapsed_time(lorawan_time_t saved_time)
|
|||
|
||||
void LoRaWANTimeHandler::init(timer_event_t &obj, mbed::Callback<void()> callback)
|
||||
{
|
||||
if (callback && LoRaWANTimer_stub::call_cb_immediately) {
|
||||
callback();
|
||||
}
|
||||
obj.timer_id = 1;
|
||||
}
|
||||
|
||||
void LoRaWANTimeHandler::start(timer_event_t &obj, const uint32_t timeout)
|
||||
|
@ -54,4 +60,5 @@ void LoRaWANTimeHandler::start(timer_event_t &obj, const uint32_t timeout)
|
|||
|
||||
void LoRaWANTimeHandler::stop(timer_event_t &obj)
|
||||
{
|
||||
obj.timer_id = 0;
|
||||
}
|
||||
|
|
|
@ -20,4 +20,5 @@
|
|||
namespace LoRaWANTimer_stub
|
||||
{
|
||||
extern lorawan_time_t time_value;
|
||||
extern bool call_cb_immediately;
|
||||
}
|
||||
|
|
|
@ -1721,21 +1721,6 @@ void LoRaMac::reset_mcps_indication()
|
|||
_mcps_indication.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
||||
}
|
||||
|
||||
void LoRaMac::set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx_power,
|
||||
float max_eirp, float antenna_gain, uint16_t timeout)
|
||||
{
|
||||
cw_mode_params_t continuous_wave;
|
||||
|
||||
continuous_wave.channel = channel;
|
||||
continuous_wave.datarate = datarate;
|
||||
continuous_wave.tx_power = tx_power;
|
||||
continuous_wave.max_eirp = max_eirp;
|
||||
continuous_wave.antenna_gain = antenna_gain;
|
||||
continuous_wave.timeout = timeout;
|
||||
|
||||
_lora_phy->set_tx_cont_mode(&continuous_wave);
|
||||
}
|
||||
|
||||
lorawan_status_t LoRaMac::initialize(EventQueue *queue,
|
||||
mbed::Callback<void(void)>scheduling_failure_handler)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue