From 0f8cfd86318e63bed99fd9d3ff191d3dcbd37968 Mon Sep 17 00:00:00 2001 From: Antti Kauppila Date: Fri, 14 Sep 2018 13:10:19 +0300 Subject: [PATCH] LoRa regions unittested, stubs licences revisited --- .../loraphyas923/Test_LoRaPHYAS923.cpp | 103 +++++++++ .../loraphyau915/Test_LoRaPHYAU915.cpp | 192 +++++++++++++++++ .../loraphycn470/Test_LoRaPHYCN470.cpp | 159 ++++++++++++++ .../loraphyin865/Test_LoRaPHYIN865.cpp | 7 + .../loraphykr920/Test_LoRaPHYKR920.cpp | 116 +++++++++++ .../loraphyus915/Test_LoRaPHYUS915.cpp | 196 ++++++++++++++++++ UNITTESTS/stubs/ATCmdParser_stub.cpp | 2 +- UNITTESTS/stubs/ATHandler_stub.cpp | 2 +- UNITTESTS/stubs/ATHandler_stub.h | 2 +- UNITTESTS/stubs/AT_CellularBase_stub.cpp | 2 +- UNITTESTS/stubs/AT_CellularBase_stub.h | 2 +- UNITTESTS/stubs/AT_CellularDevice_stub.cpp | 2 +- .../stubs/AT_CellularInformation_stub.cpp | 2 +- .../stubs/AT_CellularMultiplexer_stub.cpp | 2 +- UNITTESTS/stubs/AT_CellularNetwork_stub.cpp | 2 +- UNITTESTS/stubs/AT_CellularPower_stub.cpp | 2 +- UNITTESTS/stubs/AT_CellularSIM_stub.cpp | 2 +- UNITTESTS/stubs/AT_CellularSMS_stub.cpp | 2 +- UNITTESTS/stubs/AT_CellularStack_stub.cpp | 2 +- UNITTESTS/stubs/BufferedBlockDevice_stub.cpp | 5 +- UNITTESTS/stubs/CellularUtil_stub.cpp | 1 + UNITTESTS/stubs/ChainingBlockDevice_stub.cpp | 7 +- UNITTESTS/stubs/EventFlags_stub.cpp | 2 +- UNITTESTS/stubs/EventQueue_stub.cpp | 2 +- .../stubs/ExhaustibleBlockDevice_stub.cpp | 5 +- UNITTESTS/stubs/FileHandle_stub.h | 1 + UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp | 5 +- UNITTESTS/stubs/HeapBlockDevice_stub.cpp | 5 +- UNITTESTS/stubs/Kernel_stub.cpp | 1 + UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp | 40 ++-- UNITTESTS/stubs/LoRaMacCommand_stub.cpp | 39 ++-- UNITTESTS/stubs/LoRaMacCrypto_stub.cpp | 34 ++- UNITTESTS/stubs/LoRaMac_stub.cpp | 38 ++-- UNITTESTS/stubs/LoRaPHYEU868_stub.cpp | 38 ++-- UNITTESTS/stubs/LoRaPHY_stub.cpp | 27 ++- UNITTESTS/stubs/LoRaPHY_stub.h | 5 +- UNITTESTS/stubs/LoRaWANStack_stub.cpp | 40 ++-- UNITTESTS/stubs/LoRaWANTimer_stub.cpp | 35 ++-- UNITTESTS/stubs/MBRBlockDevice_stub.cpp | 5 +- UNITTESTS/stubs/NetworkInterface_stub.cpp | 2 +- UNITTESTS/stubs/NetworkStack_stub.cpp | 2 +- UNITTESTS/stubs/ObservingBlockDevice_stub.cpp | 29 ++- UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp | 5 +- UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp | 29 ++- UNITTESTS/stubs/SlicingBlockDevice_stub.cpp | 7 +- UNITTESTS/stubs/SocketAddress_stub.cpp | 2 +- UNITTESTS/stubs/Timer_stub.h | 1 + UNITTESTS/stubs/aes_stub.c | 16 ++ UNITTESTS/stubs/cipher_stub.c | 32 ++- UNITTESTS/stubs/cmac_stub.c | 16 ++ UNITTESTS/stubs/ip4tos_stub.c | 14 +- UNITTESTS/stubs/mbed_assert_stub.c | 2 +- UNITTESTS/stubs/mbed_critical_stub.c | 12 +- UNITTESTS/stubs/mbed_poll_stub.cpp | 2 +- UNITTESTS/stubs/mbed_poll_stub.h | 3 +- UNITTESTS/stubs/mbed_wait_api_stub.cpp | 2 +- UNITTESTS/stubs/nvic_wrapper_stub.c | 17 ++ UNITTESTS/stubs/randLIB_stub.c | 3 +- UNITTESTS/stubs/randLIB_stub.cpp | 1 + UNITTESTS/stubs/stoip4_stub.c | 14 +- .../lorawan/lorastack/phy/LoRaPHYAU915.cpp | 7 +- .../lorawan/lorastack/phy/LoRaPHYUS915.cpp | 8 +- 62 files changed, 1073 insertions(+), 287 deletions(-) diff --git a/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp b/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp index dc862734d4..98a361810d 100644 --- a/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp +++ b/UNITTESTS/features/lorawan/loraphyas923/Test_LoRaPHYAS923.cpp @@ -18,17 +18,83 @@ #include "gtest/gtest.h" #include "LoRaPHYAS923.h" +#include "LoRaPHY_stub.h" + +class my_radio : public LoRaRadio +{ +public: + + virtual void init_radio(radio_events_t *events){}; + + virtual void radio_reset(){}; + + virtual void sleep(void){}; + + virtual void standby(void){}; + + virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous){}; + + virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + + virtual void send(uint8_t *buffer, uint8_t size){}; + + virtual void receive(void){}; + + virtual void set_channel(uint32_t freq){}; + + virtual uint32_t random(void){}; + + virtual uint8_t get_status(void){return uint8_value;}; + + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + + virtual void set_public_network(bool enable){}; + + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + + virtual bool perform_carrier_sense(radio_modems_t modem, + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time){ return bool_value;}; + + virtual void start_cad(void){}; + + virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + + virtual void lock(void){}; + + virtual void unlock(void){}; + + bool bool_value; + uint8_t uint8_value; +}; + class Test_LoRaPHYAS923 : public testing::Test { protected: LoRaPHYAS923 *object; + my_radio radio; virtual void SetUp() { + LoRaPHY_stub::radio = &radio; object = new LoRaPHYAS923(); } virtual void TearDown() { + LoRaPHY_stub::radio = NULL; delete object; } }; @@ -38,3 +104,40 @@ TEST_F(Test_LoRaPHYAS923, constructor) EXPECT_TRUE(object); } +TEST_F(Test_LoRaPHYAS923, get_alternate_DR) +{ + EXPECT_TRUE(2 == object->get_alternate_DR(1)); +} + +TEST_F(Test_LoRaPHYAS923, set_next_channel) +{ + channel_selection_params_t next_channel; + lorawan_time_t backoff_time = 0; + lorawan_time_t time = 0; + uint8_t ch = 1; + + next_channel.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 0; + EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); + + next_channel.aggregate_timeoff = 1; + radio.bool_value = false; + EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); + + next_channel.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 1; + EXPECT_TRUE(LORAWAN_STATUS_NO_FREE_CHANNEL_FOUND == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); + + radio.bool_value = true; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); +} + +TEST_F(Test_LoRaPHYAS923, apply_DR_offset) +{ + //0, 1, 2, 3, 4, 5, -1, -2 + for (int i=0; i < 8; i++) { + uint8_t val = i>5?5:2; + EXPECT_TRUE(object->apply_DR_offset(0, i)); + } +} + diff --git a/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp b/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp index bf3f28001f..bc5cae491d 100644 --- a/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp +++ b/UNITTESTS/features/lorawan/loraphyau915/Test_LoRaPHYAU915.cpp @@ -18,17 +18,83 @@ #include "gtest/gtest.h" #include "LoRaPHYAU915.h" +#include "LoRaPHY_stub.h" + +class my_radio : public LoRaRadio +{ +public: + + virtual void init_radio(radio_events_t *events){}; + + virtual void radio_reset(){}; + + virtual void sleep(void){}; + + virtual void standby(void){}; + + virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous){}; + + virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + + virtual void send(uint8_t *buffer, uint8_t size){}; + + virtual void receive(void){}; + + virtual void set_channel(uint32_t freq){}; + + virtual uint32_t random(void){}; + + virtual uint8_t get_status(void){return uint8_value;}; + + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + + virtual void set_public_network(bool enable){}; + + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + + virtual bool perform_carrier_sense(radio_modems_t modem, + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time){ return bool_value;}; + + virtual void start_cad(void){}; + + virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + + virtual void lock(void){}; + + virtual void unlock(void){}; + + bool bool_value; + uint8_t uint8_value; +}; + class Test_LoRaPHYAU915 : public testing::Test { protected: LoRaPHYAU915 *object; + my_radio radio; virtual void SetUp() { + LoRaPHY_stub::radio = &radio; object = new LoRaPHYAU915(); } virtual void TearDown() { + LoRaPHY_stub::radio = NULL; delete object; } }; @@ -38,3 +104,129 @@ TEST_F(Test_LoRaPHYAU915, constructor) EXPECT_TRUE(object); } +TEST_F(Test_LoRaPHYAU915, rx_config) +{ + rx_config_params_t p; + + radio.uint8_value = 1; + EXPECT_TRUE(!object->rx_config(&p)); + + radio.uint8_value = 0; + p.is_repeater_supported = true; + EXPECT_TRUE(object->rx_config(&p)); + + p.is_repeater_supported = false; + EXPECT_TRUE(object->rx_config(&p)); +} + +TEST_F(Test_LoRaPHYAU915, tx_config) +{ + tx_config_params_t p; + int8_t tx; + lorawan_time_t time; + p.tx_power = 9; + EXPECT_TRUE(object->tx_config(&p, &tx, &time)); +} + +TEST_F(Test_LoRaPHYAU915, link_ADR_request) +{ + adr_req_params_t params; + int8_t dr_out; + int8_t tx_power_out; + uint8_t nb_rep_out; + uint8_t nb_bytes_parsed; + + LoRaPHY_stub::uint8_value = 1; + LoRaPHY_stub::ch_mask_value = 6; + LoRaPHY_stub::adr_parse_count = 2; + EXPECT_TRUE(1 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 7; + EXPECT_TRUE(1 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 5; + LoRaPHY_stub::uint8_value = 6; + EXPECT_TRUE(6 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 66; + LoRaPHY_stub::uint8_value = 7; + EXPECT_TRUE(7 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); +} + +TEST_F(Test_LoRaPHYAU915, accept_rx_param_setup_req) +{ + rx_param_setup_req_t p; + radio.bool_value = false; + EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 923300000 - 1; + EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 927500000 + 1; + p.datarate = 6; + LoRaPHY_stub::bool_counter = 0; + LoRaPHY_stub::bool_table[0] = true; + EXPECT_TRUE(2 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 923300000 + 600000; + LoRaPHY_stub::bool_counter = 0; + LoRaPHY_stub::bool_table[0] = true; + LoRaPHY_stub::bool_table[1] = true; + EXPECT_TRUE(7 == object->accept_rx_param_setup_req(&p)); +} + +TEST_F(Test_LoRaPHYAU915, get_alternate_DR) +{ + EXPECT_TRUE(0 == object->get_alternate_DR(0)); + + EXPECT_TRUE(6 == object->get_alternate_DR(1)); +} + +TEST_F(Test_LoRaPHYAU915, set_next_channel) +{ + channel_selection_params_t params; + uint8_t channel; + lorawan_time_t time; + lorawan_time_t timeoff; + + params.current_datarate = 6; + params.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 0; + EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(¶ms, &channel, &time, &timeoff)); + + radio.bool_value = false; + params.aggregate_timeoff = 1; + EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(¶ms, &channel, &time, &timeoff)); + + params.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 1; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(¶ms, &channel, &time, &timeoff)); +} + +TEST_F(Test_LoRaPHYAU915, apply_DR_offset) +{ +// { DR_8, DR_8, DR_8, DR_8, DR_8, DR_8 }, // DR_0 +// { DR_9, DR_8, DR_8, DR_8, DR_8, DR_8 }, // DR_1 +// { DR_10, DR_9, DR_8, DR_8, DR_8, DR_8 }, // DR_2 +// { DR_11, DR_10, DR_9, DR_8, DR_8, DR_8 }, // DR_3 +// { DR_12, DR_11, DR_10, DR_9, DR_8, DR_8 }, // DR_4 +// { DR_13, DR_12, DR_11, DR_10, DR_9, DR_8 }, // DR_5 +// { DR_13, DR_13, DR_12, DR_11, DR_10, DR_9 }, // DR_6 + + for (int i = 0; i < 7; i++) { + for (int j=0; j < 6; j++ ) { + uint8_t val = 8 + i; + val -= j; + if (val > 13) val = 13; + if (val < 8) val = 8; + EXPECT_TRUE(val == object->apply_DR_offset(i, j)); + } + } +} + diff --git a/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp b/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp index a09a77b073..983dec935e 100644 --- a/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp +++ b/UNITTESTS/features/lorawan/loraphycn470/Test_LoRaPHYCN470.cpp @@ -18,17 +18,85 @@ #include "gtest/gtest.h" #include "LoRaPHYCN470.h" +#include "LoRaPHY_stub.h" + +class my_radio : public LoRaRadio +{ +public: + + virtual void init_radio(radio_events_t *events){}; + + virtual void radio_reset(){}; + + virtual void sleep(void){}; + + virtual void standby(void){}; + + virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous){}; + + virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + + virtual void send(uint8_t *buffer, uint8_t size){}; + + virtual void receive(void){}; + + virtual void set_channel(uint32_t freq){}; + + virtual uint32_t random(void){}; + + virtual uint8_t get_status(void){return uint8_value;}; + + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + + virtual void set_public_network(bool enable){}; + + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + + virtual bool perform_carrier_sense(radio_modems_t modem, + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time){ return bool_value;}; + + virtual void start_cad(void){}; + + virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + + virtual void lock(void){}; + + virtual void unlock(void){}; + + bool bool_value; + uint8_t uint8_value; +}; + class Test_LoRaPHYCN470 : public testing::Test { protected: LoRaPHYCN470 *object; + my_radio radio; virtual void SetUp() { + + LoRaPHY_stub::radio = &radio; object = new LoRaPHYCN470(); } virtual void TearDown() { + + LoRaPHY_stub::radio = NULL; delete object; } }; @@ -38,3 +106,94 @@ TEST_F(Test_LoRaPHYCN470, constructor) EXPECT_TRUE(object); } +TEST_F(Test_LoRaPHYCN470, set_next_channel) +{ + channel_selection_params_t params; + uint8_t channel; + lorawan_time_t time; + lorawan_time_t timeoff; + + params.current_datarate = 4; + params.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 0; + EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(¶ms, &channel, &time, &timeoff)); + + radio.bool_value = false; + params.aggregate_timeoff = 1; + EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(¶ms, &channel, &time, &timeoff)); + + params.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 1; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(¶ms, &channel, &time, &timeoff)); +} + +TEST_F(Test_LoRaPHYCN470, rx_config) +{ + rx_config_params_t p; + + radio.uint8_value = 1; + EXPECT_TRUE(!object->rx_config(&p)); + + radio.uint8_value = 0; + p.is_repeater_supported = true; + EXPECT_TRUE(object->rx_config(&p)); + + p.is_repeater_supported = false; + EXPECT_TRUE(object->rx_config(&p)); +} + +TEST_F(Test_LoRaPHYCN470, tx_config) +{ + tx_config_params_t p; + int8_t tx; + lorawan_time_t time; + p.tx_power = 9; + EXPECT_TRUE(object->tx_config(&p, &tx, &time)); +} + +TEST_F(Test_LoRaPHYCN470, link_ADR_request) +{ + adr_req_params_t params; + int8_t dr_out; + int8_t tx_power_out; + uint8_t nb_rep_out; + uint8_t nb_bytes_parsed; + + LoRaPHY_stub::uint8_value = 1; + LoRaPHY_stub::ch_mask_value = 6; + LoRaPHY_stub::adr_parse_count = 2; + EXPECT_TRUE(1 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 7; + EXPECT_TRUE(1 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 5; + LoRaPHY_stub::uint8_value = 6; + EXPECT_TRUE(6 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 66; + LoRaPHY_stub::uint8_value = 7; + EXPECT_TRUE(7 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); +} + +TEST_F(Test_LoRaPHYCN470, accept_rx_param_setup_req) +{ + rx_param_setup_req_t p; + EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 923300000 - 1; + EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 927500000 + 1; + p.datarate = 6; + LoRaPHY_stub::bool_counter = 0; + LoRaPHY_stub::bool_table[0] = true; + EXPECT_TRUE(2 == object->accept_rx_param_setup_req(&p)); +} + + diff --git a/UNITTESTS/features/lorawan/loraphyin865/Test_LoRaPHYIN865.cpp b/UNITTESTS/features/lorawan/loraphyin865/Test_LoRaPHYIN865.cpp index 4ba1a29067..ecb12115f4 100644 --- a/UNITTESTS/features/lorawan/loraphyin865/Test_LoRaPHYIN865.cpp +++ b/UNITTESTS/features/lorawan/loraphyin865/Test_LoRaPHYIN865.cpp @@ -38,3 +38,10 @@ TEST_F(Test_LoRaPHYIN865, constructor) EXPECT_TRUE(object); } +TEST_F(Test_LoRaPHYIN865, apply_DR_offset) +{ + EXPECT_TRUE(0 == object->apply_DR_offset(0, 0)); +} + + + diff --git a/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp b/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp index 41e9aed6c9..5efab34c77 100644 --- a/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp +++ b/UNITTESTS/features/lorawan/loraphykr920/Test_LoRaPHYKR920.cpp @@ -17,18 +17,83 @@ #include "gtest/gtest.h" #include "LoRaPHYKR920.h" +#include "LoRaPHY_stub.h" +#include "LoRaRadio.h" + +class my_radio : public LoRaRadio +{ +public: + + virtual void init_radio(radio_events_t *events){}; + + virtual void radio_reset(){}; + + virtual void sleep(void){}; + + virtual void standby(void){}; + + virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous){}; + + virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + + virtual void send(uint8_t *buffer, uint8_t size){}; + + virtual void receive(void){}; + + virtual void set_channel(uint32_t freq){}; + + virtual uint32_t random(void){}; + + virtual uint8_t get_status(void){}; + + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + + virtual void set_public_network(bool enable){}; + + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + + virtual bool perform_carrier_sense(radio_modems_t modem, + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time){ return bool_value;}; + + virtual void start_cad(void){}; + + virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + + virtual void lock(void){}; + + virtual void unlock(void){}; + + bool bool_value; +}; class Test_LoRaPHYKR920 : public testing::Test { protected: LoRaPHYKR920 *object; + my_radio radio; virtual void SetUp() { + LoRaPHY_stub::radio = &radio; object = new LoRaPHYKR920(); } virtual void TearDown() { + LoRaPHY_stub::radio = NULL; delete object; } }; @@ -38,3 +103,54 @@ TEST_F(Test_LoRaPHYKR920, constructor) EXPECT_TRUE(object); } +TEST_F(Test_LoRaPHYKR920, verify_frequency_for_band) +{ + radio.bool_value = false; + EXPECT_TRUE(false == object->verify_frequency_for_band(0, 0)); + + radio.bool_value = true; + EXPECT_TRUE(false == object->verify_frequency_for_band(0, 0)); + + EXPECT_TRUE(true == object->verify_frequency_for_band(921100000, 0)); +} + +TEST_F(Test_LoRaPHYKR920, tx_config) +{ + tx_config_params_t tx_config; + int8_t tx_power = 0; + lorawan_time_t time; + + tx_config.tx_power = 9; + EXPECT_TRUE(true == object->tx_config(&tx_config, &tx_power, &time)); +} + +TEST_F(Test_LoRaPHYKR920, set_next_channel) +{ + channel_selection_params_t next_channel; + lorawan_time_t backoff_time = 0; + lorawan_time_t time = 0; + uint8_t ch = 1; + + next_channel.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 0; + EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); + + next_channel.aggregate_timeoff = 1; + radio.bool_value = false; + EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); + + next_channel.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 1; + EXPECT_TRUE(LORAWAN_STATUS_NO_FREE_CHANNEL_FOUND == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); + + radio.bool_value = true; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(&next_channel, &ch, &backoff_time, &time)); +} + +TEST_F(Test_LoRaPHYKR920, set_tx_cont_mode) +{ + cw_mode_params_t params; + params.tx_power = 9; + object->set_tx_cont_mode(¶ms, 0); +} + diff --git a/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp b/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp index 584cb8bfa5..899b47e058 100644 --- a/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp +++ b/UNITTESTS/features/lorawan/loraphyus915/Test_LoRaPHYUS915.cpp @@ -17,18 +17,83 @@ #include "gtest/gtest.h" #include "LoRaPHYUS915.h" +#include "LoRaPHY_stub.h" + +class my_radio : public LoRaRadio +{ +public: + + virtual void init_radio(radio_events_t *events){}; + + virtual void radio_reset(){}; + + virtual void sleep(void){}; + + virtual void standby(void){}; + + virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, + uint32_t datarate, uint8_t coderate, + uint32_t bandwidth_afc, uint16_t preamble_len, + uint16_t symb_timeout, bool fix_len, + uint8_t payload_len, + bool crc_on, bool freq_hop_on, uint8_t hop_period, + bool iq_inverted, bool rx_continuous){}; + + virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, + uint32_t bandwidth, uint32_t datarate, + uint8_t coderate, uint16_t preamble_len, + bool fix_len, bool crc_on, bool freq_hop_on, + uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; + + virtual void send(uint8_t *buffer, uint8_t size){}; + + virtual void receive(void){}; + + virtual void set_channel(uint32_t freq){}; + + virtual uint32_t random(void){}; + + virtual uint8_t get_status(void){return uint8_value;}; + + virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; + + virtual void set_public_network(bool enable){}; + + virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; + + virtual bool perform_carrier_sense(radio_modems_t modem, + uint32_t freq, + int16_t rssi_threshold, + uint32_t max_carrier_sense_time){ return bool_value;}; + + virtual void start_cad(void){}; + + virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; }; + + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + + virtual void lock(void){}; + + virtual void unlock(void){}; + + bool bool_value; + uint8_t uint8_value; +}; class Test_LoRaPHYUS915 : public testing::Test { protected: LoRaPHYUS915 *object; + my_radio radio; virtual void SetUp() { + LoRaPHY_stub::radio = &radio; object = new LoRaPHYUS915(); } virtual void TearDown() { + LoRaPHY_stub::radio = NULL; delete object; } }; @@ -38,3 +103,134 @@ TEST_F(Test_LoRaPHYUS915, constructor) EXPECT_TRUE(object); } +TEST_F(Test_LoRaPHYUS915, restore_default_channels) +{ + object->restore_default_channels(); +} + +TEST_F(Test_LoRaPHYUS915, rx_config) +{ + rx_config_params_t p; + + radio.uint8_value = 1; + EXPECT_TRUE(!object->rx_config(&p)); + + radio.uint8_value = 0; + p.is_repeater_supported = true; + EXPECT_TRUE(object->rx_config(&p)); + + p.is_repeater_supported = false; + EXPECT_TRUE(object->rx_config(&p)); +} + +TEST_F(Test_LoRaPHYUS915, tx_config) +{ + tx_config_params_t p; + int8_t tx; + lorawan_time_t time; + EXPECT_TRUE(object->tx_config(&p, &tx, &time)); +} + +TEST_F(Test_LoRaPHYUS915, link_ADR_request) +{ + adr_req_params_t params; + int8_t dr_out; + int8_t tx_power_out; + uint8_t nb_rep_out; + uint8_t nb_bytes_parsed; + + EXPECT_TRUE(0 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::uint8_value = 1; + LoRaPHY_stub::ch_mask_value = 6; + LoRaPHY_stub::adr_parse_count = 2; + EXPECT_TRUE(1 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 7; + EXPECT_TRUE(1 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 5; + LoRaPHY_stub::uint8_value = 6; + EXPECT_TRUE(6 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); + + LoRaPHY_stub::adr_parse_count = 2; + LoRaPHY_stub::ch_mask_value = 66; + LoRaPHY_stub::uint8_value = 7; + EXPECT_TRUE(7 == object->link_ADR_request(¶ms, &dr_out, &tx_power_out, &nb_rep_out, &nb_bytes_parsed)); +} + +TEST_F(Test_LoRaPHYUS915, accept_rx_param_setup_req) +{ + rx_param_setup_req_t p; + EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 923300000 - 1; + EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&p)); + + radio.bool_value = true; + p.frequency = 927500000 + 1; + p.datarate = 6; + LoRaPHY_stub::bool_counter = 0; + LoRaPHY_stub::bool_table[0] = true; + EXPECT_TRUE(2 == object->accept_rx_param_setup_req(&p)); +} + +TEST_F(Test_LoRaPHYUS915, get_alternate_DR) +{ + EXPECT_TRUE(0 == object->get_alternate_DR(0)); + + EXPECT_TRUE(4 == object->get_alternate_DR(1)); +} + +TEST_F(Test_LoRaPHYUS915, set_next_channel) +{ + channel_selection_params_t params; + uint8_t channel; + lorawan_time_t time; + lorawan_time_t timeoff; + + params.current_datarate = 4; + params.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 0; + EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(¶ms, &channel, &time, &timeoff)); + + radio.bool_value = false; + params.aggregate_timeoff = 1; + EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(¶ms, &channel, &time, &timeoff)); + + params.aggregate_timeoff = 0; + LoRaPHY_stub::uint8_value = 1; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(¶ms, &channel, &time, &timeoff)); +} + +TEST_F(Test_LoRaPHYUS915, apply_DR_offset) +{ + //10, 9, 8, 8 + //11, 10, 9, 8 + //12, 11, 10, 9 + //13, 12, 11, 10 + //13, 13, 12, 11 + + for (int i = 0; i < 5; i++) { + for (int j=0; j < 4; j++ ) { + uint8_t val = 10 + i; + val -= j; + if (val > 13) val = 13; + if (val < 8) val = 8; + EXPECT_TRUE(val == object->apply_DR_offset(i, j)); + } + } +} + +TEST_F(Test_LoRaPHYUS915, set_tx_cont_mode) +{ + cw_mode_params_t p; + object->set_tx_cont_mode(&p, 0); + + p.datarate = 4; + object->set_tx_cont_mode(&p, 0); +} + diff --git a/UNITTESTS/stubs/ATCmdParser_stub.cpp b/UNITTESTS/stubs/ATCmdParser_stub.cpp index d9157ec848..233dd039dc 100644 --- a/UNITTESTS/stubs/ATCmdParser_stub.cpp +++ b/UNITTESTS/stubs/ATCmdParser_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/ATHandler_stub.cpp b/UNITTESTS/stubs/ATHandler_stub.cpp index 7c65253af3..599d48b812 100644 --- a/UNITTESTS/stubs/ATHandler_stub.cpp +++ b/UNITTESTS/stubs/ATHandler_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/ATHandler_stub.h b/UNITTESTS/stubs/ATHandler_stub.h index 3341aa4ced..a3b1cfb5e8 100644 --- a/UNITTESTS/stubs/ATHandler_stub.h +++ b/UNITTESTS/stubs/ATHandler_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularBase_stub.cpp b/UNITTESTS/stubs/AT_CellularBase_stub.cpp index e1f8526f5f..179c2e42e1 100644 --- a/UNITTESTS/stubs/AT_CellularBase_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularBase_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularBase_stub.h b/UNITTESTS/stubs/AT_CellularBase_stub.h index f7d117d192..ec32d8eb28 100644 --- a/UNITTESTS/stubs/AT_CellularBase_stub.h +++ b/UNITTESTS/stubs/AT_CellularBase_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularDevice_stub.cpp b/UNITTESTS/stubs/AT_CellularDevice_stub.cpp index 2010018ced..9f6749a8f8 100644 --- a/UNITTESTS/stubs/AT_CellularDevice_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularDevice_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularInformation_stub.cpp b/UNITTESTS/stubs/AT_CellularInformation_stub.cpp index a41b3080d5..ae35f29bde 100644 --- a/UNITTESTS/stubs/AT_CellularInformation_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularInformation_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularMultiplexer_stub.cpp b/UNITTESTS/stubs/AT_CellularMultiplexer_stub.cpp index c397d5fb38..21ea7e9f54 100644 --- a/UNITTESTS/stubs/AT_CellularMultiplexer_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularMultiplexer_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp b/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp index c4ba878439..b28c8ebb9e 100644 --- a/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularNetwork_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularPower_stub.cpp b/UNITTESTS/stubs/AT_CellularPower_stub.cpp index 3459088ce5..56d8a4ca87 100644 --- a/UNITTESTS/stubs/AT_CellularPower_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularPower_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularSIM_stub.cpp b/UNITTESTS/stubs/AT_CellularSIM_stub.cpp index fc4be35b94..afab1012bd 100644 --- a/UNITTESTS/stubs/AT_CellularSIM_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularSIM_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularSMS_stub.cpp b/UNITTESTS/stubs/AT_CellularSMS_stub.cpp index 66456d7295..c43d4b2c82 100644 --- a/UNITTESTS/stubs/AT_CellularSMS_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularSMS_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/AT_CellularStack_stub.cpp b/UNITTESTS/stubs/AT_CellularStack_stub.cpp index 640d8c1b68..a4dd04732c 100644 --- a/UNITTESTS/stubs/AT_CellularStack_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularStack_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp b/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp index 9c9fabea1f..ce7e2aba88 100644 --- a/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/BufferedBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited +/* + * 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. diff --git a/UNITTESTS/stubs/CellularUtil_stub.cpp b/UNITTESTS/stubs/CellularUtil_stub.cpp index d4bcaf4916..7de3907310 100644 --- a/UNITTESTS/stubs/CellularUtil_stub.cpp +++ b/UNITTESTS/stubs/CellularUtil_stub.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "CellularUtil.h" #include #include diff --git a/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp b/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp index 51134b3553..b31de2eec2 100644 --- a/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/ChainingBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited +/* + * 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. @@ -74,7 +75,7 @@ bd_size_t ChainingBlockDevice::get_erase_size() const bd_size_t ChainingBlockDevice::get_erase_size(bd_addr_t addr) const { - return 0; + return 0; } int ChainingBlockDevice::get_erase_value() const diff --git a/UNITTESTS/stubs/EventFlags_stub.cpp b/UNITTESTS/stubs/EventFlags_stub.cpp index 9c20b882f4..82b1f48f62 100644 --- a/UNITTESTS/stubs/EventFlags_stub.cpp +++ b/UNITTESTS/stubs/EventFlags_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/EventQueue_stub.cpp b/UNITTESTS/stubs/EventQueue_stub.cpp index 71c030df22..b58b145e92 100644 --- a/UNITTESTS/stubs/EventQueue_stub.cpp +++ b/UNITTESTS/stubs/EventQueue_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp b/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp index 36cdb1cfac..845da43e6d 100644 --- a/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/ExhaustibleBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited +/* + * 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. diff --git a/UNITTESTS/stubs/FileHandle_stub.h b/UNITTESTS/stubs/FileHandle_stub.h index ef68572c1e..41fb365ea6 100644 --- a/UNITTESTS/stubs/FileHandle_stub.h +++ b/UNITTESTS/stubs/FileHandle_stub.h @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __FILE_HANDLE_STUB_H__ #define __FILE_HANDLE_STUB_H__ diff --git a/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp b/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp index bbc9db57ce..4f0e368981 100644 --- a/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/FlashSimBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2018 ARM Limited +/* + * 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. diff --git a/UNITTESTS/stubs/HeapBlockDevice_stub.cpp b/UNITTESTS/stubs/HeapBlockDevice_stub.cpp index afa6e9bbbc..dd39ffc28c 100644 --- a/UNITTESTS/stubs/HeapBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/HeapBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited +/* + * 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. diff --git a/UNITTESTS/stubs/Kernel_stub.cpp b/UNITTESTS/stubs/Kernel_stub.cpp index ecfa1d80af..0050f4481a 100644 --- a/UNITTESTS/stubs/Kernel_stub.cpp +++ b/UNITTESTS/stubs/Kernel_stub.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "Kernel.h" namespace rtos { diff --git a/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp b/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp index 13857f705f..e4ebeeb849 100644 --- a/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp +++ b/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp @@ -1,27 +1,19 @@ -/** - / _____) _ | | -( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | -(______/|_____)_|_|_| \__)_____)\____)_| |_| - (C)2013 Semtech - ___ _____ _ ___ _ _____ ___ ___ ___ ___ -/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| -\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| -|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| -embedded.connectivity.solutions=============== - -Description: LoRaWAN stack layer that controls both MAC and PHY underneath - -License: Revised BSD License, see LICENSE.TXT file include in the project - -Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) - - -Copyright (c) 2017, Arm Limited and affiliates. - -SPDX-License-Identifier: BSD-3-Clause -*/ +/* + * 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 "LoRaMacChannelPlan.h" diff --git a/UNITTESTS/stubs/LoRaMacCommand_stub.cpp b/UNITTESTS/stubs/LoRaMacCommand_stub.cpp index db0b739cb3..08dab8dcb3 100644 --- a/UNITTESTS/stubs/LoRaMacCommand_stub.cpp +++ b/UNITTESTS/stubs/LoRaMacCommand_stub.cpp @@ -1,26 +1,19 @@ -/** - / _____) _ | | -( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | -(______/|_____)_|_|_| \__)_____)\____)_| |_| - (C)2013 Semtech - ___ _____ _ ___ _ _____ ___ ___ ___ ___ -/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| -\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| -|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| -embedded.connectivity.solutions=============== - -Description: LoRa MAC layer implementation - -License: Revised BSD License, see LICENSE.TXT file include in the project - -Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) - -Copyright (c) 2017, Arm Limited and affiliates. - -SPDX-License-Identifier: BSD-3-Clause -*/ +/* + * 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 "LoRaMacCommand.h" #include "LoRaMac.h" diff --git a/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp b/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp index c50e499f56..d2113d012b 100644 --- a/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp +++ b/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp @@ -1,27 +1,19 @@ -/** - * / _____) _ | | - * ( (____ _____ ____ _| |_ _____ ____| |__ - * \____ \| ___ | (_ _) ___ |/ ___) _ \ - * _____) ) ____| | | || |_| ____( (___| | | | - * (______/|_____)_|_|_| \__)_____)\____)_| |_| - * (C)2013 Semtech - * ___ _____ _ ___ _ _____ ___ ___ ___ ___ - * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| - * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| - * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| - * embedded.connectivity.solutions=============== +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 * - * Description: LoRa MAC crypto implementation + * 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 * - * License: Revised BSD License, see LICENSE.TXT file include in the project + * http://www.apache.org/licenses/LICENSE-2.0 * - * Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jäckle ( STACKFORCE ) - * - * - * Copyright (c) 2017, Arm Limited and affiliates. - * - * SPDX-License-Identifier: BSD-3-Clause -*/ + * 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 #include diff --git a/UNITTESTS/stubs/LoRaMac_stub.cpp b/UNITTESTS/stubs/LoRaMac_stub.cpp index 14fe7a68d0..22a4e63e95 100644 --- a/UNITTESTS/stubs/LoRaMac_stub.cpp +++ b/UNITTESTS/stubs/LoRaMac_stub.cpp @@ -1,26 +1,20 @@ -/** - / _____) _ | | -( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | -(______/|_____)_|_|_| \__)_____)\____)_| |_| - (C)2013 Semtech - ___ _____ _ ___ _ _____ ___ ___ ___ ___ -/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| -\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| -|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| -embedded.connectivity.solutions=============== +/* + * 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. + */ -Description: LoRa MAC layer implementation - -License: Revised BSD License, see LICENSE.TXT file include in the project - -Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) - -Copyright (c) 2017, Arm Limited and affiliates. - -SPDX-License-Identifier: BSD-3-Clause -*/ #include #include "LoRaMac.h" diff --git a/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp b/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp index 68cc888f8b..a425f30a12 100644 --- a/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp +++ b/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp @@ -1,32 +1,18 @@ -/** - * @file LoRaPHYEU868.cpp +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 * - * @brief Implements LoRaPHY for European 868 MHz band + * 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 * - * \code - * ______ _ - * / _____) _ | | - * ( (____ _____ ____ _| |_ _____ ____| |__ - * \____ \| ___ | (_ _) ___ |/ ___) _ \ - * _____) ) ____| | | || |_| ____( (___| | | | - * (______/|_____)_|_|_| \__)_____)\____)_| |_| - * (C)2013 Semtech - * ___ _____ _ ___ _ _____ ___ ___ ___ ___ - * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| - * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| - * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| - * embedded.connectivity.solutions=============== - * - * \endcode - * - * - * License: Revised BSD License, see LICENSE.TXT file include in the project - * - * Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) - * - * Copyright (c) 2017, Arm Limited and affiliates. - * SPDX-License-Identifier: BSD-3-Clause + * 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 "LoRaPHYEU868.h" diff --git a/UNITTESTS/stubs/LoRaPHY_stub.cpp b/UNITTESTS/stubs/LoRaPHY_stub.cpp index 6ef2b7b5bc..cc00240aa3 100644 --- a/UNITTESTS/stubs/LoRaPHY_stub.cpp +++ b/UNITTESTS/stubs/LoRaPHY_stub.cpp @@ -1,3 +1,19 @@ +/* + * 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 @@ -8,6 +24,7 @@ #include "LoRaPHY.h" #include "LoRaPHY_stub.h" +LoRaRadio *LoRaPHY_stub::radio = NULL; uint32_t LoRaPHY_stub::uint32_value = 0; uint16_t LoRaPHY_stub::uint16_value = 0; uint8_t LoRaPHY_stub::uint8_value = 0; @@ -19,9 +36,11 @@ channel_params_t *LoRaPHY_stub::channel_params_ptr = NULL; uint8_t LoRaPHY_stub::bool_counter = 0; bool LoRaPHY_stub::bool_table[20] = {}; uint8_t LoRaPHY_stub::linkAdrNbBytesParsed = 0; +uint8_t LoRaPHY_stub::ch_mask_value = 0; +uint8_t LoRaPHY_stub::adr_parse_count = 0; LoRaPHY::LoRaPHY() - : _radio(NULL) + : _radio(LoRaPHY_stub::radio) { } @@ -154,6 +173,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle, uint8_t LoRaPHY::parse_link_ADR_req(const uint8_t *payload, link_adr_params_t *params) { + params->ch_mask_ctrl = LoRaPHY_stub::ch_mask_value; + + if (LoRaPHY_stub::adr_parse_count) { + return --LoRaPHY_stub::adr_parse_count; + } + return LoRaPHY_stub::uint8_value; } diff --git a/UNITTESTS/stubs/LoRaPHY_stub.h b/UNITTESTS/stubs/LoRaPHY_stub.h index c1632ae7d2..12a4e589bf 100644 --- a/UNITTESTS/stubs/LoRaPHY_stub.h +++ b/UNITTESTS/stubs/LoRaPHY_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,6 +23,7 @@ namespace LoRaPHY_stub { +extern LoRaRadio *radio; extern uint8_t bool_counter; extern bool bool_table[20]; extern uint32_t uint32_value; @@ -34,4 +35,6 @@ extern uint16_t uint16_value; extern lorawan_status_t lorawan_status_value; extern channel_params_t* channel_params_ptr; extern uint8_t linkAdrNbBytesParsed; +extern uint8_t ch_mask_value; +extern uint8_t adr_parse_count; } diff --git a/UNITTESTS/stubs/LoRaWANStack_stub.cpp b/UNITTESTS/stubs/LoRaWANStack_stub.cpp index 8300d6957a..628ea0faf6 100644 --- a/UNITTESTS/stubs/LoRaWANStack_stub.cpp +++ b/UNITTESTS/stubs/LoRaWANStack_stub.cpp @@ -1,27 +1,19 @@ -/** - / _____) _ | | -( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | -(______/|_____)_|_|_| \__)_____)\____)_| |_| - (C)2013 Semtech - ___ _____ _ ___ _ _____ ___ ___ ___ ___ -/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| -\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| -|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| -embedded.connectivity.solutions=============== - -Description: LoRaWAN stack layer that controls both MAC and PHY underneath - -License: Revised BSD License, see LICENSE.TXT file include in the project - -Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) - - -Copyright (c) 2017, Arm Limited and affiliates. - -SPDX-License-Identifier: BSD-3-Clause -*/ +/* + * 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 #include diff --git a/UNITTESTS/stubs/LoRaWANTimer_stub.cpp b/UNITTESTS/stubs/LoRaWANTimer_stub.cpp index 9c524d1ada..1b7f88b135 100644 --- a/UNITTESTS/stubs/LoRaWANTimer_stub.cpp +++ b/UNITTESTS/stubs/LoRaWANTimer_stub.cpp @@ -1,22 +1,19 @@ -/** - / _____) _ | | -( (____ _____ ____ _| |_ _____ ____| |__ - \____ \| ___ | (_ _) ___ |/ ___) _ \ - _____) ) ____| | | || |_| ____( (___| | | | -(______/|_____)_|_|_| \__)_____)\____)_| |_| - (C)2013 Semtech - -Description: Timer objects and scheduling management - -License: Revised BSD License, see LICENSE.TXT file include in the project - -Maintainer: Miguel Luis and Gregory Cristian - - -Copyright (c) 2017, Arm Limited and affiliates. - -SPDX-License-Identifier: BSD-3-Clause -*/ +/* + * 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 "LoRaWANTimer.h" diff --git a/UNITTESTS/stubs/MBRBlockDevice_stub.cpp b/UNITTESTS/stubs/MBRBlockDevice_stub.cpp index 1e12f59cee..9759f749c9 100644 --- a/UNITTESTS/stubs/MBRBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/MBRBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited +/* + * Copyright (c) 2017, 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. diff --git a/UNITTESTS/stubs/NetworkInterface_stub.cpp b/UNITTESTS/stubs/NetworkInterface_stub.cpp index 0e8eaa15a9..cfe6bdaa79 100644 --- a/UNITTESTS/stubs/NetworkInterface_stub.cpp +++ b/UNITTESTS/stubs/NetworkInterface_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Arm Limited and affiliates. + * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/NetworkStack_stub.cpp b/UNITTESTS/stubs/NetworkStack_stub.cpp index 372812effb..2d3a451a3c 100644 --- a/UNITTESTS/stubs/NetworkStack_stub.cpp +++ b/UNITTESTS/stubs/NetworkStack_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Arm Limited and affiliates. + * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp b/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp index ffd9450a83..550bf722a3 100644 --- a/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/ObservingBlockDevice_stub.cpp @@ -1,23 +1,18 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017-2017 ARM Limited +/* + * Copyright (c) 2017, Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * 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 "ObservingBlockDevice.h" diff --git a/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp b/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp index df41cb1da5..52a94fa5b1 100644 --- a/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/ProfilingBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited +/* + * Copyright (c) 2017, 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. diff --git a/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp b/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp index 13e20d934e..17a42915bb 100644 --- a/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/ReadOnlyBlockDevice_stub.cpp @@ -1,23 +1,18 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017-2017 ARM Limited +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * 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 * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * http://www.apache.org/licenses/LICENSE-2.0 * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * 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 "ReadOnlyBlockDevice.h" diff --git a/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp b/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp index 6b4fbabdcf..d0b75ee194 100644 --- a/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp +++ b/UNITTESTS/stubs/SlicingBlockDevice_stub.cpp @@ -1,5 +1,6 @@ -/* mbed Microcontroller Library - * Copyright (c) 2017 ARM Limited +/* + * 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. @@ -19,7 +20,7 @@ SlicingBlockDevice::SlicingBlockDevice(BlockDevice *bd, bd_addr_t start, bd_addr_t stop) { - + } int SlicingBlockDevice::init() diff --git a/UNITTESTS/stubs/SocketAddress_stub.cpp b/UNITTESTS/stubs/SocketAddress_stub.cpp index 9ed53f03cf..874e5ce667 100644 --- a/UNITTESTS/stubs/SocketAddress_stub.cpp +++ b/UNITTESTS/stubs/SocketAddress_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/Timer_stub.h b/UNITTESTS/stubs/Timer_stub.h index 699fdd0c53..a97333fe63 100644 --- a/UNITTESTS/stubs/Timer_stub.h +++ b/UNITTESTS/stubs/Timer_stub.h @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef TIMER_STUB_H #define TIMER_STUB_H diff --git a/UNITTESTS/stubs/aes_stub.c b/UNITTESTS/stubs/aes_stub.c index ca54d09030..c9b93dfb0b 100644 --- a/UNITTESTS/stubs/aes_stub.c +++ b/UNITTESTS/stubs/aes_stub.c @@ -1,3 +1,19 @@ +/* + * 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. + */ #if !defined(MBEDTLS_CONFIG_FILE) diff --git a/UNITTESTS/stubs/cipher_stub.c b/UNITTESTS/stubs/cipher_stub.c index 350e4fa0de..98234bbe4e 100644 --- a/UNITTESTS/stubs/cipher_stub.c +++ b/UNITTESTS/stubs/cipher_stub.c @@ -1,26 +1,18 @@ -/** - * \file cipher.c +/* + * Copyright (c) , Arm Limited and affiliates. + * SPDX-License-Identifier: Apache-2.0 * - * \brief Generic cipher wrapper for mbed TLS + * 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 * - * \author Adriaan de Jong + * http://www.apache.org/licenses/LICENSE-2.0 * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * 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. - * - * This file is part of mbed TLS (https://tls.mbed.org) + * 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. */ #if !defined(MBEDTLS_CONFIG_FILE) diff --git a/UNITTESTS/stubs/cmac_stub.c b/UNITTESTS/stubs/cmac_stub.c index e2277f17ad..ed720625ee 100644 --- a/UNITTESTS/stubs/cmac_stub.c +++ b/UNITTESTS/stubs/cmac_stub.c @@ -1,3 +1,19 @@ +/* + * 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. + */ #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" diff --git a/UNITTESTS/stubs/ip4tos_stub.c b/UNITTESTS/stubs/ip4tos_stub.c index 35957fe232..c45c1383bb 100644 --- a/UNITTESTS/stubs/ip4tos_stub.c +++ b/UNITTESTS/stubs/ip4tos_stub.c @@ -1,18 +1,20 @@ /* - * Copyright (c) 2014-2018 ARM Limited. All rights reserved. + * 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. + * + * 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 + * 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. + * 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 #include #include "common_functions.h" diff --git a/UNITTESTS/stubs/mbed_assert_stub.c b/UNITTESTS/stubs/mbed_assert_stub.c index 9029a6192d..afe6fb3ff3 100644 --- a/UNITTESTS/stubs/mbed_assert_stub.c +++ b/UNITTESTS/stubs/mbed_assert_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Arm Limited and affiliates. + * Copyright (c) , Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/mbed_critical_stub.c b/UNITTESTS/stubs/mbed_critical_stub.c index f812764382..ca08e252d4 100644 --- a/UNITTESTS/stubs/mbed_critical_stub.c +++ b/UNITTESTS/stubs/mbed_critical_stub.c @@ -1,16 +1,16 @@ /* - * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved + * Copyright (c) 2017, 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. + * 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 + * 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. + * 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. */ diff --git a/UNITTESTS/stubs/mbed_poll_stub.cpp b/UNITTESTS/stubs/mbed_poll_stub.cpp index 1914399d2a..4db534ed10 100644 --- a/UNITTESTS/stubs/mbed_poll_stub.cpp +++ b/UNITTESTS/stubs/mbed_poll_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) , Arm Limited and affiliates. + * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/mbed_poll_stub.h b/UNITTESTS/stubs/mbed_poll_stub.h index 6c0a4327a9..930766e840 100644 --- a/UNITTESTS/stubs/mbed_poll_stub.h +++ b/UNITTESTS/stubs/mbed_poll_stub.h @@ -1,5 +1,5 @@ /* - * Copyright (c) , Arm Limited and affiliates. + * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #ifndef __MBED_POLL_STUB_H__ #define __MBED_POLL_STUB_H__ diff --git a/UNITTESTS/stubs/mbed_wait_api_stub.cpp b/UNITTESTS/stubs/mbed_wait_api_stub.cpp index f8b240544d..68a265308c 100644 --- a/UNITTESTS/stubs/mbed_wait_api_stub.cpp +++ b/UNITTESTS/stubs/mbed_wait_api_stub.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) , Arm Limited and affiliates. + * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/UNITTESTS/stubs/nvic_wrapper_stub.c b/UNITTESTS/stubs/nvic_wrapper_stub.c index 636f05bae5..9cd88195c0 100644 --- a/UNITTESTS/stubs/nvic_wrapper_stub.c +++ b/UNITTESTS/stubs/nvic_wrapper_stub.c @@ -1,3 +1,20 @@ +/* + * Copyright (c) 2017, 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 "nvic_wrapper.h" void NVIC_SystemReset(void) {} diff --git a/UNITTESTS/stubs/randLIB_stub.c b/UNITTESTS/stubs/randLIB_stub.c index 97154cf2ee..e9fd486adb 100644 --- a/UNITTESTS/stubs/randLIB_stub.c +++ b/UNITTESTS/stubs/randLIB_stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017, Arm Limited and affiliates. + * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include #include #include diff --git a/UNITTESTS/stubs/randLIB_stub.cpp b/UNITTESTS/stubs/randLIB_stub.cpp index 61cd893d0e..28989c444e 100644 --- a/UNITTESTS/stubs/randLIB_stub.cpp +++ b/UNITTESTS/stubs/randLIB_stub.cpp @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "randLIB.h" void randLIB_seed_random(void) diff --git a/UNITTESTS/stubs/stoip4_stub.c b/UNITTESTS/stubs/stoip4_stub.c index d22c20e23e..9cb8036577 100644 --- a/UNITTESTS/stubs/stoip4_stub.c +++ b/UNITTESTS/stubs/stoip4_stub.c @@ -1,18 +1,20 @@ /* - * Copyright (c) 2014-2018 ARM Limited. All rights reserved. + * 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. + * + * 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 + * 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. + * 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 #include #include diff --git a/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp b/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp index 357d382844..de79e51f29 100644 --- a/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHYAU915.cpp @@ -615,10 +615,5 @@ lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next uint8_t LoRaPHYAU915::apply_DR_offset(int8_t dr, int8_t dr_offset) { - int8_t datarate = datarate_offsets_AU915[dr][dr_offset]; - - if (datarate < 0) { - datarate = DR_0; - } - return datarate; + return datarate_offsets_AU915[dr][dr_offset]; } diff --git a/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp b/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp index a531de055b..0ea2ddd930 100644 --- a/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp +++ b/features/lorawan/lorastack/phy/LoRaPHYUS915.cpp @@ -676,11 +676,5 @@ void LoRaPHYUS915::set_tx_cont_mode(cw_mode_params_t* params, uint32_t given_fre uint8_t LoRaPHYUS915::apply_DR_offset(int8_t dr, int8_t dr_offset) { - int8_t datarate = datarate_offsets_US915[dr][dr_offset]; - - if (datarate < 0) { - datarate = DR_0; - } - - return datarate; + return datarate_offsets_US915[dr][dr_offset]; }