takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaPHY_stub.cpp Source File

LoRaPHY_stub.cpp

00001 /*
00002  * Copyright (c) , 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 
00019 #include <stdbool.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022 #include <stdint.h>
00023 
00024 #include "LoRaPHY.h"
00025 #include "LoRaPHY_stub.h"
00026 
00027 LoRaRadio *LoRaPHY_stub::radio = NULL;
00028 uint32_t LoRaPHY_stub::uint32_value = 0;
00029 uint16_t LoRaPHY_stub::uint16_value = 0;
00030 uint8_t LoRaPHY_stub::uint8_value = 0;
00031 int8_t LoRaPHY_stub::int8_value = 0;
00032 int LoRaPHY_stub::int_value = 0;
00033 double LoRaPHY_stub::double_value = 0;
00034 lorawan_status_t LoRaPHY_stub::lorawan_status_value = LORAWAN_STATUS_OK;
00035 channel_params_t *LoRaPHY_stub::channel_params_ptr = NULL;
00036 uint8_t LoRaPHY_stub::bool_counter = 0;
00037 bool LoRaPHY_stub::bool_table[20] = {};
00038 uint8_t LoRaPHY_stub::linkAdrNbBytesParsed = 0;
00039 uint8_t LoRaPHY_stub::ch_mask_value = 0;
00040 uint8_t LoRaPHY_stub::adr_parse_count = 0;
00041 
00042 LoRaPHY::LoRaPHY()
00043     : _radio(LoRaPHY_stub::radio)
00044 {
00045 }
00046 
00047 LoRaPHY::~LoRaPHY()
00048 {
00049 }
00050 
00051 void LoRaPHY::initialize(LoRaWANTimeHandler *lora_time)
00052 {
00053 }
00054 
00055 bool LoRaPHY::mask_bit_test(const uint16_t *mask, unsigned bit)
00056 {
00057     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00058 }
00059 
00060 void LoRaPHY::mask_bit_set(uint16_t *mask, unsigned bit)
00061 {
00062 }
00063 
00064 void LoRaPHY::mask_bit_clear(uint16_t *mask, unsigned bit)
00065 {
00066 }
00067 
00068 void LoRaPHY::set_radio_instance(LoRaRadio &radio)
00069 {
00070 }
00071 
00072 void LoRaPHY::put_radio_to_sleep()
00073 {
00074 }
00075 
00076 void LoRaPHY::put_radio_to_standby()
00077 {
00078 }
00079 
00080 void LoRaPHY::setup_public_network_mode(bool set)
00081 {
00082 }
00083 
00084 void LoRaPHY::handle_receive(void)
00085 {
00086 }
00087 
00088 uint32_t LoRaPHY::get_radio_rng()
00089 {
00090     return LoRaPHY_stub::uint32_value;
00091 }
00092 
00093 void LoRaPHY::handle_send(uint8_t *buf, uint8_t size)
00094 {
00095 }
00096 
00097 uint8_t LoRaPHY::request_new_channel(int8_t channel_id, channel_params_t *new_channel)
00098 {
00099     return LoRaPHY_stub::uint8_value;
00100 }
00101 
00102 int32_t LoRaPHY::get_random(int32_t min, int32_t max)
00103 {
00104     return LoRaPHY_stub::uint32_value;
00105 }
00106 
00107 bool LoRaPHY::verify_channel_DR(uint16_t *channel_mask, int8_t dr)
00108 {
00109     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00110 }
00111 
00112 bool LoRaPHY::val_in_range(int8_t value, int8_t min, int8_t max)
00113 {
00114     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00115 }
00116 
00117 bool LoRaPHY::disable_channel(uint16_t *channel_mask, uint8_t id,
00118                               uint8_t max_channels_num)
00119 {
00120     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00121 }
00122 
00123 uint8_t LoRaPHY::count_bits(uint16_t mask, uint8_t nbBits)
00124 {
00125     return LoRaPHY_stub::uint8_value;
00126 }
00127 
00128 uint8_t LoRaPHY::num_active_channels(uint16_t *channel_mask, uint8_t start_idx,
00129                                      uint8_t stop_idx)
00130 {
00131     return LoRaPHY_stub::uint8_value;
00132 }
00133 
00134 void LoRaPHY::copy_channel_mask(uint16_t *dest_mask, uint16_t *src_mask, uint8_t len)
00135 {
00136     if ((dest_mask != NULL) && (src_mask != NULL)) {
00137         for (uint8_t i = 0; i < len; i++) {
00138             dest_mask[i] = src_mask[i];
00139         }
00140     }
00141 }
00142 
00143 void LoRaPHY::set_last_tx_done(uint8_t channel, bool joined, lorawan_time_t last_tx_done_time)
00144 {
00145 }
00146 
00147 lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
00148                                             band_t  *bands, uint8_t nb_bands)
00149 {
00150     return LoRaPHY_stub::uint32_value;
00151 }
00152 
00153 uint8_t LoRaPHY::parse_link_ADR_req(const uint8_t *payload,
00154                                     link_adr_params_t *params)
00155 {
00156     params->ch_mask_ctrl = LoRaPHY_stub::ch_mask_value;
00157 
00158     if (LoRaPHY_stub::adr_parse_count) {
00159         return --LoRaPHY_stub::adr_parse_count;
00160     }
00161 
00162     return LoRaPHY_stub::uint8_value;
00163 }
00164 
00165 uint8_t LoRaPHY::verify_link_ADR_req(verify_adr_params_t *verify_params,
00166                                      int8_t *dr, int8_t *tx_pow, uint8_t *nb_rep)
00167 {
00168     return LoRaPHY_stub::uint8_value;
00169 }
00170 
00171 void LoRaPHY::get_rx_window_params(double t_symb, uint8_t min_rx_symb,
00172                                    uint32_t rx_error, uint32_t wakeup_time,
00173                                    uint32_t *window_timeout, int32_t *window_offset)
00174 {
00175 }
00176 
00177 int8_t LoRaPHY::compute_tx_power(int8_t tx_power_idx, float max_eirp,
00178                                  float antenna_gain)
00179 {
00180     return LoRaPHY_stub::int8_value;
00181 }
00182 
00183 
00184 int8_t LoRaPHY::get_next_lower_dr(int8_t dr, int8_t min_dr)
00185 {
00186     return LoRaPHY_stub::int8_value;
00187 }
00188 
00189 uint8_t LoRaPHY::get_bandwidth(uint8_t dr)
00190 {
00191     return LoRaPHY_stub::uint8_value;
00192 }
00193 
00194 uint8_t LoRaPHY::enabled_channel_count(uint8_t datarate,
00195                                        const uint16_t *channel_mask,
00196                                        uint8_t *channel_indices,
00197                                        uint8_t *delayTx)
00198 {
00199     return LoRaPHY_stub::uint8_value;
00200 }
00201 
00202 bool LoRaPHY::is_datarate_supported(const int8_t datarate) const
00203 {
00204     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00205 }
00206 
00207 void LoRaPHY::reset_to_default_values(loramac_protocol_params *params, bool init)
00208 {
00209 }
00210 
00211 int8_t LoRaPHY::get_next_lower_tx_datarate(int8_t datarate)
00212 {
00213     return LoRaPHY_stub::int8_value;
00214 }
00215 
00216 uint8_t LoRaPHY::get_minimum_rx_datarate()
00217 {
00218     return LoRaPHY_stub::uint8_value;
00219 }
00220 
00221 uint8_t LoRaPHY::get_minimum_tx_datarate()
00222 {
00223     return LoRaPHY_stub::uint8_value;
00224 }
00225 
00226 uint8_t LoRaPHY::get_default_tx_datarate()
00227 {
00228     return LoRaPHY_stub::uint8_value;
00229 }
00230 
00231 uint8_t  LoRaPHY::get_default_max_tx_datarate()
00232 {
00233     return LoRaPHY_stub::uint8_value;
00234 }
00235 
00236 uint8_t LoRaPHY::get_default_tx_power()
00237 {
00238     return LoRaPHY_stub::uint8_value;
00239 }
00240 
00241 uint8_t LoRaPHY::get_max_payload(uint8_t datarate, bool use_repeater)
00242 {
00243     return LoRaPHY_stub::uint8_value;
00244 }
00245 
00246 uint16_t LoRaPHY::get_maximum_frame_counter_gap()
00247 {
00248     return LoRaPHY_stub::uint16_value;
00249 }
00250 
00251 uint32_t LoRaPHY::get_ack_timeout()
00252 {
00253     return LoRaPHY_stub::uint32_value;
00254 }
00255 
00256 uint32_t LoRaPHY::get_default_rx2_frequency()
00257 {
00258     return LoRaPHY_stub::uint32_value;
00259 }
00260 
00261 uint8_t LoRaPHY::get_default_rx2_datarate()
00262 {
00263     return phy_params.rx_window2_datarate;
00264 }
00265 
00266 uint16_t *LoRaPHY::get_channel_mask(bool get_default)
00267 {
00268     return &LoRaPHY_stub::uint16_value;
00269 }
00270 
00271 uint8_t LoRaPHY::get_max_nb_channels()
00272 {
00273     return LoRaPHY_stub::uint8_value;
00274 }
00275 
00276 channel_params_t *LoRaPHY::get_phy_channels()
00277 {
00278     return LoRaPHY_stub::channel_params_ptr;
00279 }
00280 
00281 bool LoRaPHY::is_custom_channel_plan_supported()
00282 {
00283     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00284 }
00285 
00286 void LoRaPHY::restore_default_channels()
00287 {
00288 }
00289 
00290 bool LoRaPHY::verify_rx_datarate(uint8_t datarate)
00291 {
00292     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00293 }
00294 
00295 bool LoRaPHY::verify_tx_datarate(uint8_t datarate, bool use_default)
00296 {
00297     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00298 }
00299 
00300 bool LoRaPHY::verify_tx_power(uint8_t tx_power)
00301 {
00302     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00303 }
00304 
00305 bool LoRaPHY::verify_duty_cycle(bool cycle)
00306 {
00307     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00308 }
00309 
00310 bool LoRaPHY::verify_nb_join_trials(uint8_t nb_join_trials)
00311 {
00312     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00313 }
00314 
00315 void LoRaPHY::apply_cf_list(const uint8_t *payload, uint8_t size)
00316 {
00317 }
00318 
00319 
00320 bool LoRaPHY::get_next_ADR(bool restore_channel_mask, int8_t &dr_out,
00321                            int8_t &tx_power_out, uint32_t &adr_ack_cnt)
00322 {
00323     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00324 }
00325 
00326 void LoRaPHY::compute_rx_win_params(int8_t datarate, uint8_t min_rx_symbols,
00327                                     uint32_t rx_error,
00328                                     rx_config_params_t  *rx_conf_params)
00329 {
00330 }
00331 
00332 bool LoRaPHY::rx_config(rx_config_params_t  *rx_conf)
00333 {
00334     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00335 }
00336 
00337 bool LoRaPHY::tx_config(tx_config_params_t *tx_conf, int8_t *tx_power,
00338                         lorawan_time_t *tx_toa)
00339 {
00340     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00341 }
00342 
00343 uint8_t LoRaPHY::link_ADR_request(adr_req_params_t *link_adr_req,
00344                                   int8_t *dr_out, int8_t *tx_power_out,
00345                                   uint8_t *nb_rep_out, uint8_t *nb_bytes_processed)
00346 {
00347     *nb_bytes_processed = LoRaPHY_stub::linkAdrNbBytesParsed;
00348     return LoRaPHY_stub::uint8_value;
00349 }
00350 
00351 uint8_t LoRaPHY::accept_rx_param_setup_req(rx_param_setup_req_t *params)
00352 {
00353     return LoRaPHY_stub::uint8_value;
00354 }
00355 
00356 bool LoRaPHY::accept_tx_param_setup_req(uint8_t ul_dwell_time, uint8_t dl_dwell_time)
00357 {
00358     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00359 }
00360 
00361 int LoRaPHY::lookup_band_for_frequency(uint32_t freq) const
00362 {
00363     return LoRaPHY_stub::int_value;
00364 }
00365 
00366 bool LoRaPHY::verify_frequency_for_band(uint32_t freq, uint8_t band) const
00367 {
00368     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00369 }
00370 
00371 uint8_t LoRaPHY::dl_channel_request(uint8_t channel_id, uint32_t rx1_frequency)
00372 {
00373     return LoRaPHY_stub::uint8_value;
00374 }
00375 
00376 int8_t LoRaPHY::get_alternate_DR(uint8_t nb_trials)
00377 {
00378     return LoRaPHY_stub::int8_value;
00379 }
00380 
00381 void LoRaPHY::calculate_backoff(bool joined, bool last_tx_was_join_req, bool dc_enabled, uint8_t channel,
00382                                 lorawan_time_t elapsed_time, lorawan_time_t tx_toa)
00383 {
00384 }
00385 
00386 lorawan_status_t LoRaPHY::set_next_channel(channel_selection_params_t *params,
00387                                            uint8_t *channel, lorawan_time_t *time,
00388                                            lorawan_time_t *aggregate_timeoff)
00389 {
00390     return LoRaPHY_stub::lorawan_status_value;
00391 }
00392 
00393 lorawan_status_t LoRaPHY::add_channel(const channel_params_t *new_channel,
00394                                       uint8_t id)
00395 {
00396     return LoRaPHY_stub::lorawan_status_value;
00397 }
00398 
00399 bool LoRaPHY::remove_channel(uint8_t channel_id)
00400 {
00401     return LoRaPHY_stub::bool_table[LoRaPHY_stub::bool_counter++];
00402 }
00403 
00404 void LoRaPHY::set_tx_cont_mode(cw_mode_params_t  *params, uint32_t given_frequency)
00405 {
00406 }
00407 
00408 uint8_t LoRaPHY::apply_DR_offset(int8_t dr, int8_t dr_offset)
00409 {
00410     return LoRaPHY_stub::uint8_value;
00411 }
00412 
00413