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.
LoRaPHYEU433.cpp
00001 /** 00002 * @file LoRaPHYEU433.cpp 00003 * 00004 * @brief Implements LoRaPHY for European 433 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 "LoRaPHYEU433.h" 00033 #include "lora_phy_ds.h" 00034 00035 /*! 00036 * Number of default channels 00037 */ 00038 #define EU433_NUMB_DEFAULT_CHANNELS 3 00039 00040 /*! 00041 * Number of channels to apply for the CF list 00042 */ 00043 #define EU433_NUMB_CHANNELS_CF_LIST 5 00044 00045 /*! 00046 * Minimal datarate that can be used by the node 00047 */ 00048 #define EU433_TX_MIN_DATARATE DR_0 00049 00050 /*! 00051 * Maximal datarate that can be used by the node 00052 */ 00053 #define EU433_TX_MAX_DATARATE DR_7 00054 00055 /*! 00056 * Minimal datarate that can be used by the node 00057 */ 00058 #define EU433_RX_MIN_DATARATE DR_0 00059 00060 /*! 00061 * Maximal datarate that can be used by the node 00062 */ 00063 #define EU433_RX_MAX_DATARATE DR_7 00064 00065 /*! 00066 * Default datarate used by the node 00067 */ 00068 #define EU433_DEFAULT_DATARATE DR_0 00069 00070 #define EU433_DEFAULT_MAX_DATARATE DR_5 00071 00072 /*! 00073 * Minimal Rx1 receive datarate offset 00074 */ 00075 #define EU433_MIN_RX1_DR_OFFSET 0 00076 00077 /*! 00078 * Maximal Rx1 receive datarate offset 00079 */ 00080 #define EU433_MAX_RX1_DR_OFFSET 5 00081 00082 /*! 00083 * Default Rx1 receive datarate offset 00084 */ 00085 #define EU433_DEFAULT_RX1_DR_OFFSET 0 00086 00087 /*! 00088 * Minimal Tx output power that can be used by the node 00089 */ 00090 #define EU433_MIN_TX_POWER TX_POWER_5 00091 00092 /*! 00093 * Maximal Tx output power that can be used by the node 00094 */ 00095 #define EU433_MAX_TX_POWER TX_POWER_0 00096 00097 /*! 00098 * Default Tx output power used by the node 00099 */ 00100 #define EU433_DEFAULT_TX_POWER TX_POWER_0 00101 00102 /*! 00103 * Default Max EIRP 00104 */ 00105 #define EU433_DEFAULT_MAX_EIRP 12.15f 00106 00107 /*! 00108 * Default antenna gain 00109 */ 00110 #define EU433_DEFAULT_ANTENNA_GAIN 2.15f 00111 00112 /*! 00113 * ADR Ack limit 00114 */ 00115 #define EU433_ADR_ACK_LIMIT 64 00116 00117 /*! 00118 * ADR Ack delay 00119 */ 00120 #define EU433_ADR_ACK_DELAY 32 00121 00122 /*! 00123 * Enabled or disabled the duty cycle 00124 */ 00125 #define EU433_DUTY_CYCLE_ENABLED 1 00126 00127 /*! 00128 * Maximum RX window duration 00129 */ 00130 #define EU433_MAX_RX_WINDOW 3000 00131 00132 /*! 00133 * Receive delay 1 00134 */ 00135 #define EU433_RECEIVE_DELAY1 1000 00136 00137 /*! 00138 * Receive delay 2 00139 */ 00140 #define EU433_RECEIVE_DELAY2 2000 00141 00142 /*! 00143 * Join accept delay 1 00144 */ 00145 #define EU433_JOIN_ACCEPT_DELAY1 5000 00146 00147 /*! 00148 * Join accept delay 2 00149 */ 00150 #define EU433_JOIN_ACCEPT_DELAY2 6000 00151 00152 /*! 00153 * Maximum frame counter gap 00154 */ 00155 #define EU433_MAX_FCNT_GAP 16384 00156 00157 /*! 00158 * Ack timeout 00159 */ 00160 #define EU433_ACKTIMEOUT 2000 00161 00162 /*! 00163 * Random ack timeout limits 00164 */ 00165 #define EU433_ACK_TIMEOUT_RND 1000 00166 00167 /*! 00168 * Verification of default datarate 00169 */ 00170 #if ( EU433_DEFAULT_DATARATE > DR_5 ) 00171 #error "A default DR higher than DR_5 may lead to connectivity loss." 00172 #endif 00173 00174 /*! 00175 * Second reception window channel frequency definition. 00176 */ 00177 #define EU433_RX_WND_2_FREQ 434665000 00178 00179 /*! 00180 * Second reception window channel datarate definition. 00181 */ 00182 #define EU433_RX_WND_2_DR DR_0 00183 00184 /*! 00185 * Band 0 definition 00186 * { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00187 */ 00188 static const band_t EU433_BAND0 = {100, EU433_MAX_TX_POWER, 0, 0, 0, 433175000, 434665000}; // 1.0 % 00189 00190 /*! 00191 * LoRaMac default channel 1 00192 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00193 */ 00194 static const channel_params_t EU433_LC1 = {433175000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0}; 00195 00196 /*! 00197 * LoRaMac default channel 2 00198 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00199 */ 00200 static const channel_params_t EU433_LC2 = {433375000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0}; 00201 00202 /*! 00203 * LoRaMac default channel 3 00204 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00205 */ 00206 static const channel_params_t EU433_LC3 = {433575000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0}; 00207 00208 /*! 00209 * LoRaMac channels which are allowed for the join procedure 00210 */ 00211 #define EU433_JOIN_CHANNELS (uint16_t) (LC(1) | LC(2) | LC(3)) 00212 00213 /*! 00214 * Data rates table definition 00215 */ 00216 static const uint8_t datarates_EU433 [] = {12, 11, 10, 9, 8, 7, 7, 50}; 00217 00218 /*! 00219 * Bandwidths table definition in Hz 00220 */ 00221 static const uint32_t bandwidths_EU433 [] = {125000, 125000, 125000, 125000, 125000, 125000, 250000, 0}; 00222 00223 /*! 00224 * Maximum payload with respect to the datarate index. Cannot operate with repeater. 00225 */ 00226 static const uint8_t max_payloads_EU433 [] = {51, 51, 51, 115, 242, 242, 242, 242}; 00227 00228 /*! 00229 * Maximum payload with respect to the datarate index. Can operate with repeater. 00230 */ 00231 static const uint8_t max_payloads_with_repeater_EU433 [] = {51, 51, 51, 115, 222, 222, 222, 222}; 00232 00233 00234 LoRaPHYEU433::LoRaPHYEU433(LoRaWANTimeHandler &lora_time) 00235 : LoRaPHY(lora_time) 00236 { 00237 bands[0] = EU433_BAND0 ; 00238 00239 // Channels 00240 channels[0] = EU433_LC1 ; 00241 channels[1] = EU433_LC2 ;; 00242 channels[2] = EU433_LC3 ;; 00243 00244 // Initialize the channels default mask 00245 default_channel_mask[0] = LC(1) + LC(2) + LC(3); 00246 // Update the channels mask 00247 copy_channel_mask(channel_mask, default_channel_mask, EU433_CHANNEL_MASK_SIZE); 00248 00249 // set default channels 00250 phy_params.channels.channel_list = channels; 00251 phy_params.channels.channel_list_size = EU433_MAX_NB_CHANNELS; 00252 phy_params.channels.mask = channel_mask; 00253 phy_params.channels.default_mask = default_channel_mask; 00254 phy_params.channels.mask_size = EU433_CHANNEL_MASK_SIZE; 00255 00256 // set bands for EU433 spectrum 00257 phy_params.bands.table = bands; 00258 phy_params.bands.size = EU433_MAX_NB_BANDS; 00259 00260 // set bandwidths available in EU433 spectrum 00261 phy_params.bandwidths.table = (void *) bandwidths_EU433 ; 00262 phy_params.bandwidths.size = 8; 00263 00264 // set data rates available in EU433 spectrum 00265 phy_params.datarates.table = (void *) datarates_EU433 ; 00266 phy_params.datarates.size = 8; 00267 00268 // set payload sizes with respect to data rates 00269 phy_params.payloads.table = (void *) max_payloads_EU433 ; 00270 phy_params.payloads.size = 8; 00271 phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater_EU433 ; 00272 phy_params.payloads_with_repeater.size = 8; 00273 00274 // dwell time setting 00275 phy_params.ul_dwell_time_setting = 0; 00276 phy_params.dl_dwell_time_setting = 0; 00277 00278 // set initial and default parameters 00279 phy_params.duty_cycle_enabled = EU433_DUTY_CYCLE_ENABLED; 00280 phy_params.accept_tx_param_setup_req = false; 00281 phy_params.fsk_supported = true; 00282 phy_params.cflist_supported = true; 00283 phy_params.dl_channel_req_supported = true; 00284 phy_params.custom_channelplans_supported = true; 00285 phy_params.default_channel_cnt = EU433_NUMB_DEFAULT_CHANNELS; 00286 phy_params.max_channel_cnt = EU433_MAX_NB_CHANNELS; 00287 phy_params.cflist_channel_cnt = EU433_NUMB_CHANNELS_CF_LIST; 00288 phy_params.min_tx_datarate = EU433_TX_MIN_DATARATE; 00289 phy_params.max_tx_datarate = EU433_TX_MAX_DATARATE; 00290 phy_params.min_rx_datarate = EU433_RX_MIN_DATARATE; 00291 phy_params.max_rx_datarate = EU433_RX_MAX_DATARATE; 00292 phy_params.default_datarate = EU433_DEFAULT_DATARATE; 00293 phy_params.default_max_datarate = EU433_DEFAULT_MAX_DATARATE; 00294 phy_params.min_rx1_dr_offset = EU433_MIN_RX1_DR_OFFSET; 00295 phy_params.max_rx1_dr_offset = EU433_MAX_RX1_DR_OFFSET; 00296 phy_params.default_rx1_dr_offset = EU433_DEFAULT_RX1_DR_OFFSET; 00297 phy_params.min_tx_power = EU433_MIN_TX_POWER; 00298 phy_params.max_tx_power = EU433_MAX_TX_POWER; 00299 phy_params.default_tx_power = EU433_DEFAULT_TX_POWER; 00300 phy_params.default_max_eirp = EU433_DEFAULT_MAX_EIRP; 00301 phy_params.default_antenna_gain = EU433_DEFAULT_ANTENNA_GAIN; 00302 phy_params.adr_ack_limit = EU433_ADR_ACK_LIMIT; 00303 phy_params.adr_ack_delay = EU433_ADR_ACK_DELAY; 00304 phy_params.max_rx_window = EU433_MAX_RX_WINDOW; 00305 phy_params.recv_delay1 = EU433_RECEIVE_DELAY1; 00306 phy_params.recv_delay2 = EU433_RECEIVE_DELAY2; 00307 phy_params.join_channel_mask = EU433_JOIN_CHANNELS; 00308 phy_params.join_accept_delay1 = EU433_JOIN_ACCEPT_DELAY1; 00309 phy_params.join_accept_delay2 = EU433_JOIN_ACCEPT_DELAY2; 00310 phy_params.max_fcnt_gap = EU433_MAX_FCNT_GAP; 00311 phy_params.ack_timeout = EU433_ACKTIMEOUT; 00312 phy_params.ack_timeout_rnd = EU433_ACK_TIMEOUT_RND; 00313 phy_params.rx_window2_datarate = EU433_RX_WND_2_DR; 00314 phy_params.rx_window2_frequency = EU433_RX_WND_2_FREQ; 00315 } 00316 00317 LoRaPHYEU433::~LoRaPHYEU433() 00318 { 00319 }
Generated on Tue Jul 12 2022 14:23:51 by
