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.
LoRaMac_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 #include <stdlib.h> 00019 #include "LoRaMac.h" 00020 #include "LoRaMac_stub.h" 00021 00022 using namespace events; 00023 using namespace mbed; 00024 00025 int LoRaMac_stub::bool_false_counter = 0; 00026 int LoRaMac_stub::bool_true_counter = 0; 00027 bool LoRaMac_stub::bool_value = false; 00028 int LoRaMac_stub::int_value = 0; 00029 rx_slot_t LoRaMac_stub::slot_value = RX_SLOT_WIN_1 ; 00030 lorawan_status_t LoRaMac_stub::status_value = LORAWAN_STATUS_OK; 00031 loramac_mcps_confirm_t *LoRaMac_stub::mcps_conf_ptr = NULL; 00032 loramac_mcps_indication_t *LoRaMac_stub::mcps_ind_ptr = NULL; 00033 loramac_mlme_confirm_t *LoRaMac_stub::mlme_conf_ptr = NULL; 00034 loramac_mlme_indication_t *LoRaMac_stub::mlme_ind_ptr = NULL; 00035 device_class_t LoRaMac_stub::dev_class_value = CLASS_A; 00036 mbed::Callback<void(void)> LoRaMac_stub::_ack_expiry_handler_for_class_c = NULL; 00037 mbed::Callback<void(void)> LoRaMac_stub::_scheduling_failure_handler = NULL; 00038 00039 00040 LoRaMac::LoRaMac() 00041 : _lora_time(), 00042 _lora_phy(NULL), 00043 _mac_commands(), 00044 _channel_plan(), 00045 _lora_crypto(), 00046 _ev_queue(NULL), 00047 _mcps_indication(), 00048 _mcps_confirmation(), 00049 _mlme_indication(), 00050 _mlme_confirmation(), 00051 _is_nwk_joined(false), 00052 _continuous_rx2_window_open(false), 00053 _device_class(CLASS_A) 00054 {} 00055 00056 LoRaMac::~LoRaMac() 00057 { 00058 } 00059 00060 const loramac_mcps_confirm_t *LoRaMac::get_mcps_confirmation() const 00061 { 00062 return LoRaMac_stub::mcps_conf_ptr; 00063 } 00064 00065 const loramac_mcps_indication_t *LoRaMac::get_mcps_indication() const 00066 { 00067 return LoRaMac_stub::mcps_ind_ptr; 00068 } 00069 00070 const loramac_mlme_confirm_t *LoRaMac::get_mlme_confirmation() const 00071 { 00072 return LoRaMac_stub::mlme_conf_ptr; 00073 } 00074 00075 const loramac_mlme_indication_t *LoRaMac::get_mlme_indication() const 00076 { 00077 return LoRaMac_stub::mlme_ind_ptr; 00078 } 00079 00080 void LoRaMac::post_process_mlme_request() 00081 { 00082 } 00083 00084 void LoRaMac::post_process_mcps_req() 00085 { 00086 } 00087 00088 void LoRaMac::post_process_mcps_ind() 00089 { 00090 } 00091 00092 void LoRaMac::post_process_mlme_ind() 00093 { 00094 } 00095 00096 lorawan_time_t LoRaMac::get_current_time(void) 00097 { 00098 } 00099 00100 rx_slot_t LoRaMac::get_current_slot(void) 00101 { 00102 return LoRaMac_stub::slot_value; 00103 } 00104 00105 void LoRaMac::handle_join_accept_frame(const uint8_t *payload, uint16_t size) 00106 { 00107 } 00108 00109 void LoRaMac::check_frame_size(uint16_t size) 00110 { 00111 } 00112 00113 bool LoRaMac::message_integrity_check(const uint8_t *const payload, 00114 const uint16_t size, 00115 uint8_t *const ptr_pos, 00116 uint32_t address, 00117 uint32_t *downlink_counter, 00118 const uint8_t *nwk_skey) 00119 { 00120 if (LoRaMac_stub::bool_false_counter) { 00121 LoRaMac_stub::bool_false_counter--; 00122 return false; 00123 } 00124 if (LoRaMac_stub::bool_true_counter) { 00125 LoRaMac_stub::bool_true_counter--; 00126 return true; 00127 } 00128 00129 return LoRaMac_stub::bool_value; 00130 } 00131 00132 void LoRaMac::extract_data_and_mac_commands(const uint8_t *payload, 00133 uint16_t size, 00134 uint8_t fopts_len, 00135 uint8_t *nwk_skey, 00136 uint8_t *app_skey, 00137 uint32_t address, 00138 uint32_t downlink_counter, 00139 int16_t rssi, 00140 int8_t snr) 00141 { 00142 } 00143 00144 void LoRaMac::extract_mac_commands_only(const uint8_t *payload, 00145 int8_t snr, 00146 uint8_t fopts_len) 00147 { 00148 } 00149 00150 void LoRaMac::handle_data_frame(const uint8_t *const payload, 00151 const uint16_t size, 00152 uint8_t ptr_pos, 00153 uint8_t msg_type, 00154 int16_t rssi, 00155 int8_t snr) 00156 { 00157 } 00158 00159 void LoRaMac::set_batterylevel_callback(mbed::Callback<uint8_t(void)> battery_level) 00160 { 00161 } 00162 00163 void LoRaMac::on_radio_tx_done(lorawan_time_t timestamp) 00164 { 00165 } 00166 00167 void LoRaMac::on_radio_rx_done(const uint8_t *const payload, uint16_t size, 00168 int16_t rssi, int8_t snr) 00169 { 00170 } 00171 00172 void LoRaMac::on_radio_tx_timeout(void) 00173 { 00174 } 00175 00176 void LoRaMac::on_radio_rx_timeout(bool is_timeout) 00177 { 00178 } 00179 00180 bool LoRaMac::continue_joining_process() 00181 { 00182 if (LoRaMac_stub::bool_false_counter) { 00183 LoRaMac_stub::bool_false_counter--; 00184 return false; 00185 } 00186 if (LoRaMac_stub::bool_true_counter) { 00187 LoRaMac_stub::bool_true_counter--; 00188 return true; 00189 } 00190 return LoRaMac_stub::bool_value; 00191 } 00192 00193 bool LoRaMac::continue_sending_process() 00194 { 00195 if (LoRaMac_stub::bool_false_counter) { 00196 LoRaMac_stub::bool_false_counter--; 00197 return false; 00198 } 00199 if (LoRaMac_stub::bool_true_counter) { 00200 LoRaMac_stub::bool_true_counter--; 00201 return true; 00202 } 00203 return LoRaMac_stub::bool_value; 00204 } 00205 00206 lorawan_status_t LoRaMac::send_join_request() 00207 { 00208 return LoRaMac_stub::status_value; 00209 } 00210 00211 lorawan_status_t LoRaMac::handle_retransmission() 00212 { 00213 return LoRaMac_stub::status_value; 00214 } 00215 00216 void LoRaMac::on_backoff_timer_expiry(void) 00217 { 00218 } 00219 00220 void LoRaMac::open_rx1_window(void) 00221 { 00222 } 00223 00224 void LoRaMac::open_rx2_window() 00225 { 00226 } 00227 00228 void LoRaMac::on_ack_timeout_timer_event(void) 00229 { 00230 } 00231 00232 bool LoRaMac::validate_payload_length(uint16_t length, 00233 int8_t datarate, 00234 uint8_t fopts_len) 00235 { 00236 if (LoRaMac_stub::bool_false_counter) { 00237 LoRaMac_stub::bool_false_counter--; 00238 return false; 00239 } 00240 if (LoRaMac_stub::bool_true_counter) { 00241 LoRaMac_stub::bool_true_counter--; 00242 return true; 00243 } 00244 return LoRaMac_stub::bool_value; 00245 } 00246 00247 void LoRaMac::set_mlme_schedule_ul_indication(void) 00248 { 00249 } 00250 00251 // This is not actual transmission. It just schedules a message in response 00252 // to MCPS request 00253 lorawan_status_t LoRaMac::send(loramac_mhdr_t *machdr, const uint8_t fport, 00254 const void *fbuffer, uint16_t fbuffer_size) 00255 { 00256 return LoRaMac_stub::status_value; 00257 } 00258 00259 int LoRaMac::get_backoff_timer_event_id(void) 00260 { 00261 return LoRaMac_stub::int_value; 00262 } 00263 00264 lorawan_status_t LoRaMac::clear_tx_pipe(void) 00265 { 00266 return LoRaMac_stub::status_value; 00267 } 00268 00269 lorawan_status_t LoRaMac::schedule_tx() 00270 { 00271 return LoRaMac_stub::status_value; 00272 } 00273 00274 void LoRaMac::calculate_backOff(uint8_t channel) 00275 { 00276 } 00277 00278 void LoRaMac::reset_mac_parameters(void) 00279 { 00280 } 00281 00282 uint8_t LoRaMac::get_default_tx_datarate() 00283 { 00284 return 0; 00285 } 00286 00287 void LoRaMac::enable_adaptive_datarate(bool adr_enabled) 00288 { 00289 } 00290 00291 lorawan_status_t LoRaMac::set_channel_data_rate(uint8_t data_rate) 00292 { 00293 return LoRaMac_stub::status_value; 00294 } 00295 00296 bool LoRaMac::tx_ongoing() 00297 { 00298 if (LoRaMac_stub::bool_false_counter) { 00299 LoRaMac_stub::bool_false_counter--; 00300 return false; 00301 } 00302 if (LoRaMac_stub::bool_true_counter) { 00303 LoRaMac_stub::bool_true_counter--; 00304 return true; 00305 } 00306 return LoRaMac_stub::bool_value; 00307 } 00308 00309 void LoRaMac::set_tx_ongoing(bool ongoing) 00310 { 00311 } 00312 00313 void LoRaMac::reset_ongoing_tx(bool reset_pending) 00314 { 00315 } 00316 00317 int16_t LoRaMac::prepare_ongoing_tx(const uint8_t port, 00318 const uint8_t *const data, 00319 uint16_t length, 00320 uint8_t flags, 00321 uint8_t num_retries) 00322 { 00323 return 0; 00324 } 00325 00326 lorawan_status_t LoRaMac::send_ongoing_tx() 00327 { 00328 return LoRaMac_stub::status_value; 00329 } 00330 00331 device_class_t LoRaMac::get_device_class() const 00332 { 00333 return LoRaMac_stub::dev_class_value; 00334 } 00335 00336 void LoRaMac::set_device_class(const device_class_t &device_class, 00337 mbed::Callback<void(void)>ack_expiry_handler) 00338 { 00339 LoRaMac_stub::_ack_expiry_handler_for_class_c = ack_expiry_handler; 00340 } 00341 00342 void LoRaMac::setup_link_check_request() 00343 { 00344 } 00345 00346 lorawan_status_t LoRaMac::prepare_join(const lorawan_connect_t *params, bool is_otaa) 00347 { 00348 return LoRaMac_stub::status_value; 00349 } 00350 00351 lorawan_status_t LoRaMac::join(bool is_otaa) 00352 { 00353 return LoRaMac_stub::status_value; 00354 } 00355 00356 static void memcpy_convert_endianess(uint8_t *dst, 00357 const uint8_t *src, 00358 uint16_t size) 00359 { 00360 } 00361 00362 lorawan_status_t LoRaMac::prepare_frame(loramac_mhdr_t *machdr, 00363 loramac_frame_ctrl_t *fctrl, 00364 const uint8_t fport, 00365 const void *fbuffer, 00366 uint16_t fbuffer_size) 00367 { 00368 return LoRaMac_stub::status_value; 00369 } 00370 00371 lorawan_status_t LoRaMac::send_frame_on_channel(uint8_t channel) 00372 { 00373 return LoRaMac_stub::status_value; 00374 } 00375 00376 void LoRaMac::reset_mcps_confirmation() 00377 { 00378 } 00379 00380 void LoRaMac::reset_mlme_confirmation() 00381 { 00382 } 00383 00384 void LoRaMac::reset_mcps_indication() 00385 { 00386 } 00387 00388 void LoRaMac::set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx_power, 00389 float max_eirp, float antenna_gain, uint16_t timeout) 00390 { 00391 } 00392 00393 lorawan_status_t LoRaMac::initialize(EventQueue *queue, 00394 mbed::Callback<void(void)>scheduling_failure_handler) 00395 { 00396 LoRaMac_stub::_scheduling_failure_handler = scheduling_failure_handler; 00397 return LoRaMac_stub::status_value; 00398 } 00399 00400 void LoRaMac::disconnect() 00401 { 00402 } 00403 00404 uint8_t LoRaMac::get_max_possible_tx_size(uint8_t fopts_len) 00405 { 00406 return 0; 00407 } 00408 00409 bool LoRaMac::nwk_joined() 00410 { 00411 if (LoRaMac_stub::bool_false_counter) { 00412 LoRaMac_stub::bool_false_counter--; 00413 return false; 00414 } 00415 if (LoRaMac_stub::bool_true_counter) { 00416 LoRaMac_stub::bool_true_counter--; 00417 return true; 00418 } 00419 return LoRaMac_stub::bool_value; 00420 } 00421 00422 void LoRaMac::set_nwk_joined(bool joined) 00423 { 00424 } 00425 00426 lorawan_status_t LoRaMac::add_channel_plan(const lorawan_channelplan_t &plan) 00427 { 00428 return LoRaMac_stub::status_value; 00429 } 00430 00431 lorawan_status_t LoRaMac::remove_channel_plan() 00432 { 00433 return LoRaMac_stub::status_value; 00434 } 00435 00436 lorawan_status_t LoRaMac::get_channel_plan(lorawan_channelplan_t &plan) 00437 { 00438 return LoRaMac_stub::status_value; 00439 } 00440 00441 lorawan_status_t LoRaMac::remove_single_channel(uint8_t id) 00442 { 00443 return LoRaMac_stub::status_value; 00444 } 00445 00446 lorawan_status_t LoRaMac::multicast_channel_link(multicast_params_t *channel_param) 00447 { 00448 return LoRaMac_stub::status_value; 00449 } 00450 00451 lorawan_status_t LoRaMac::multicast_channel_unlink(multicast_params_t *channel_param) 00452 { 00453 return LoRaMac_stub::status_value; 00454 } 00455 00456 void LoRaMac::bind_phy(LoRaPHY &phy) 00457 { 00458 }
Generated on Tue Aug 9 2022 00:37:09 by
1.7.2