diff --git a/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp b/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp new file mode 100644 index 0000000000..d02c9d68f7 --- /dev/null +++ b/UNITTESTS/features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2018, 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 "gtest/gtest.h" +#include "LoRaWANInterface.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){}; + + virtual void start_cad(void){}; + + virtual bool check_rf_frequency(uint32_t frequency){}; + + virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; + + virtual void lock(void){}; + + virtual void unlock(void){}; +}; + +class my_LoRaPHY : public LoRaPHY +{ +public: + my_LoRaPHY(){}; + + virtual ~my_LoRaPHY(){}; +}; + +class Test_LoRaWANInterface : public testing::Test { +protected: + LoRaWANInterface *object; + my_radio radio; + + virtual void SetUp() + { + object = new LoRaWANInterface(radio); + } + + virtual void TearDown() + { + delete object; + } +}; + +TEST_F(Test_LoRaWANInterface, constructor) +{ + EXPECT_TRUE(object); + + my_radio radio; + my_LoRaPHY phy; + LoRaWANInterface object(radio, phy); +} + +TEST_F(Test_LoRaWANInterface, initialize) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->initialize(NULL)); +} + +TEST_F(Test_LoRaWANInterface, connect) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->connect()); + + lorawan_connect_t conn; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->connect(conn)); +} + +TEST_F(Test_LoRaWANInterface, disconnect) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->disconnect()); +} + +TEST_F(Test_LoRaWANInterface, add_link_check_request) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->add_link_check_request()); +} + +TEST_F(Test_LoRaWANInterface, remove_link_check_request) +{ + object->remove_link_check_request(); +} + +TEST_F(Test_LoRaWANInterface, set_datarate) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_datarate(1)); +} + +TEST_F(Test_LoRaWANInterface, enable_adaptive_datarate) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->enable_adaptive_datarate()); +} + +TEST_F(Test_LoRaWANInterface, disable_adaptive_datarate) +{ + object->disable_adaptive_datarate(); +} + +TEST_F(Test_LoRaWANInterface, set_confirmed_msg_retries) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_confirmed_msg_retries(1)); +} + +TEST_F(Test_LoRaWANInterface, set_channel_plan) +{ + lorawan_channelplan_t plan; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_channel_plan(plan)); +} + +TEST_F(Test_LoRaWANInterface, get_channel_plan) +{ + lorawan_channelplan_t plan; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_channel_plan(plan)); +} + +TEST_F(Test_LoRaWANInterface, remove_channel_plan) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->remove_channel_plan()); +} + +TEST_F(Test_LoRaWANInterface, remove_channel) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->remove_channel(1)); +} + +TEST_F(Test_LoRaWANInterface, send) +{ + EXPECT_TRUE(0 == object->send(1, NULL, 0, 0)); +} + +TEST_F(Test_LoRaWANInterface, receive) +{ + EXPECT_TRUE(0 == object->receive(1, NULL, 0, 0)); + + uint8_t port; + int flags; + EXPECT_TRUE(0 == object->receive(NULL, 0, port, flags)); +} + +TEST_F(Test_LoRaWANInterface, add_app_callbacks) +{ + lorawan_app_callbacks_t cbs; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->add_app_callbacks(&cbs)); +} + +TEST_F(Test_LoRaWANInterface, set_device_class) +{ + object->set_device_class(CLASS_A); +} + +TEST_F(Test_LoRaWANInterface, get_tx_metadata) +{ + lorawan_tx_metadata data; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_tx_metadata(data)); +} + +TEST_F(Test_LoRaWANInterface, get_rx_metadata) +{ + lorawan_rx_metadata data; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_rx_metadata(data)); +} + +TEST_F(Test_LoRaWANInterface, get_backoff_metadata) +{ + int i; + EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_backoff_metadata(i)); +} + +TEST_F(Test_LoRaWANInterface, cancel_sending) +{ + EXPECT_TRUE(LORAWAN_STATUS_OK == object->cancel_sending()); +} + diff --git a/UNITTESTS/features/lorawan/lorawaninterface/unittest.cmake b/UNITTESTS/features/lorawan/lorawaninterface/unittest.cmake new file mode 100644 index 0000000000..3a86f0516e --- /dev/null +++ b/UNITTESTS/features/lorawan/lorawaninterface/unittest.cmake @@ -0,0 +1,51 @@ +#[[ + * Copyright (c) 2018, 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. +]] + +# Unit test suite name +set(TEST_SUITE_NAME "lorawan_LoRaWANInterface") + +# Source files +set(unittest-sources + ../features/lorawan/LoRaWANInterface.cpp +) + +# Add test specific include paths +set(unittest-includes ${unittest-includes} + target_h + ../features/lorawan +) + +# Test & stub files +set(unittest-test-sources + ../features/lorawan/lorawaninterface/Test_LoRaWANInterface.cpp + stubs/LoRaPHY_stub.cpp + stubs/LoRaWANStack_stub.cpp + stubs/LoRaMac_stub.cpp + stubs/mbed_assert_stub.c + stubs/LoRaMacCrypto_stub.cpp + stubs/LoRaMacChannelPlan_stub.cpp + stubs/LoRaWANTimer_stub.cpp + stubs/LoRaMacCommand_stub.cpp + stubs/LoRaPHYEU868_stub.cpp +) + +# defines +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMBED_CONF_LORA_PHY=\"EU868\"") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMBED_CONF_LORA_PHY=\"EU868\"") + + + diff --git a/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp b/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp new file mode 100644 index 0000000000..13857f705f --- /dev/null +++ b/UNITTESTS/stubs/LoRaMacChannelPlan_stub.cpp @@ -0,0 +1,60 @@ +/** + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (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 +*/ + +#include "LoRaMacChannelPlan.h" + +LoRaMacChannelPlan::LoRaMacChannelPlan() : _lora_phy(NULL) +{ +} + +LoRaMacChannelPlan::~LoRaMacChannelPlan() +{ +} + +void LoRaMacChannelPlan::activate_channelplan_subsystem(LoRaPHY *phy) +{ +} + +lorawan_status_t LoRaMacChannelPlan::set_plan(const lorawan_channelplan_t& plan) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacChannelPlan::get_plan(lorawan_channelplan_t& plan, + const channel_params_t* channel_list) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacChannelPlan::remove_plan() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacChannelPlan::remove_single_channel(uint8_t channel_id) +{ + return LORAWAN_STATUS_OK; +} + diff --git a/UNITTESTS/stubs/LoRaMacCommand_stub.cpp b/UNITTESTS/stubs/LoRaMacCommand_stub.cpp new file mode 100644 index 0000000000..db0b739cb3 --- /dev/null +++ b/UNITTESTS/stubs/LoRaMacCommand_stub.cpp @@ -0,0 +1,149 @@ +/** + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (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 +*/ + +#include "LoRaMacCommand.h" +#include "LoRaMac.h" + + +LoRaMacCommand::LoRaMacCommand() +{ +} + +void LoRaMacCommand::clear_command_buffer() +{ +} + +uint8_t LoRaMacCommand::get_mac_cmd_length() const +{ + return 0; +} + +uint8_t *LoRaMacCommand::get_mac_commands_buffer() +{ + return NULL; +} + +void LoRaMacCommand::parse_mac_commands_to_repeat() +{ +} + + +void LoRaMacCommand::clear_repeat_buffer() +{ +} + +void LoRaMacCommand::copy_repeat_commands_to_buffer() +{ +} + +uint8_t LoRaMacCommand::get_repeat_commands_length() const +{ + return 0; +} + +void LoRaMacCommand::clear_mac_commands_in_next_tx() +{ +} + +bool LoRaMacCommand::is_mac_command_in_next_tx() const +{ + return false; +} + +void LoRaMacCommand::clear_sticky_mac_cmd() +{ +} + +bool LoRaMacCommand::has_sticky_mac_cmd() const +{ + return false; +} + +lorawan_status_t LoRaMacCommand::process_mac_commands(const uint8_t *payload, uint8_t mac_index, + uint8_t commands_size, uint8_t snr, + loramac_mlme_confirm_t& mlme_conf, + lora_mac_system_params_t &mac_sys_params, + LoRaPHY &lora_phy) +{ + return LORAWAN_STATUS_OK; +} + +bool LoRaMacCommand::is_sticky_mac_command_pending() +{ + return false; +} + +int32_t LoRaMacCommand::cmd_buffer_remaining() const +{ + return 0; +} + +void LoRaMacCommand::set_batterylevel_callback(mbed::Callback battery_level) +{ +} + +lorawan_status_t LoRaMacCommand::add_link_check_req() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_link_adr_ans(uint8_t status) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_duty_cycle_ans() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_rx_param_setup_ans(uint8_t status) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_dev_status_ans(uint8_t battery, uint8_t margin) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_new_channel_ans(uint8_t status) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_rx_timing_setup_ans() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_tx_param_setup_ans() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMacCommand::add_dl_channel_ans(uint8_t status) +{ + return LORAWAN_STATUS_OK; +} diff --git a/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp b/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp new file mode 100644 index 0000000000..c50e499f56 --- /dev/null +++ b/UNITTESTS/stubs/LoRaMacCrypto_stub.cpp @@ -0,0 +1,70 @@ +/** + * / _____) _ | | + * ( (____ _____ ____ _| |_ _____ ____| |__ + * \____ \| ___ | (_ _) ___ |/ ___) _ \ + * _____) ) ____| | | || |_| ____( (___| | | | + * (______/|_____)_|_|_| \__)_____)\____)_| |_| + * (C)2013 Semtech + * ___ _____ _ ___ _ _____ ___ ___ ___ ___ + * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| + * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| + * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| + * embedded.connectivity.solutions=============== + * + * Description: LoRa MAC crypto implementation + * + * License: Revised BSD License, see LICENSE.TXT file include in the project + * + * 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 +*/ + +#include +#include + +#include "LoRaMacCrypto.h" +#include "system/lorawan_data_structures.h" + + +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; +} + +int LoRaMacCrypto::encrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t, + uint8_t , uint32_t , uint8_t *) +{ + return 0; +} + +int LoRaMacCrypto::decrypt_payload(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t, + uint8_t , uint32_t , uint8_t *) +{ + return 0; +} + +int LoRaMacCrypto::compute_join_frame_mic(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint32_t *) +{ + return 0; +} + +int LoRaMacCrypto::decrypt_join_frame(const uint8_t *, uint16_t , const uint8_t *, uint32_t, uint8_t *) +{ + return 0; +} + +int LoRaMacCrypto::compute_skeys_for_join_frame(const uint8_t *, uint32_t, const uint8_t *, uint16_t , + uint8_t *, uint8_t *) +{ + return 0; +} + diff --git a/UNITTESTS/stubs/LoRaMac_stub.cpp b/UNITTESTS/stubs/LoRaMac_stub.cpp new file mode 100644 index 0000000000..14fe7a68d0 --- /dev/null +++ b/UNITTESTS/stubs/LoRaMac_stub.cpp @@ -0,0 +1,399 @@ +/** + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (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 +*/ +#include +#include "LoRaMac.h" + + +using namespace events; +using namespace mbed; + + +LoRaMac::LoRaMac() + : _lora_time(), + _lora_phy(NULL), + _mac_commands(), + _channel_plan(), + _lora_crypto(), + _ev_queue(NULL), + _mcps_indication(), + _mcps_confirmation(), + _mlme_indication(), + _mlme_confirmation(), + _is_nwk_joined(false), + _continuous_rx2_window_open(false), + _device_class(CLASS_A) +{} + +LoRaMac::~LoRaMac() +{ +} + +const loramac_mcps_confirm_t *LoRaMac::get_mcps_confirmation() const +{ + return NULL; +} + +const loramac_mcps_indication_t *LoRaMac::get_mcps_indication() const +{ + return NULL; +} + +const loramac_mlme_confirm_t *LoRaMac::get_mlme_confirmation() const +{ + return NULL; +} + +const loramac_mlme_indication_t *LoRaMac::get_mlme_indication() const +{ + return NULL; +} + +void LoRaMac::post_process_mlme_request() +{ +} + +void LoRaMac::post_process_mcps_req() +{ +} + +void LoRaMac::post_process_mcps_ind() +{ +} + +void LoRaMac::post_process_mlme_ind() +{ +} + +lorawan_time_t LoRaMac::get_current_time(void) +{ +} + +rx_slot_t LoRaMac::get_current_slot(void) +{ + return RX_SLOT_WIN_1; +} + +void LoRaMac::handle_join_accept_frame(const uint8_t *payload, uint16_t size) +{ +} + +void LoRaMac::check_frame_size(uint16_t size) +{ +} + +bool LoRaMac::message_integrity_check(const uint8_t *const payload, + const uint16_t size, + uint8_t *const ptr_pos, + uint32_t address, + uint32_t *downlink_counter, + const uint8_t *nwk_skey) +{ + return true; +} + +void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload, + uint16_t size, + uint8_t fopts_len, + uint8_t *nwk_skey, + uint8_t *app_skey, + uint32_t address, + uint32_t downlink_counter, + int16_t rssi, + int8_t snr) +{ +} + +void LoRaMac::extract_mac_commands_only(const uint8_t *payload, + int8_t snr, + uint8_t fopts_len) +{ +} + +void LoRaMac::handle_data_frame(const uint8_t *const payload, + const uint16_t size, + uint8_t ptr_pos, + uint8_t msg_type, + int16_t rssi, + int8_t snr) +{ +} + +void LoRaMac::set_batterylevel_callback(mbed::Callback battery_level) +{ +} + +void LoRaMac::on_radio_tx_done(lorawan_time_t timestamp) +{ +} + +void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size, + int16_t rssi, int8_t snr) +{ +} + +void LoRaMac::on_radio_tx_timeout(void) +{ +} + +void LoRaMac::on_radio_rx_timeout(bool is_timeout) +{ +} + +bool LoRaMac::continue_joining_process() +{ + return true; +} + +bool LoRaMac::continue_sending_process() +{ + return true; +} + +lorawan_status_t LoRaMac::send_join_request() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::handle_retransmission() +{ + return LORAWAN_STATUS_OK; +} + +void LoRaMac::on_backoff_timer_expiry(void) +{ +} + +void LoRaMac::open_rx1_window(void) +{ +} + +void LoRaMac::open_rx2_window() +{ +} + +void LoRaMac::on_ack_timeout_timer_event(void) +{ +} + +bool LoRaMac::validate_payload_length(uint16_t length, + int8_t datarate, + uint8_t fopts_len) +{ + return false; +} + +void LoRaMac::set_mlme_schedule_ul_indication(void) +{ +} + +// This is not actual transmission. It just schedules a message in response +// to MCPS request +lorawan_status_t LoRaMac::send(loramac_mhdr_t *machdr, const uint8_t fport, + const void *fbuffer, uint16_t fbuffer_size) +{ + return LORAWAN_STATUS_OK; +} + +int LoRaMac::get_backoff_timer_event_id(void) +{ + return 0; +} + +lorawan_status_t LoRaMac::clear_tx_pipe(void) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::schedule_tx() +{ + return LORAWAN_STATUS_OK; +} + +void LoRaMac::calculate_backOff(uint8_t channel) +{ +} + +void LoRaMac::reset_mac_parameters(void) +{ +} + +uint8_t LoRaMac::get_default_tx_datarate() +{ + return 0; +} + +void LoRaMac::enable_adaptive_datarate(bool adr_enabled) +{ +} + +lorawan_status_t LoRaMac::set_channel_data_rate(uint8_t data_rate) +{ + return LORAWAN_STATUS_OK; +} + +bool LoRaMac::tx_ongoing() +{ + return false; +} + +void LoRaMac::set_tx_ongoing(bool ongoing) +{ +} + +void LoRaMac::reset_ongoing_tx(bool reset_pending) +{ +} + +int16_t LoRaMac::prepare_ongoing_tx(const uint8_t port, + const uint8_t *const data, + uint16_t length, + uint8_t flags, + uint8_t num_retries) +{ + return 0; +} + +lorawan_status_t LoRaMac::send_ongoing_tx() +{ + return LORAWAN_STATUS_OK; +} + +device_class_t LoRaMac::get_device_class() const +{ + return CLASS_A; +} + +void LoRaMac::set_device_class(const device_class_t &device_class, + mbed::Callbackack_expiry_handler) +{ +} + +void LoRaMac::setup_link_check_request() +{ +} + +lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_otaa) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::join(bool is_otaa) +{ + return LORAWAN_STATUS_OK; +} + +static void memcpy_convert_endianess(uint8_t *dst, + const uint8_t *src, + uint16_t size) +{ +} + +lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr, + loramac_frame_ctrl_t *fctrl, + const uint8_t fport, + const void *fbuffer, + uint16_t fbuffer_size) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::send_frame_on_channel(uint8_t channel) +{ + return LORAWAN_STATUS_OK; +} + +void LoRaMac::reset_mcps_confirmation() +{ +} + +void LoRaMac::reset_mlme_confirmation() +{ +} + +void LoRaMac::reset_mcps_indication() +{ +} + +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) +{ +} + +lorawan_status_t LoRaMac::initialize(EventQueue *queue, + mbed::Callbackscheduling_failure_handler) +{ + return LORAWAN_STATUS_OK; +} + +void LoRaMac::disconnect() +{ +} + +uint8_t LoRaMac::get_max_possible_tx_size(uint8_t fopts_len) +{ + return 0; +} + +bool LoRaMac::nwk_joined() +{ + return false; +} + +void LoRaMac::set_nwk_joined(bool joined) +{ +} + +lorawan_status_t LoRaMac::add_channel_plan(const lorawan_channelplan_t &plan) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::remove_channel_plan() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::get_channel_plan(lorawan_channelplan_t &plan) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::remove_single_channel(uint8_t id) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::multicast_channel_link(multicast_params_t *channel_param) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaMac::multicast_channel_unlink(multicast_params_t *channel_param) +{ + return LORAWAN_STATUS_OK; +} + +void LoRaMac::bind_phy(LoRaPHY &phy) +{ +} diff --git a/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp b/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp new file mode 100644 index 0000000000..68cc888f8b --- /dev/null +++ b/UNITTESTS/stubs/LoRaPHYEU868_stub.cpp @@ -0,0 +1,42 @@ +/** + * @file LoRaPHYEU868.cpp + * + * @brief Implements LoRaPHY for European 868 MHz band + * + * \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 + * + */ + +#include "LoRaPHYEU868.h" +#include "lora_phy_ds.h" + +LoRaPHYEU868::LoRaPHYEU868() +{ +} + +LoRaPHYEU868::~LoRaPHYEU868() +{ +} + diff --git a/UNITTESTS/stubs/LoRaWANStack_stub.cpp b/UNITTESTS/stubs/LoRaWANStack_stub.cpp new file mode 100644 index 0000000000..8300d6957a --- /dev/null +++ b/UNITTESTS/stubs/LoRaWANStack_stub.cpp @@ -0,0 +1,306 @@ +/** + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (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 +*/ + +#include +#include + +#include "LoRaWANStack.h" + +using namespace mbed; +using namespace events; + +/***************************************************************************** + * Constructor * + ****************************************************************************/ +LoRaWANStack::LoRaWANStack() + : _loramac(), + _device_current_state(DEVICE_STATE_NOT_INITIALIZED), + _lw_session(), + _tx_msg(), + _rx_msg(), + _tx_metadata(), + _rx_metadata(), + _num_retry(1), + _ctrl_flags(0), + _app_port(12), + _link_check_requested(false), + _automatic_uplink_ongoing(false), + _ready_for_rx(true), + _queue(NULL) +{ +} + +void LoRaWANStack::bind_phy_and_radio_driver(LoRaRadio &radio, LoRaPHY &phy) +{ +} + +lorawan_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::set_lora_callbacks(const lorawan_app_callbacks_t *callbacks) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::connect() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::connect(const lorawan_connect_t &connect) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::add_channels(const lorawan_channelplan_t &channel_plan) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::drop_channel_list() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::get_enabled_channels(lorawan_channelplan_t &channel_plan) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::set_confirmed_msg_retry(uint8_t count) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::stop_sending(void) +{ + return LORAWAN_STATUS_OK; +} + +int16_t LoRaWANStack::handle_tx(const uint8_t port, const uint8_t *data, + uint16_t length, uint8_t flags, + bool null_allowed, bool allow_port_0) +{ + return 0; +} + +int16_t LoRaWANStack::handle_rx(uint8_t *data, uint16_t length, uint8_t &port, int &flags, bool validate_params) +{ + return 0; +} + +lorawan_status_t LoRaWANStack::set_link_check_request() +{ + return LORAWAN_STATUS_OK; +} + +void LoRaWANStack::remove_link_check_request() +{ +} + +lorawan_status_t LoRaWANStack::shutdown() +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::set_device_class(const device_class_t &device_class) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::acquire_tx_metadata(lorawan_tx_metadata &tx_metadata) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::acquire_rx_metadata(lorawan_rx_metadata &metadata) +{ + return LORAWAN_STATUS_OK; +} + +lorawan_status_t LoRaWANStack::acquire_backoff_metadata(int &backoff) +{ + return LORAWAN_STATUS_OK; +} + +/***************************************************************************** + * Interrupt handlers * + ****************************************************************************/ +void LoRaWANStack::tx_interrupt_handler(void) +{ +} + +void LoRaWANStack::rx_interrupt_handler(const uint8_t *payload, uint16_t size, + int16_t rssi, int8_t snr) +{ +} + +void LoRaWANStack::rx_error_interrupt_handler(void) +{ +} + +void LoRaWANStack::tx_timeout_interrupt_handler(void) +{ +} + +void LoRaWANStack::rx_timeout_interrupt_handler(void) +{ +} + +void LoRaWANStack::process_transmission_timeout() +{ +} + +void LoRaWANStack::process_transmission(void) +{ +} + +void LoRaWANStack::handle_ack_expiry_for_class_c(void) +{ +} + +void LoRaWANStack::handle_scheduling_failure(void) +{ +} + +void LoRaWANStack::process_reception(const uint8_t *const payload, uint16_t size, + int16_t rssi, int8_t snr) +{ +} + +void LoRaWANStack::process_reception_timeout(bool is_timeout) +{ +} + +void LoRaWANStack::make_tx_metadata_available(void) +{ +} + +void LoRaWANStack::make_rx_metadata_available(void) +{ +} + +bool LoRaWANStack::is_port_valid(const uint8_t port, bool allow_port_0) +{ + return true; +} + +lorawan_status_t LoRaWANStack::set_application_port(const uint8_t port, bool allow_port_0) +{ + return LORAWAN_STATUS_OK; +} + +void LoRaWANStack::state_machine_run_to_completion() +{ +} + +void LoRaWANStack::send_event_to_application(const lorawan_event_t event) const +{ +} + +void LoRaWANStack::send_automatic_uplink_message(const uint8_t port) +{ +} + +int LoRaWANStack::convert_to_msg_flag(const mcps_type_t type) +{ + return 0; +} + +lorawan_status_t LoRaWANStack::handle_connect(bool is_otaa) +{ + return LORAWAN_STATUS_OK; +} + +void LoRaWANStack::mlme_indication_handler() +{ +} + +void LoRaWANStack::mlme_confirm_handler() +{ +} + +void LoRaWANStack::mcps_confirm_handler() +{ +} + +void LoRaWANStack::mcps_indication_handler() +{ +} + +lorawan_status_t LoRaWANStack::state_controller(device_states_t new_state) +{ + return LORAWAN_STATUS_OK; +} + +void LoRaWANStack::process_shutdown_state(lorawan_status_t &op_status) +{ +} + +void LoRaWANStack::process_status_check_state() +{ +} + +void LoRaWANStack::process_scheduling_state(lorawan_status_t &op_status) +{ +} + +void LoRaWANStack::process_joining_state(lorawan_status_t &op_status) +{ +} + +void LoRaWANStack::process_connected_state() +{ +} + +void LoRaWANStack::process_connecting_state(lorawan_status_t &op_status) +{ +} + +void LoRaWANStack::process_idle_state(lorawan_status_t &op_status) +{ +} + +void LoRaWANStack::process_uninitialized_state(lorawan_status_t &op_status) +{ +} + diff --git a/UNITTESTS/stubs/LoRaWANTimer_stub.cpp b/UNITTESTS/stubs/LoRaWANTimer_stub.cpp new file mode 100644 index 0000000000..9c524d1ada --- /dev/null +++ b/UNITTESTS/stubs/LoRaWANTimer_stub.cpp @@ -0,0 +1,56 @@ +/** + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (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 +*/ + +#include "LoRaWANTimer.h" + +LoRaWANTimeHandler::LoRaWANTimeHandler() + : _queue(NULL) +{ +} + +LoRaWANTimeHandler::~LoRaWANTimeHandler() +{ +} + +void LoRaWANTimeHandler::activate_timer_subsystem(events::EventQueue *queue) +{ +} + +lorawan_time_t LoRaWANTimeHandler::get_current_time( void ) +{ + return (lorawan_time_t)0; +} + +lorawan_time_t LoRaWANTimeHandler::get_elapsed_time(lorawan_time_t saved_time) +{ + return (lorawan_time_t)0; +} + +void LoRaWANTimeHandler::init(timer_event_t &obj, mbed::Callback callback) +{ +} + +void LoRaWANTimeHandler::start(timer_event_t &obj, const uint32_t timeout) +{ +} + +void LoRaWANTimeHandler::stop(timer_event_t &obj) +{ +}