takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Test_LoRaPHY.cpp Source File

Test_LoRaPHY.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 "LoRaPHY.h"
00020 
00021 #include "LoRaWANTimer_stub.h"
00022 
00023 class my_LoRaPHY : public LoRaPHY
00024 {
00025 public:
00026     my_LoRaPHY(){phy_params.adr_ack_delay = 1;}
00027 
00028     virtual ~my_LoRaPHY(){}
00029 
00030     loraphy_params_t &get_phy_params() {
00031         return phy_params;
00032     }
00033 };
00034 
00035 class my_radio : public LoRaRadio
00036 {
00037 public:
00038 
00039     virtual void init_radio(radio_events_t *events){};
00040 
00041     virtual void radio_reset(){};
00042 
00043     virtual void sleep(void){};
00044 
00045     virtual void standby(void){};
00046 
00047     virtual void set_rx_config (radio_modems_t modem, uint32_t bandwidth,
00048                                    uint32_t datarate, uint8_t coderate,
00049                                    uint32_t bandwidth_afc, uint16_t preamble_len,
00050                                    uint16_t symb_timeout, bool fix_len,
00051                                    uint8_t payload_len,
00052                                    bool crc_on, bool freq_hop_on, uint8_t hop_period,
00053                                    bool iq_inverted, bool rx_continuous){};
00054 
00055     virtual void set_tx_config(radio_modems_t modem, int8_t power, uint32_t fdev,
00056                                   uint32_t bandwidth, uint32_t datarate,
00057                                   uint8_t coderate, uint16_t preamble_len,
00058                                   bool fix_len, bool crc_on, bool freq_hop_on,
00059                                   uint8_t hop_period, bool iq_inverted, uint32_t timeout){};
00060 
00061     virtual void send(uint8_t *buffer, uint8_t size){};
00062 
00063     virtual void receive(void){};
00064 
00065     virtual void set_channel(uint32_t freq){};
00066 
00067     virtual uint32_t random(void){};
00068 
00069     virtual uint8_t get_status(void){return uint8_value;};
00070 
00071     virtual void set_max_payload_length(radio_modems_t modem, uint8_t max){};
00072 
00073     virtual void set_public_network(bool enable){};
00074 
00075     virtual uint32_t time_on_air(radio_modems_t modem, uint8_t pkt_len){};
00076 
00077     virtual bool perform_carrier_sense(radio_modems_t modem,
00078                                            uint32_t freq,
00079                                            int16_t rssi_threshold,
00080                                            uint32_t max_carrier_sense_time){ return bool_value;};
00081 
00082     virtual void start_cad(void){};
00083 
00084     virtual bool check_rf_frequency(uint32_t frequency){ return bool_value; };
00085 
00086     virtual void set_tx_continuous_wave(uint32_t freq, int8_t power, uint16_t time){};
00087 
00088     virtual void lock(void){};
00089 
00090     virtual void unlock(void){};
00091 
00092     bool bool_value;
00093     uint8_t uint8_value;
00094 };
00095 
00096 class Test_LoRaPHY : public testing::Test {
00097 protected:
00098     my_LoRaPHY *object;
00099 
00100     virtual void SetUp()
00101     {
00102         object = new my_LoRaPHY();
00103     }
00104 
00105     virtual void TearDown()
00106     {
00107         delete object;
00108     }
00109 };
00110 
00111 TEST_F(Test_LoRaPHY, initialize)
00112 {
00113     object->initialize(NULL);
00114 }
00115 
00116 TEST_F(Test_LoRaPHY, set_radio_instance)
00117 {
00118     my_radio radio;
00119     object->set_radio_instance(radio);
00120 }
00121 
00122 TEST_F(Test_LoRaPHY, put_radio_to_sleep)
00123 {
00124     my_radio radio;
00125     object->set_radio_instance(radio);
00126     object->put_radio_to_sleep();
00127 }
00128 
00129 TEST_F(Test_LoRaPHY, put_radio_to_standby)
00130 {
00131     my_radio radio;
00132     object->set_radio_instance(radio);
00133     object->put_radio_to_standby();
00134 }
00135 
00136 TEST_F(Test_LoRaPHY, handle_receive)
00137 {
00138     my_radio radio;
00139     object->set_radio_instance(radio);
00140     object->handle_receive();
00141 }
00142 
00143 TEST_F(Test_LoRaPHY, handle_send)
00144 {
00145     my_radio radio;
00146     object->set_radio_instance(radio);
00147     object->handle_send(NULL, 0);
00148 }
00149 
00150 TEST_F(Test_LoRaPHY, setup_public_network_mode)
00151 {
00152     my_radio radio;
00153     channel_params_t p;
00154     object->get_phy_params().channels.channel_list = &p;
00155     object->set_radio_instance(radio);
00156     object->setup_public_network_mode(false);
00157 }
00158 
00159 TEST_F(Test_LoRaPHY, get_radio_rng)
00160 {
00161     my_radio radio;
00162     object->set_radio_instance(radio);
00163     EXPECT_TRUE(0 != object->get_radio_rng());
00164 }
00165 
00166 TEST_F(Test_LoRaPHY, calculate_backoff)
00167 {
00168     channel_params_t p[1];
00169     p[0].band = 0;
00170     object->get_phy_params().channels.channel_list = p;
00171     band_t  b[1];
00172     object->get_phy_params().bands.table = b;
00173     object->calculate_backoff(false, false, false, 0, 10, 12);
00174 
00175     object->calculate_backoff(false, true, false, 0, 3600000 + 10, 12);
00176 
00177     object->calculate_backoff(false, false, true, 0, 3600000 + 36000000 + 10, 12);
00178 }
00179 
00180 TEST_F(Test_LoRaPHY, mask_bit_test)
00181 {
00182     uint16_t buf;
00183     EXPECT_TRUE(!object->mask_bit_test(&buf, 0));
00184 }
00185 
00186 TEST_F(Test_LoRaPHY, mask_bit_set)
00187 {
00188     uint16_t buf;
00189     object->mask_bit_set(&buf, 3);
00190 }
00191 
00192 TEST_F(Test_LoRaPHY, mask_bit_clear)
00193 {
00194     uint16_t buf;
00195     object->mask_bit_clear(&buf, 0);
00196 }
00197 
00198 TEST_F(Test_LoRaPHY, request_new_channel)
00199 {
00200     channel_params_t p;
00201     EXPECT_TRUE(0 == object->request_new_channel(1, &p));
00202 
00203     p.frequency = 0;
00204     object->get_phy_params().custom_channelplans_supported = true;
00205     uint16_t list;
00206     object->get_phy_params().channels.default_mask = &list;
00207     channel_params_t pp;
00208     object->get_phy_params().channels.channel_list = &pp;
00209     EXPECT_TRUE(0 == object->request_new_channel(1, &p));
00210 
00211     //Default
00212     p.frequency = 2;
00213     EXPECT_TRUE(0 == object->request_new_channel(1, &p));
00214 
00215     //Freq & DR invalid
00216     object->get_phy_params().max_channel_cnt = 2;
00217     EXPECT_TRUE(0 == object->request_new_channel(1, &p));
00218 
00219     //Freq invalid
00220     pp.frequency = 0;
00221     object->get_phy_params().default_max_datarate = 1;
00222     object->get_phy_params().max_tx_datarate = 8;
00223     p.dr_range.fields.max = 2;
00224     p.dr_range.fields.min = 0;
00225     object->get_phy_params().default_channel_cnt = 3;
00226     EXPECT_TRUE(2 == object->request_new_channel(0, &p));
00227 
00228     //DR invalid
00229     pp.frequency = 2;
00230     p.band = 0;
00231     object->get_phy_params().bands.size = 1;
00232     band_t  b;
00233     object->get_phy_params().bands.table = &b;
00234     b.higher_band_freq  = 5;
00235     b.lower_band_freq  = 1;
00236     p.dr_range.fields.max = 12;
00237     p.dr_range.fields.min = 1;
00238     EXPECT_TRUE(1 == object->request_new_channel(0, &p));
00239 
00240     //STATUS_OK
00241     p.dr_range.fields.max = 2;
00242     uint16_t list2[16];
00243     p.dr_range.fields.min = 0;
00244     object->get_phy_params().channels.mask = list2;
00245     EXPECT_TRUE(3 == object->request_new_channel(0, &p));
00246 }
00247 
00248 TEST_F(Test_LoRaPHY, set_last_tx_done)
00249 {
00250     channel_params_t p[1];
00251     p[0].band = 0;
00252     object->get_phy_params().channels.channel_list = p;
00253     band_t  b[1];
00254     object->get_phy_params().bands.table = b;
00255     object->set_last_tx_done(0, false, 0);
00256 
00257     object->set_last_tx_done(0, true, 0);
00258 }
00259 
00260 TEST_F(Test_LoRaPHY, restore_default_channels)
00261 {
00262     channel_params_t p[1];
00263     p[0].band = 0;
00264     object->get_phy_params().channels.channel_list = p;
00265     uint16_t m, dm;
00266     object->get_phy_params().channels.mask_size = 1;
00267     object->get_phy_params().channels.default_mask = &dm;
00268     object->get_phy_params().channels.mask = &m;
00269     object->restore_default_channels();
00270 }
00271 
00272 TEST_F(Test_LoRaPHY, apply_cf_list)
00273 {
00274     uint8_t list[16];
00275     object->apply_cf_list(list, 0);
00276 
00277     object->get_phy_params().cflist_supported = true;
00278     object->apply_cf_list(list, 0);
00279 
00280     object->get_phy_params().default_channel_cnt = 2;
00281     object->get_phy_params().cflist_channel_cnt = 0;
00282     object->get_phy_params().max_channel_cnt = 3;
00283 
00284     uint16_t mask[8];
00285     channel_params_t p[8];
00286     object->get_phy_params().channels.default_mask = mask;
00287     object->get_phy_params().channels.mask = mask;
00288     object->get_phy_params().channels.channel_list = p;
00289     object->apply_cf_list(list, 16);
00290 
00291     list[1] = 15;
00292     object->get_phy_params().cflist_channel_cnt = 1;
00293     object->apply_cf_list(list, 16);
00294 }
00295 
00296 TEST_F(Test_LoRaPHY, get_next_ADR)
00297 {
00298     int8_t i = 0;
00299     int8_t j = 0;
00300     uint32_t ctr = 0;
00301     object->get_phy_params().min_tx_datarate = 0;
00302     EXPECT_TRUE(!object->get_next_ADR(false, i, j, ctr));
00303 
00304     i = 1;
00305     object->get_phy_params().adr_ack_limit = 3;
00306     EXPECT_TRUE(!object->get_next_ADR(false, i, j, ctr));
00307 
00308     object->get_phy_params().adr_ack_limit = 3;
00309     ctr = 4;
00310     object->get_phy_params().max_tx_power = 2;
00311     object->get_phy_params().adr_ack_delay = 1;
00312     EXPECT_TRUE(object->get_next_ADR(true, i, j, ctr));
00313 
00314     ctr = 5;
00315     object->get_phy_params().adr_ack_delay = 2;
00316     EXPECT_TRUE(!object->get_next_ADR(true, i, j, ctr));
00317 }
00318 
00319 TEST_F(Test_LoRaPHY, rx_config)
00320 {
00321     my_radio radio;
00322     object->set_radio_instance(radio);
00323     uint8_t list;
00324     object->get_phy_params().datarates.table = &list;
00325     uint8_t list2;
00326     object->get_phy_params().payloads_with_repeater.table = &list2;
00327     rx_config_params_t  p;
00328     p.datarate  = 0;
00329     p.rx_slot  = RX_SLOT_WIN_1 ;
00330     channel_params_t pp[1];
00331     object->get_phy_params().channels.channel_list = pp;
00332     pp[0].rx1_frequency = 2;
00333     p.channel  = 0;
00334     uint8_t tab[8];
00335     object->get_phy_params().payloads.table = tab;
00336     object->get_phy_params().payloads_with_repeater.table = tab;
00337     EXPECT_TRUE(object->rx_config(&p));
00338 
00339     p.datarate  = DR_7;
00340     p.is_repeater_supported  = true;
00341     object->get_phy_params().fsk_supported = true;
00342     EXPECT_TRUE(object->rx_config(&p));
00343 }
00344 
00345 TEST_F(Test_LoRaPHY, compute_rx_win_params)
00346 {
00347     uint32_t list[1];
00348     list[0] = 0;
00349     object->get_phy_params().bandwidths.table = list;
00350     uint8_t list2;
00351     object->get_phy_params().datarates.table = &list2;
00352     rx_config_params_t  p;
00353     object->compute_rx_win_params(0, 0, 0, &p);
00354 
00355     p.datarate  = 0;
00356     list[0] = 125000;
00357     object->compute_rx_win_params(0, 0, 0, &p);
00358 
00359     list[0] = 250000;
00360     object->compute_rx_win_params(0, 0, 0, &p);
00361 
00362     list[0] = 500000;
00363     object->get_phy_params().fsk_supported = true;
00364     object->get_phy_params().max_rx_datarate = 0;
00365     object->compute_rx_win_params(0, 0, 0, &p);
00366 }
00367 
00368 TEST_F(Test_LoRaPHY, tx_config)
00369 {
00370     band_t  b;
00371     object->get_phy_params().bands.table = &b;
00372     channel_params_t pp;
00373     pp.band=0;
00374     object->get_phy_params().channels.channel_list = &pp;
00375     uint32_t list = 0;
00376     object->get_phy_params().bandwidths.table = &list;
00377     uint8_t list2;
00378     object->get_phy_params().datarates.table = &list2;
00379     my_radio radio;
00380     object->set_radio_instance(radio);
00381     tx_config_params_t p;
00382     p.channel=0;
00383     int8_t i;
00384     lorawan_time_t t;
00385     object->tx_config(&p, &i, &t);
00386 
00387     p.datarate = 8;
00388     object->get_phy_params().max_tx_datarate = 8;
00389     object->tx_config(&p, &i, &t);
00390 }
00391 
00392 TEST_F(Test_LoRaPHY, link_ADR_request)
00393 {
00394     adr_req_params_t p;
00395     uint8_t b[100];
00396     p.payload  = b;
00397     b[0] = 0x03;
00398     b[1] = 1;
00399     b[2] = 0;
00400     b[3] = 0;
00401     b[4] = 1 << 4;
00402     b[5] = 0x03;
00403     b[6] = 1;
00404     b[7] = 1;
00405     b[8] = 1;
00406     b[9] = 6 << 4;
00407     b[10] = 0x03;
00408     b[11] = 1;
00409     b[12] = 0xff;
00410     b[13] = 0xff;
00411     b[14] = 0;
00412     b[15] = 0;
00413     p.payload_size  = 16;
00414     int8_t i, j;
00415     uint8_t k, l;
00416     uint8_t t[5];
00417     t[0] = 0;
00418     object->get_phy_params().datarates.size = 1;
00419     object->get_phy_params().datarates.table = t;
00420     //Test without ADR payload does not make sense here.
00421 
00422     object->get_phy_params().max_channel_cnt = 2;
00423     channel_params_t li[4];
00424     object->get_phy_params().channels.channel_list = li;
00425     li[0].frequency = 0;
00426     li[1].frequency = 5;
00427     EXPECT_TRUE(4 == object->link_ADR_request(&p, &i, &j, &k, &l));
00428 
00429     t[0] = 3;
00430     //verify adr with p.adr_enabled = false
00431     EXPECT_TRUE(0 == object->link_ADR_request(&p, &i, &j, &k, &l));
00432 
00433     p.current_nb_rep  = 0;
00434     EXPECT_TRUE(0 == object->link_ADR_request(&p, &i, &j, &k, &l));
00435 
00436     p.adr_enabled  = true;
00437     li[0].dr_range.value = 0xff;
00438     object->get_phy_params().min_tx_datarate = DR_3;
00439     object->get_phy_params().max_tx_datarate = DR_8;
00440 
00441     //verify adr with status != 0
00442     EXPECT_TRUE(0 == object->link_ADR_request(&p, &i, &j, &k, &l));
00443 
00444     object->get_phy_params().max_tx_power = 2;
00445     object->get_phy_params().min_tx_power = 6;
00446     //verify adr with status != 0
00447     EXPECT_TRUE(4 == object->link_ADR_request(&p, &i, &j, &k, &l));
00448 
00449     object->get_phy_params().min_tx_datarate = DR_0;
00450     li[0].dr_range.value = 0xf0;
00451     EXPECT_TRUE(6 == object->link_ADR_request(&p, &i, &j, &k, &l));
00452 
00453     li[1].dr_range.fields.min = DR_0;
00454     li[1].dr_range.fields.max = DR_13;
00455     b[4] = 6 << 4;
00456     p.payload_size  = 5;
00457     EXPECT_TRUE(7 == object->link_ADR_request(&p, &i, &j, &k, &l));
00458 
00459     uint16_t mask[2];
00460     object->get_phy_params().channels.mask = mask;
00461     object->get_phy_params().channels.mask_size = 2;
00462     EXPECT_TRUE(7 == object->link_ADR_request(&p, &i, &j, &k, &l));
00463 
00464     li[0].dr_range.value = 0xff;
00465     object->get_phy_params().max_channel_cnt = 0;
00466     EXPECT_TRUE(5 == object->link_ADR_request(&p, &i, &j, &k, &l));
00467 
00468     b[0] = 0x03;
00469     b[1] = 1;
00470     b[2] = 0;
00471     b[3] = 0;
00472     b[4] = 0;
00473     t[0] = 0;
00474     object->get_phy_params().datarates.size = 1;
00475     object->get_phy_params().datarates.table = t;
00476     //Test without ADR payload does not make sense here.
00477 
00478     object->get_phy_params().max_channel_cnt = 2;
00479     li[0].frequency = 0;
00480     li[1].frequency = 5;
00481     EXPECT_TRUE(4 == object->link_ADR_request(&p, &i, &j, &k, &l));
00482 }
00483 
00484 TEST_F(Test_LoRaPHY, accept_rx_param_setup_req)
00485 {
00486     my_radio radio;
00487     object->set_radio_instance(radio);
00488     rx_param_setup_req_t req;
00489     EXPECT_TRUE(0 == object->accept_rx_param_setup_req(&req));
00490 }
00491 
00492 TEST_F(Test_LoRaPHY, accept_tx_param_setup_req)
00493 {
00494     my_radio radio;
00495     object->set_radio_instance(radio);
00496     object->get_phy_params().accept_tx_param_setup_req = true;
00497     EXPECT_TRUE(object->accept_tx_param_setup_req(0, 0));
00498 }
00499 
00500 TEST_F(Test_LoRaPHY, dl_channel_request)
00501 {
00502     EXPECT_TRUE(0 == object->dl_channel_request(0, 0));
00503 
00504     object->get_phy_params().dl_channel_req_supported = true;
00505     object->get_phy_params().bands.size = 1;
00506     band_t  t[1];
00507     object->get_phy_params().bands.table = t;
00508     channel_params_t p[4];
00509     object->get_phy_params().channels.channel_list = p;
00510 
00511     p[0].frequency = 0;
00512     EXPECT_TRUE(0 == object->dl_channel_request(0, 1));
00513 
00514     t[0].higher_band_freq  = 19;
00515     t[0].lower_band_freq  = 0;
00516     p[0].frequency = 1;
00517     EXPECT_TRUE(3 == object->dl_channel_request(0, 1));
00518 }
00519 
00520 TEST_F(Test_LoRaPHY, get_alternate_DR)
00521 {
00522     EXPECT_TRUE(0 == object->get_alternate_DR(0));
00523 
00524     object->get_phy_params().default_max_datarate = 5;
00525     object->get_phy_params().min_tx_datarate = 4;
00526     EXPECT_TRUE(5 == object->get_alternate_DR(1));
00527 
00528     object->get_phy_params().default_max_datarate = 6;
00529     object->get_phy_params().min_tx_datarate = 4;
00530     EXPECT_TRUE(5 == object->get_alternate_DR(2));
00531 }
00532 
00533 TEST_F(Test_LoRaPHY, set_next_channel)
00534 {
00535     channel_selection_params_t p;
00536     uint8_t ch;
00537     lorawan_time_t t1;
00538     lorawan_time_t t2;
00539     p.aggregate_timeoff = 10000;
00540     EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(&p, &ch, &t1, &t2));
00541 
00542     uint16_t list[16];
00543     list[4] = 1;
00544     memcpy(list, "\0", 16);
00545     object->get_phy_params().channels.mask = list;
00546     object->get_phy_params().channels.mask_size = 1;
00547     p.aggregate_timeoff = 10000;
00548     EXPECT_TRUE(LORAWAN_STATUS_DUTYCYCLE_RESTRICTED == object->set_next_channel(&p, &ch, &t1, &t2));
00549 
00550     LoRaWANTimer_stub::time_value = 20000;
00551     EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(&p, &ch, &t1, &t2));
00552 
00553     p.joined = false;
00554     p.dc_enabled = false;
00555     band_t  b[4];
00556     object->get_phy_params().bands.size = 2;
00557     object->get_phy_params().bands.table = &b;
00558     b[0].off_time  = 0;
00559     b[1].off_time  = 9999999;
00560     list[4] = 0;
00561     object->get_phy_params().channels.mask_size = 128;
00562     p.current_datarate = DR_1;
00563     object->get_phy_params().max_channel_cnt = 4;
00564     EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(&p, &ch, &t1, &t2));
00565 
00566     p.dc_enabled = true;
00567     EXPECT_TRUE(LORAWAN_STATUS_NO_CHANNEL_FOUND == object->set_next_channel(&p, &ch, &t1, &t2));
00568 
00569     list[4] = 1;
00570     p.joined = true;
00571     p.dc_enabled = false;
00572     channel_params_t l[4];
00573     l[0].dr_range.value = 0xff;
00574     l[1].dr_range.value = 0xff;
00575     l[2].dr_range.value = 0xf0;
00576     l[3].dr_range.value = 0xf0;
00577     l[2].band = 2;
00578     l[3].band = 3;
00579     object->get_phy_params().channels.channel_list = l;
00580     list[0] = 0xFF;
00581     b[2].off_time  = 9999999;
00582     b[3].off_time  = 0;
00583     EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(&p, &ch, &t1, &t2));
00584 
00585     b[0].off_time  = 10000;
00586     LoRaWANTimer_stub::time_value = 2000;
00587     p.aggregate_timeoff = 1000;
00588     p.dc_enabled = true;
00589     EXPECT_TRUE(LORAWAN_STATUS_OK == object->set_next_channel(&p, &ch, &t1, &t2));
00590 }
00591 
00592 TEST_F(Test_LoRaPHY, add_channel)
00593 {
00594     uint16_t list[16];
00595     object->get_phy_params().channels.mask = list;
00596     object->get_phy_params().channels.default_mask = list;
00597     channel_params_t p;
00598     EXPECT_TRUE(LORAWAN_STATUS_PARAMETER_INVALID == object->add_channel(&p, 0));
00599 
00600     object->get_phy_params().custom_channelplans_supported = true;
00601     object->get_phy_params().max_channel_cnt = 2;
00602     object->get_phy_params().min_tx_datarate = 0;
00603     object->get_phy_params().max_tx_datarate = 13;
00604     p.dr_range.fields.min = 6;
00605     p.dr_range.fields.max = 1;
00606     EXPECT_TRUE(LORAWAN_STATUS_FREQ_AND_DR_INVALID == object->add_channel(&p, 0));
00607 }
00608 
00609 TEST_F(Test_LoRaPHY, remove_channel)
00610 {
00611     channel_params_t pp;
00612     pp.band=0;
00613     object->get_phy_params().channels.channel_list = &pp;
00614     uint16_t list[16];
00615     list[0] = 1;
00616     object->get_phy_params().channels.mask = list;
00617     object->get_phy_params().channels.default_mask = list;
00618     EXPECT_TRUE(false == object->remove_channel(0));
00619 
00620     list[0] = 0;
00621     EXPECT_TRUE(false == object->remove_channel(0));
00622 
00623     object->get_phy_params().channels.mask_size = 1;
00624     object->get_phy_params().max_channel_cnt = 0;
00625     EXPECT_TRUE(false == object->remove_channel(0));
00626 
00627     object->get_phy_params().max_channel_cnt = 1;
00628     EXPECT_TRUE(true == object->remove_channel(0));
00629 }
00630 
00631 TEST_F(Test_LoRaPHY, set_tx_cont_mode)
00632 {
00633     channel_params_t pp;
00634     pp.band=0;
00635     object->get_phy_params().channels.channel_list = &pp;
00636     band_t  b;
00637     object->get_phy_params().bands.table = &b;
00638     my_radio radio;
00639     object->set_radio_instance(radio);
00640 
00641     cw_mode_params_t  p;
00642     p.max_eirp  = 0;
00643     p.channel =0;
00644     object->set_tx_cont_mode(&p);
00645 
00646     p.max_eirp  = 1;
00647     p.antenna_gain  = 1;
00648     object->set_tx_cont_mode(&p, 1);
00649 }
00650 
00651 TEST_F(Test_LoRaPHY, apply_DR_offset)
00652 {
00653     EXPECT_TRUE(0 == object->apply_DR_offset(0, 0));
00654 
00655     object->get_phy_params().min_tx_datarate = 1;
00656     EXPECT_TRUE(1 == object->apply_DR_offset(0, 2));
00657 }
00658 
00659 TEST_F(Test_LoRaPHY, reset_to_default_values)
00660 {
00661     loramac_protocol_params p;
00662     object->reset_to_default_values(&p);
00663 
00664     object->reset_to_default_values(&p, true);
00665 }
00666 
00667 TEST_F(Test_LoRaPHY, get_next_lower_tx_datarate)
00668 {
00669     EXPECT_TRUE(DR_0 == object->get_next_lower_tx_datarate(DR_2));
00670 
00671     object->get_phy_params().ul_dwell_time_setting = 1;
00672     object->get_phy_params().dwell_limit_datarate = DR_1;
00673     EXPECT_TRUE(DR_1 == object->get_next_lower_tx_datarate(DR_2));
00674 }
00675 
00676 TEST_F(Test_LoRaPHY, get_minimum_rx_datarate)
00677 {
00678     EXPECT_TRUE(DR_0 == object->get_minimum_rx_datarate());
00679 
00680     object->get_phy_params().dl_dwell_time_setting = 1;
00681     object->get_phy_params().dwell_limit_datarate = DR_1;
00682     EXPECT_TRUE(DR_1 == object->get_minimum_rx_datarate());
00683 }
00684 
00685 TEST_F(Test_LoRaPHY, get_minimum_tx_datarate)
00686 {
00687     EXPECT_TRUE(DR_0 == object->get_minimum_tx_datarate());
00688 
00689     object->get_phy_params().ul_dwell_time_setting = 1;
00690     object->get_phy_params().dwell_limit_datarate = DR_1;
00691     EXPECT_TRUE(DR_1 == object->get_minimum_tx_datarate());
00692 }
00693 
00694 TEST_F(Test_LoRaPHY, get_default_tx_datarate)
00695 {
00696     EXPECT_TRUE(0 == object->get_default_tx_datarate());
00697 }
00698 
00699 TEST_F(Test_LoRaPHY, get_default_max_tx_datarate)
00700 {
00701     EXPECT_TRUE(DR_0 == object->get_default_max_tx_datarate());
00702 }
00703 
00704 TEST_F(Test_LoRaPHY, get_default_tx_power)
00705 {
00706     EXPECT_TRUE(0 == object->get_default_tx_power());
00707 }
00708 
00709 TEST_F(Test_LoRaPHY, get_max_payload)
00710 {
00711     uint8_t list=8;
00712     object->get_phy_params().payloads.table = &list;
00713     object->get_phy_params().payloads_with_repeater.table = &list;
00714     EXPECT_TRUE(8 == object->get_max_payload(0));
00715 
00716     EXPECT_TRUE(8 == object->get_max_payload(0, true));
00717 }
00718 
00719 TEST_F(Test_LoRaPHY, get_maximum_frame_counter_gap)
00720 {
00721     EXPECT_TRUE(0 == object->get_maximum_frame_counter_gap());
00722 }
00723 
00724 TEST_F(Test_LoRaPHY, get_ack_timeout)
00725 {
00726     EXPECT_TRUE(0 == object->get_ack_timeout());
00727 }
00728 
00729 TEST_F(Test_LoRaPHY, get_default_rx2_frequency)
00730 {
00731     EXPECT_TRUE(0 == object->get_default_rx2_frequency());
00732 }
00733 
00734 TEST_F(Test_LoRaPHY, get_default_rx2_datarate)
00735 {
00736     EXPECT_TRUE(0 == object->get_default_rx2_datarate());
00737 }
00738 
00739 TEST_F(Test_LoRaPHY, get_channel_mask)
00740 {
00741     EXPECT_TRUE(0 == object->get_channel_mask());
00742     EXPECT_TRUE(0 == object->get_channel_mask(true));
00743 }
00744 
00745 TEST_F(Test_LoRaPHY, get_max_nb_channels)
00746 {
00747     EXPECT_TRUE(0 == object->get_max_nb_channels());
00748 }
00749 
00750 TEST_F(Test_LoRaPHY, get_phy_channels)
00751 {
00752     EXPECT_TRUE(0 == object->get_phy_channels());
00753 }
00754 
00755 TEST_F(Test_LoRaPHY, is_custom_channel_plan_supported)
00756 {
00757     EXPECT_TRUE(false == object->is_custom_channel_plan_supported());
00758 }
00759 
00760 TEST_F(Test_LoRaPHY, verify_rx_datarate)
00761 {
00762     EXPECT_TRUE(false == object->verify_rx_datarate(0));
00763 
00764     object->get_phy_params().datarates.size = 1;
00765     uint8_t t[1];
00766     t[0] = 2;
00767     object->get_phy_params().datarates.table = t;
00768     object->get_phy_params().dl_dwell_time_setting = 0;
00769 
00770     EXPECT_TRUE(true == object->verify_rx_datarate(0));
00771 
00772     object->get_phy_params().dl_dwell_time_setting = 1;
00773     object->get_phy_params().min_rx_datarate = 0;
00774 
00775     EXPECT_TRUE(true == object->verify_rx_datarate(0));
00776 }
00777 
00778 TEST_F(Test_LoRaPHY, verify_tx_datarate)
00779 {
00780     EXPECT_TRUE(false == object->verify_tx_datarate(0));
00781 
00782     object->get_phy_params().datarates.size = 1;
00783     uint8_t t[1];
00784     t[0] = 2;
00785     object->get_phy_params().datarates.table = t;
00786     object->get_phy_params().ul_dwell_time_setting = 0;
00787     EXPECT_TRUE(true == object->verify_tx_datarate(0));
00788 
00789     object->get_phy_params().ul_dwell_time_setting = 1;
00790     EXPECT_TRUE(true == object->verify_tx_datarate(0));
00791 
00792     object->get_phy_params().ul_dwell_time_setting = 1;
00793     EXPECT_TRUE(true == object->verify_tx_datarate(0, true));
00794 }
00795 
00796 TEST_F(Test_LoRaPHY, verify_tx_power)
00797 {
00798     EXPECT_TRUE(true == object->verify_tx_power(0));
00799 }
00800 
00801 TEST_F(Test_LoRaPHY, verify_duty_cycle)
00802 {
00803     EXPECT_TRUE(true == object->verify_duty_cycle(false));
00804 
00805     EXPECT_TRUE(false == object->verify_duty_cycle(true));
00806 }
00807 
00808 TEST_F(Test_LoRaPHY, verify_nb_join_trials)
00809 {
00810     EXPECT_TRUE(false == object->verify_nb_join_trials(0));
00811     EXPECT_TRUE(true == object->verify_nb_join_trials(100));
00812 }
00813 
00814