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.
Dependencies: nRF51_Vdd TextLCD BME280
LoRaWANInterface.cpp
00001 /** 00002 * @file 00003 * 00004 * @brief Implementation of LoRaWANBase 00005 * 00006 * Copyright (c) 2017, Arm Limited and affiliates. 00007 * SPDX-License-Identifier: Apache-2.0 00008 * 00009 * Licensed under the Apache License, Version 2.0 (the "License"); 00010 * you may not use this file except in compliance with the License. 00011 * You may obtain a copy of the License at 00012 * 00013 * http://www.apache.org/licenses/LICENSE-2.0 00014 * 00015 * Unless required by applicable law or agreed to in writing, software 00016 * distributed under the License is distributed on an "AS IS" BASIS, 00017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 */ 00021 00022 #include "LoRaWANInterface.h" 00023 #include "lorastack/phy/loraphy_target.h" 00024 00025 using namespace events; 00026 00027 LoRaWANInterface::LoRaWANInterface(LoRaRadio &radio) 00028 : _default_phy(NULL) 00029 { 00030 _default_phy = new LoRaPHY_region; 00031 MBED_ASSERT(_default_phy); 00032 _lw_stack.bind_phy_and_radio_driver(radio, *_default_phy); 00033 } 00034 00035 LoRaWANInterface::LoRaWANInterface(LoRaRadio &radio, LoRaPHY &phy) 00036 : _default_phy(NULL) 00037 { 00038 _lw_stack.bind_phy_and_radio_driver(radio, phy); 00039 } 00040 00041 LoRaWANInterface::~LoRaWANInterface() 00042 { 00043 delete _default_phy; 00044 _default_phy = NULL; 00045 } 00046 00047 lorawan_status_t LoRaWANInterface::initialize(EventQueue *queue) 00048 { 00049 Lock lock(*this); 00050 return _lw_stack.initialize_mac_layer(queue); 00051 } 00052 00053 lorawan_status_t LoRaWANInterface::connect() 00054 { 00055 Lock lock(*this); 00056 return _lw_stack.connect(); 00057 } 00058 00059 lorawan_status_t LoRaWANInterface::connect(const lorawan_connect_t &connect) 00060 { 00061 Lock lock(*this); 00062 return _lw_stack.connect(connect); 00063 } 00064 00065 lorawan_status_t LoRaWANInterface::disconnect() 00066 { 00067 Lock lock(*this); 00068 return _lw_stack.shutdown(); 00069 } 00070 00071 lorawan_status_t LoRaWANInterface::add_link_check_request() 00072 { 00073 Lock lock(*this); 00074 return _lw_stack.set_link_check_request(); 00075 } 00076 00077 void LoRaWANInterface::remove_link_check_request() 00078 { 00079 Lock lock(*this); 00080 _lw_stack.remove_link_check_request(); 00081 } 00082 00083 lorawan_status_t LoRaWANInterface::set_datarate(uint8_t data_rate) 00084 { 00085 Lock lock(*this); 00086 return _lw_stack.set_channel_data_rate(data_rate); 00087 } 00088 00089 lorawan_status_t LoRaWANInterface::set_confirmed_msg_retries(uint8_t count) 00090 { 00091 Lock lock(*this); 00092 return _lw_stack.set_confirmed_msg_retry(count); 00093 } 00094 00095 lorawan_status_t LoRaWANInterface::enable_adaptive_datarate() 00096 { 00097 Lock lock(*this); 00098 return _lw_stack.enable_adaptive_datarate(true); 00099 } 00100 00101 lorawan_status_t LoRaWANInterface::disable_adaptive_datarate() 00102 { 00103 Lock lock(*this); 00104 return _lw_stack.enable_adaptive_datarate(false); 00105 } 00106 00107 lorawan_status_t LoRaWANInterface::set_channel_plan(const lorawan_channelplan_t &channel_plan) 00108 { 00109 Lock lock(*this); 00110 return _lw_stack.add_channels(channel_plan); 00111 } 00112 00113 lorawan_status_t LoRaWANInterface::get_channel_plan(lorawan_channelplan_t &channel_plan) 00114 { 00115 Lock lock(*this); 00116 return _lw_stack.get_enabled_channels(channel_plan); 00117 } 00118 00119 lorawan_status_t LoRaWANInterface::remove_channel(uint8_t id) 00120 { 00121 Lock lock(*this); 00122 return _lw_stack.remove_a_channel(id); 00123 } 00124 00125 lorawan_status_t LoRaWANInterface::remove_channel_plan() 00126 { 00127 Lock lock(*this); 00128 return _lw_stack.drop_channel_list(); 00129 } 00130 00131 int16_t LoRaWANInterface::send(uint8_t port, const uint8_t *data, uint16_t length, int flags) 00132 { 00133 Lock lock(*this); 00134 return _lw_stack.handle_tx(port, data, length, flags); 00135 } 00136 00137 lorawan_status_t LoRaWANInterface::cancel_sending(void) 00138 { 00139 Lock lock(*this); 00140 return _lw_stack.stop_sending(); 00141 } 00142 00143 lorawan_status_t LoRaWANInterface::get_tx_metadata(lorawan_tx_metadata &metadata) 00144 { 00145 Lock lock(*this); 00146 return _lw_stack.acquire_tx_metadata(metadata); 00147 } 00148 00149 lorawan_status_t LoRaWANInterface::get_rx_metadata(lorawan_rx_metadata &metadata) 00150 { 00151 Lock lock(*this); 00152 return _lw_stack.acquire_rx_metadata(metadata); 00153 } 00154 00155 lorawan_status_t LoRaWANInterface::get_backoff_metadata(int &backoff) 00156 { 00157 Lock lock(*this); 00158 return _lw_stack.acquire_backoff_metadata(backoff); 00159 } 00160 00161 int16_t LoRaWANInterface::receive(uint8_t port, uint8_t *data, uint16_t length, int flags) 00162 { 00163 Lock lock(*this); 00164 return _lw_stack.handle_rx(data, length, port, flags, true); 00165 } 00166 00167 int16_t LoRaWANInterface::receive(uint8_t *data, uint16_t length, uint8_t &port, int &flags) 00168 { 00169 Lock lock(*this); 00170 return _lw_stack.handle_rx(data, length, port, flags, false); 00171 } 00172 00173 lorawan_status_t LoRaWANInterface::add_app_callbacks(lorawan_app_callbacks_t *callbacks) 00174 { 00175 Lock lock(*this); 00176 return _lw_stack.set_lora_callbacks(callbacks); 00177 } 00178 00179 lorawan_status_t LoRaWANInterface::set_device_class(const device_class_t device_class) 00180 { 00181 Lock lock(*this); 00182 return _lw_stack.set_device_class(device_class); 00183 }
Generated on Tue Jul 12 2022 15:15:48 by
