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
LoRaPHYEU868.cpp
00001 /** 00002 * @file LoRaPHYEU868.cpp 00003 * 00004 * @brief Implements LoRaPHY for European 868 MHz band 00005 * 00006 * \code 00007 * ______ _ 00008 * / _____) _ | | 00009 * ( (____ _____ ____ _| |_ _____ ____| |__ 00010 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 00011 * _____) ) ____| | | || |_| ____( (___| | | | 00012 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 00013 * (C)2013 Semtech 00014 * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 00015 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 00016 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 00017 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 00018 * embedded.connectivity.solutions=============== 00019 * 00020 * \endcode 00021 * 00022 * 00023 * License: Revised BSD License, see LICENSE.TXT file include in the project 00024 * 00025 * Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) 00026 * 00027 * Copyright (c) 2017, Arm Limited and affiliates. 00028 * SPDX-License-Identifier: BSD-3-Clause 00029 * 00030 */ 00031 00032 #include "LoRaPHYEU868.h" 00033 #include "lora_phy_ds.h" 00034 00035 /*! 00036 * Number of default channels 00037 */ 00038 #define EU868_NUMB_DEFAULT_CHANNELS 3 00039 00040 /*! 00041 * Number of channels to apply for the CF list 00042 */ 00043 #define EU868_NUMB_CHANNELS_CF_LIST 5 00044 00045 /*! 00046 * Minimal datarate that can be used by the node 00047 */ 00048 #define EU868_TX_MIN_DATARATE DR_0 00049 00050 /*! 00051 * Maximal datarate that can be used by the node 00052 */ 00053 #define EU868_TX_MAX_DATARATE DR_7 00054 00055 /*! 00056 * Minimal datarate that can be used by the node 00057 */ 00058 #define EU868_RX_MIN_DATARATE DR_0 00059 00060 /*! 00061 * Maximal datarate that can be used by the node 00062 */ 00063 #define EU868_RX_MAX_DATARATE DR_7 00064 00065 /*! 00066 * Default datarate used by the node 00067 */ 00068 #define EU868_DEFAULT_DATARATE DR_0 00069 00070 #define EU868_DEFAULT_MAX_DATARATE DR_5 00071 00072 /*! 00073 * Minimal Rx1 receive datarate offset 00074 */ 00075 #define EU868_MIN_RX1_DR_OFFSET 0 00076 00077 /*! 00078 * Maximal Rx1 receive datarate offset 00079 */ 00080 #define EU868_MAX_RX1_DR_OFFSET 5 00081 00082 /*! 00083 * Default Rx1 receive datarate offset 00084 */ 00085 #define EU868_DEFAULT_RX1_DR_OFFSET 0 00086 00087 /*! 00088 * Minimal Tx output power that can be used by the node 00089 */ 00090 #define EU868_MIN_TX_POWER TX_POWER_7 00091 00092 /*! 00093 * Maximal Tx output power that can be used by the node 00094 */ 00095 #define EU868_MAX_TX_POWER TX_POWER_0 00096 00097 /*! 00098 * Default Tx output power used by the node 00099 */ 00100 #define EU868_DEFAULT_TX_POWER TX_POWER_0 00101 00102 /*! 00103 * Default Max EIRP 00104 */ 00105 #define EU868_DEFAULT_MAX_EIRP 16.0f 00106 00107 /*! 00108 * Default antenna gain 00109 */ 00110 #define EU868_DEFAULT_ANTENNA_GAIN 2.15f 00111 00112 /*! 00113 * ADR Ack limit 00114 */ 00115 #define EU868_ADR_ACK_LIMIT 64 00116 00117 /*! 00118 * ADR Ack delay 00119 */ 00120 #define EU868_ADR_ACK_DELAY 32 00121 00122 /*! 00123 * Enabled or disabled the duty cycle 00124 */ 00125 #define EU868_DUTY_CYCLE_ENABLED 1 00126 00127 /*! 00128 * Maximum RX window duration 00129 */ 00130 #define EU868_MAX_RX_WINDOW 3000 00131 00132 /*! 00133 * Receive delay 1 00134 */ 00135 #define EU868_RECEIVE_DELAY1 1000 00136 00137 /*! 00138 * Receive delay 2 00139 */ 00140 #define EU868_RECEIVE_DELAY2 2000 00141 00142 /*! 00143 * Join accept delay 1 00144 */ 00145 #define EU868_JOIN_ACCEPT_DELAY1 5000 00146 00147 /*! 00148 * Join accept delay 2 00149 */ 00150 #define EU868_JOIN_ACCEPT_DELAY2 6000 00151 00152 /*! 00153 * Maximum frame counter gap 00154 */ 00155 #define EU868_MAX_FCNT_GAP 16384 00156 00157 /*! 00158 * Ack timeout 00159 */ 00160 #define EU868_ACKTIMEOUT 2000 00161 00162 /*! 00163 * Random ack timeout limits 00164 */ 00165 #define EU868_ACK_TIMEOUT_RND 1000 00166 00167 #if ( EU868_DEFAULT_DATARATE > DR_5 ) 00168 #error "A default DR higher than DR_5 may lead to connectivity loss." 00169 #endif 00170 00171 /*! 00172 * Second reception window channel frequency definition. 00173 */ 00174 #define EU868_RX_WND_2_FREQ 869525000 00175 00176 /*! 00177 * Second reception window channel datarate definition. 00178 */ 00179 #define EU868_RX_WND_2_DR DR_0 00180 00181 /*! 00182 * Band 0 definition 00183 * { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00184 */ 00185 static const band_t EU868_BAND0 = {100 , EU868_MAX_TX_POWER, 0, 0, 0,865000000, 868000000}; // 1.0 % 00186 /*! 00187 * Band 1 definition 00188 * { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00189 */ 00190 static const band_t EU868_BAND1 = {100 , EU868_MAX_TX_POWER, 0, 0, 0, 868100000, 868600000}; // 1.0 % 00191 00192 /*! 00193 * Band 2 definition 00194 * Band = { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00195 */ 00196 static const band_t EU868_BAND2 = {1000, EU868_MAX_TX_POWER, 0, 0, 0, 868700000, 869200000}; // 0.1 % 00197 00198 /*! 00199 * Band 3 definition 00200 * Band = { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00201 */ 00202 static const band_t EU868_BAND3 = {10 , EU868_MAX_TX_POWER, 0, 0, 0, 869400000, 869650000}; // 10.0 % 00203 00204 /*! 00205 * Band 4 definition 00206 * Band = { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00207 */ 00208 static const band_t EU868_BAND4 = {100 , EU868_MAX_TX_POWER, 0, 0, 0, 869700000, 870000000}; // 1.0 % 00209 00210 /*! 00211 * Band 5 definition - It's actually a sub part of Band 2 00212 * Band = { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00213 */ 00214 static const band_t EU868_BAND5 = {1000, EU868_MAX_TX_POWER, 0, 0, 0, 863000000, 865000000}; // 0.1 % 00215 00216 /*! 00217 * LoRaMac default channel 1 00218 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00219 */ 00220 static const channel_params_t EU868_LC1 = {868100000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 1}; 00221 00222 /*! 00223 * LoRaMac default channel 2 00224 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00225 */ 00226 static const channel_params_t EU868_LC2 = {868300000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 1}; 00227 00228 /*! 00229 * LoRaMac default channel 3 00230 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00231 */ 00232 static const channel_params_t EU868_LC3 = {868500000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 1}; 00233 00234 /*! 00235 * LoRaMac channels which are allowed for the join procedure 00236 */ 00237 #define EU868_JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3)) 00238 00239 /*! 00240 * Data rates table definition 00241 */ 00242 static const uint8_t datarates_EU868 [] = {12, 11, 10, 9, 8, 7, 7, 50}; 00243 00244 /*! 00245 * Bandwidths table definition in Hz 00246 */ 00247 static const uint32_t bandwidths_EU868 [] = {125000, 125000, 125000, 125000, 125000, 125000, 250000, 0}; 00248 00249 /*! 00250 * Maximum payload with respect to the datarate index. Cannot operate with repeater. 00251 */ 00252 static const uint8_t max_payloads_EU868 [] = {51, 51, 51, 115, 242, 242, 242, 242}; 00253 00254 /*! 00255 * Maximum payload with respect to the datarate index. Can operate with repeater. 00256 */ 00257 static const uint8_t max_payloads_repeater_EU868 [] = {51, 51, 51, 115, 222, 222, 222, 222}; 00258 00259 LoRaPHYEU868::LoRaPHYEU868() 00260 { 00261 bands[0] = EU868_BAND0 ; 00262 bands[1] = EU868_BAND1 ; 00263 bands[2] = EU868_BAND2 ; 00264 bands[3] = EU868_BAND3 ; 00265 bands[4] = EU868_BAND4 ; 00266 bands[5] = EU868_BAND5 ; 00267 00268 // Default Channels are always enabled, rest will be added later 00269 channels[0] = EU868_LC1 ; 00270 channels[0].band = 1; 00271 channels[1] = EU868_LC2 ; 00272 channels[1].band = 1; 00273 channels[2] = EU868_LC3 ; 00274 channels[2].band = 1; 00275 00276 // Initialize the channels default mask 00277 default_channel_mask[0] = LC(1) + LC(2) + LC(3); 00278 // Update the channels mask 00279 copy_channel_mask(channel_mask, default_channel_mask, 1); 00280 00281 // set default channels 00282 phy_params.channels.channel_list = channels; 00283 phy_params.channels.channel_list_size = EU868_MAX_NB_CHANNELS; 00284 phy_params.channels.mask = channel_mask; 00285 phy_params.channels.default_mask = default_channel_mask; 00286 phy_params.channels.mask_size = EU868_CHANNEL_MASK_SIZE; 00287 00288 // set bands for EU868 spectrum 00289 phy_params.bands.table = (void *) bands; 00290 phy_params.bands.size = EU868_MAX_NB_BANDS; 00291 00292 // set bandwidths available in EU868 spectrum 00293 phy_params.bandwidths.table = (void *) bandwidths_EU868 ; 00294 phy_params.bandwidths.size = 8; 00295 00296 // set data rates available in EU868 spectrum 00297 phy_params.datarates.table = (void *) datarates_EU868 ; 00298 phy_params.datarates.size = 8; 00299 00300 // set payload sizes with respect to data rates 00301 phy_params.payloads.table = (void *) max_payloads_EU868 ; 00302 phy_params.payloads.size = 8; 00303 phy_params.payloads_with_repeater.table = (void *) max_payloads_repeater_EU868 ; 00304 phy_params.payloads_with_repeater.size = 8; 00305 00306 // dwell time setting 00307 phy_params.ul_dwell_time_setting = 0; 00308 phy_params.dl_dwell_time_setting = 0; 00309 00310 // set initial and default parameters 00311 phy_params.duty_cycle_enabled = EU868_DUTY_CYCLE_ENABLED; 00312 phy_params.accept_tx_param_setup_req = true; 00313 phy_params.fsk_supported = true; 00314 phy_params.cflist_supported = true; 00315 phy_params.dl_channel_req_supported = true; 00316 phy_params.custom_channelplans_supported = true; 00317 phy_params.default_channel_cnt = EU868_NUMB_DEFAULT_CHANNELS; 00318 phy_params.max_channel_cnt = EU868_MAX_NB_CHANNELS; 00319 phy_params.cflist_channel_cnt = EU868_NUMB_CHANNELS_CF_LIST; 00320 phy_params.min_tx_datarate = EU868_TX_MIN_DATARATE; 00321 phy_params.max_tx_datarate = EU868_TX_MAX_DATARATE; 00322 phy_params.min_rx_datarate = EU868_RX_MIN_DATARATE; 00323 phy_params.max_rx_datarate = EU868_RX_MAX_DATARATE; 00324 phy_params.default_datarate = EU868_DEFAULT_DATARATE; 00325 phy_params.default_max_datarate = EU868_DEFAULT_MAX_DATARATE; 00326 phy_params.min_rx1_dr_offset = EU868_MIN_RX1_DR_OFFSET; 00327 phy_params.max_rx1_dr_offset = EU868_MAX_RX1_DR_OFFSET; 00328 phy_params.default_rx1_dr_offset = EU868_DEFAULT_RX1_DR_OFFSET; 00329 phy_params.min_tx_power = EU868_MIN_TX_POWER; 00330 phy_params.max_tx_power = EU868_MAX_TX_POWER; 00331 phy_params.default_tx_power = EU868_DEFAULT_TX_POWER; 00332 phy_params.default_max_eirp = EU868_DEFAULT_MAX_EIRP; 00333 phy_params.default_antenna_gain = EU868_DEFAULT_ANTENNA_GAIN; 00334 phy_params.adr_ack_limit = EU868_ADR_ACK_LIMIT; 00335 phy_params.adr_ack_delay = EU868_ADR_ACK_DELAY; 00336 phy_params.max_rx_window = EU868_MAX_RX_WINDOW; 00337 phy_params.recv_delay1 = EU868_RECEIVE_DELAY1; 00338 phy_params.recv_delay2 = EU868_RECEIVE_DELAY2; 00339 phy_params.join_channel_mask = EU868_JOIN_CHANNELS; 00340 phy_params.join_accept_delay1 = EU868_JOIN_ACCEPT_DELAY1; 00341 phy_params.join_accept_delay2 = EU868_JOIN_ACCEPT_DELAY2; 00342 phy_params.max_fcnt_gap = EU868_MAX_FCNT_GAP; 00343 phy_params.ack_timeout = EU868_ACKTIMEOUT; 00344 phy_params.ack_timeout_rnd = EU868_ACK_TIMEOUT_RND; 00345 phy_params.rx_window2_datarate = EU868_RX_WND_2_DR; 00346 phy_params.rx_window2_frequency = EU868_RX_WND_2_FREQ; 00347 } 00348 00349 LoRaPHYEU868::~LoRaPHYEU868() 00350 { 00351 } 00352
Generated on Tue Jul 12 2022 15:15:48 by
