Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Test_LoRaWANInterface.cpp
00001 /* 00002 * Copyright (c) 2018, Arm Limited and affiliates 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "gtest/gtest.h" 00019 #include "LoRaWANInterface.h" 00020 00021 class my_radio : public LoRaRadio 00022 { 00023 public: 00024 00025 virtual void init_radio(radio_events_t *events){}; 00026 00027 virtual void radio_reset(){}; 00028 00029 virtual void sleep(void){}; 00030 00031 virtual void standby(void){}; 00032 00033 virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth, 00034 uint32_t datarate, uint8_t coderate, 00035 uint32_t bandwidth_afc, uint16_t preamble_len, 00036 uint16_t symb_timeout, bool fix_len, 00037 uint8_t payload_len, 00038 bool crc_on, bool freq_hop_on, uint8_t hop_period, 00039 bool iq_inverted, bool rx_continuous){}; 00040 00041 virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev, 00042 uint32_t bandwidth, uint32_t datarate, 00043 uint8_t coderate, uint16_t preamble_len, 00044 bool fix_len, bool crc_on, bool freq_hop_on, 00045 uint8_t hop_period, bool iq_inverted, uint32_t timeout){}; 00046 00047 virtual void send(uint8_t *buffer, uint8_t size){}; 00048 00049 virtual void receive(void){}; 00050 00051 virtual void set_channel(uint32_t freq){}; 00052 00053 virtual uint32_t random(void){}; 00054 00055 virtual uint8_t get_status(void){}; 00056 00057 virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){}; 00058 00059 virtual void set_public_network(bool enable){}; 00060 00061 virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){}; 00062 00063 virtual bool perform_carrier_sense(radio_modems_t modem, 00064 uint32_t freq, 00065 int16_t rssi_threshold, 00066 uint32_t max_carrier_sense_time){}; 00067 00068 virtual void start_cad(void){}; 00069 00070 virtual bool check_rf_frequency(uint32_t frequency){}; 00071 00072 virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){}; 00073 00074 virtual void lock(void){}; 00075 00076 virtual void unlock(void){}; 00077 }; 00078 00079 class my_LoRaPHY : public LoRaPHY 00080 { 00081 public: 00082 my_LoRaPHY(){}; 00083 00084 virtual ~my_LoRaPHY(){}; 00085 }; 00086 00087 class Test_LoRaWANInterface : public testing::Test { 00088 protected: 00089 LoRaWANInterface *object; 00090 my_radio radio; 00091 00092 virtual void SetUp() 00093 { 00094 object = new LoRaWANInterface(radio); 00095 } 00096 00097 virtual void TearDown() 00098 { 00099 delete object; 00100 } 00101 }; 00102 00103 TEST_F(Test_LoRaWANInterface, constructor) 00104 { 00105 EXPECT_TRUE(object); 00106 00107 my_radio radio; 00108 my_LoRaPHY phy; 00109 LoRaWANInterface object(radio, phy); 00110 } 00111 00112 TEST_F(Test_LoRaWANInterface, initialize) 00113 { 00114 EXPECT_TRUE(LORAWAN_STATUS_OK == object->initialize(NULL)); 00115 } 00116 00117 TEST_F(Test_LoRaWANInterface, connect) 00118 { 00119 EXPECT_TRUE(LORAWAN_STATUS_OK == object->connect()); 00120 00121 lorawan_connect_t conn; 00122 EXPECT_TRUE(LORAWAN_STATUS_OK == object->connect(conn)); 00123 } 00124 00125 TEST_F(Test_LoRaWANInterface, disconnect) 00126 { 00127 EXPECT_TRUE(LORAWAN_STATUS_OK == object->disconnect()); 00128 } 00129 00130 TEST_F(Test_LoRaWANInterface, add_link_check_request) 00131 { 00132 EXPECT_TRUE(LORAWAN_STATUS_OK == object->add_link_check_request()); 00133 } 00134 00135 TEST_F(Test_LoRaWANInterface, remove_link_check_request) 00136 { 00137 object->remove_link_check_request(); 00138 } 00139 00140 TEST_F(Test_LoRaWANInterface, set_datarate) 00141 { 00142 EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_datarate(1)); 00143 } 00144 00145 TEST_F(Test_LoRaWANInterface, enable_adaptive_datarate) 00146 { 00147 EXPECT_TRUE(LORAWAN_STATUS_OK == object->enable_adaptive_datarate()); 00148 } 00149 00150 TEST_F(Test_LoRaWANInterface, disable_adaptive_datarate) 00151 { 00152 object->disable_adaptive_datarate(); 00153 } 00154 00155 TEST_F(Test_LoRaWANInterface, set_confirmed_msg_retries) 00156 { 00157 EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_confirmed_msg_retries(1)); 00158 } 00159 00160 TEST_F(Test_LoRaWANInterface, set_channel_plan) 00161 { 00162 lorawan_channelplan_t plan; 00163 EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_channel_plan(plan)); 00164 } 00165 00166 TEST_F(Test_LoRaWANInterface, get_channel_plan) 00167 { 00168 lorawan_channelplan_t plan; 00169 EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_channel_plan(plan)); 00170 } 00171 00172 TEST_F(Test_LoRaWANInterface, remove_channel_plan) 00173 { 00174 EXPECT_TRUE(LORAWAN_STATUS_OK == object->remove_channel_plan()); 00175 } 00176 00177 TEST_F(Test_LoRaWANInterface, remove_channel) 00178 { 00179 EXPECT_TRUE(LORAWAN_STATUS_OK == object->remove_channel(1)); 00180 } 00181 00182 TEST_F(Test_LoRaWANInterface, send) 00183 { 00184 EXPECT_TRUE(0 == object->send(1, NULL, 0, 0)); 00185 } 00186 00187 TEST_F(Test_LoRaWANInterface, receive) 00188 { 00189 EXPECT_TRUE(0 == object->receive(1, NULL, 0, 0)); 00190 00191 uint8_t port; 00192 int flags; 00193 EXPECT_TRUE(0 == object->receive(NULL, 0, port, flags)); 00194 } 00195 00196 TEST_F(Test_LoRaWANInterface, add_app_callbacks) 00197 { 00198 lorawan_app_callbacks_t cbs; 00199 EXPECT_TRUE(LORAWAN_STATUS_OK == object->add_app_callbacks(&cbs)); 00200 } 00201 00202 TEST_F(Test_LoRaWANInterface, set_device_class) 00203 { 00204 object->set_device_class(CLASS_A); 00205 } 00206 00207 TEST_F(Test_LoRaWANInterface, get_tx_metadata) 00208 { 00209 lorawan_tx_metadata data; 00210 EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_tx_metadata(data)); 00211 } 00212 00213 TEST_F(Test_LoRaWANInterface, get_rx_metadata) 00214 { 00215 lorawan_rx_metadata data; 00216 EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_rx_metadata(data)); 00217 } 00218 00219 TEST_F(Test_LoRaWANInterface, get_backoff_metadata) 00220 { 00221 int i; 00222 EXPECT_TRUE(LORAWAN_STATUS_OK == object->get_backoff_metadata(i)); 00223 } 00224 00225 TEST_F(Test_LoRaWANInterface, cancel_sending) 00226 { 00227 EXPECT_TRUE(LORAWAN_STATUS_OK == object->cancel_sending()); 00228 } 00229
Generated on Tue Aug 9 2022 00:37:22 by
1.7.2