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.
LoRaPHYIN865.cpp
00001 /** 00002 * @file LoRaPHYIN865.cpp 00003 * 00004 * @brief Implements LoRaPHY for Indian 865 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 "LoRaPHYIN865.h" 00033 #include "lora_phy_ds.h" 00034 00035 00036 /*! 00037 * Number of default channels 00038 */ 00039 #define IN865_NUMB_DEFAULT_CHANNELS 3 00040 00041 /*! 00042 * Number of channels to apply for the CF list 00043 */ 00044 #define IN865_NUMB_CHANNELS_CF_LIST 5 00045 00046 /*! 00047 * Minimal datarate that can be used by the node 00048 */ 00049 #define IN865_TX_MIN_DATARATE DR_0 00050 00051 /*! 00052 * Maximal datarate that can be used by the node 00053 */ 00054 #define IN865_TX_MAX_DATARATE DR_7 00055 00056 /*! 00057 * Minimal datarate that can be used by the node 00058 */ 00059 #define IN865_RX_MIN_DATARATE DR_0 00060 00061 /*! 00062 * Maximal datarate that can be used by the node 00063 */ 00064 #define IN865_RX_MAX_DATARATE DR_7 00065 00066 /*! 00067 * Default datarate used by the node 00068 */ 00069 #define IN865_DEFAULT_DATARATE DR_0 00070 #define IN865_DEFAULT_MAX_DATARATE DR_5 00071 00072 /*! 00073 * Minimal Rx1 receive datarate offset 00074 */ 00075 #define IN865_MIN_RX1_DR_OFFSET 0 00076 00077 /*! 00078 * Maximal Rx1 receive datarate offset 00079 */ 00080 #define IN865_MAX_RX1_DR_OFFSET 7 00081 00082 /*! 00083 * Default Rx1 receive datarate offset 00084 */ 00085 #define IN865_DEFAULT_RX1_DR_OFFSET 0 00086 00087 /*! 00088 * Minimal Tx output power that can be used by the node 00089 */ 00090 #define IN865_MIN_TX_POWER TX_POWER_10 00091 00092 /*! 00093 * Maximal Tx output power that can be used by the node 00094 */ 00095 #define IN865_MAX_TX_POWER TX_POWER_0 00096 00097 /*! 00098 * Default Tx output power used by the node 00099 */ 00100 #define IN865_DEFAULT_TX_POWER TX_POWER_0 00101 00102 /*! 00103 * Default Max EIRP 00104 */ 00105 #define IN865_DEFAULT_MAX_EIRP 30.0f 00106 00107 /*! 00108 * Default antenna gain 00109 */ 00110 #define IN865_DEFAULT_ANTENNA_GAIN 2.15f 00111 00112 /*! 00113 * ADR Ack limit 00114 */ 00115 #define IN865_ADR_ACK_LIMIT 64 00116 00117 /*! 00118 * ADR Ack delay 00119 */ 00120 #define IN865_ADR_ACK_DELAY 32 00121 00122 /*! 00123 * Enabled or disabled the duty cycle 00124 */ 00125 #define IN865_DUTY_CYCLE_ENABLED 1 00126 00127 /*! 00128 * Maximum RX window duration 00129 */ 00130 #define IN865_MAX_RX_WINDOW 3000 00131 00132 /*! 00133 * Receive delay 1 00134 */ 00135 #define IN865_RECEIVE_DELAY1 1000 00136 00137 /*! 00138 * Receive delay 2 00139 */ 00140 #define IN865_RECEIVE_DELAY2 2000 00141 00142 /*! 00143 * Join accept delay 1 00144 */ 00145 #define IN865_JOIN_ACCEPT_DELAY1 5000 00146 00147 /*! 00148 * Join accept delay 2 00149 */ 00150 #define IN865_JOIN_ACCEPT_DELAY2 6000 00151 00152 /*! 00153 * Maximum frame counter gap 00154 */ 00155 #define IN865_MAX_FCNT_GAP 16384 00156 00157 /*! 00158 * Ack timeout 00159 */ 00160 #define IN865_ACKTIMEOUT 2000 00161 00162 /*! 00163 * Random ack timeout limits 00164 */ 00165 #define IN865_ACK_TIMEOUT_RND 1000 00166 00167 #if ( IN865_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 IN865_RX_WND_2_FREQ 866550000 00175 00176 /*! 00177 * Second reception window channel datarate definition. 00178 */ 00179 #define IN865_RX_WND_2_DR DR_2 00180 00181 /*! 00182 * Band 0 definition 00183 * { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } 00184 */ 00185 static const band_t IN865_BAND0 = { 1 , IN865_MAX_TX_POWER, 0, 0, 0, 865000000, 867000000 }; // 100.0 % 00186 00187 /*! 00188 * LoRaMac default channel 1 00189 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00190 */ 00191 static const channel_params_t IN865_LC1 = { 865062500, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }; 00192 00193 /*! 00194 * LoRaMac default channel 2 00195 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00196 */ 00197 static const channel_params_t IN865_LC2 = { 865402500, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }; 00198 00199 /*! 00200 * LoRaMac default channel 3 00201 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } 00202 */ 00203 static const channel_params_t IN865_LC3 = { 865985000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }; 00204 00205 /*! 00206 * LoRaMac channels which are allowed for the join procedure 00207 */ 00208 #define IN865_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) ) 00209 00210 /*! 00211 * Data rates table definition 00212 */ 00213 static const uint8_t datarates_IN865 [] = { 12, 11, 10, 9, 8, 7, 0, 50 }; 00214 00215 /*! 00216 * Bandwidths table definition in Hz 00217 */ 00218 static const uint32_t bandwidths_IN865 [] = { 125000, 125000, 125000, 125000, 125000, 125000, 250000, 0 }; 00219 00220 /*! 00221 * Maximum payload with respect to the datarate index. Cannot operate with repeater. 00222 */ 00223 static const uint8_t max_payloads_IN865 [] = { 51, 51, 51, 115, 242, 242, 242, 242 }; 00224 00225 /*! 00226 * Maximum payload with respect to the datarate index. Can operate with repeater. 00227 */ 00228 static const uint8_t max_payloads_with_repeater [] = { 51, 51, 51, 115, 222, 222, 222, 222 }; 00229 00230 /*! 00231 * Effective datarate offsets for receive window 1. 00232 */ 00233 static const int8_t rx1_dr_offset_IN865 [] = { 0, 1, 2, 3, 4, 5, -1, -2 }; 00234 00235 LoRaPHYIN865::LoRaPHYIN865(LoRaWANTimeHandler &lora_time) 00236 : LoRaPHY(lora_time) 00237 { 00238 bands[0] = IN865_BAND0 ; 00239 00240 // Default Channels are always enabled, rest will be added later 00241 channels[0] = IN865_LC1 ; 00242 channels[1] = IN865_LC2 ; 00243 channels[2] = IN865_LC3 ; 00244 00245 // Initialize the channels default mask 00246 default_channel_mask[0] = LC(1) + LC(2) + LC(3); 00247 // Update the channels mask 00248 copy_channel_mask(channel_mask, default_channel_mask, 1); 00249 00250 // set default channels 00251 phy_params.channels.channel_list = channels; 00252 phy_params.channels.channel_list_size = IN865_MAX_NB_CHANNELS; 00253 phy_params.channels.mask = channel_mask; 00254 phy_params.channels.default_mask = default_channel_mask; 00255 phy_params.channels.mask_size = IN865_CHANNEL_MASK_SIZE; 00256 00257 // set bands for IN865 spectrum 00258 phy_params.bands.table = (void *) bands; 00259 phy_params.bands.size = IN865_MAX_NB_BANDS; 00260 00261 // set bandwidths available in IN865 spectrum 00262 phy_params.bandwidths.table = (void *) bandwidths_IN865 ; 00263 phy_params.bandwidths.size = 8; 00264 00265 // set data rates available in IN865 spectrum 00266 phy_params.datarates.table = (void *) datarates_IN865 ; 00267 phy_params.datarates.size = 8; 00268 00269 // set payload sizes with respect to data rates 00270 phy_params.payloads.table = (void *) max_payloads_IN865 ; 00271 phy_params.payloads.size = 8; 00272 phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater ; 00273 phy_params.payloads_with_repeater.size = 8; 00274 00275 // dwell time setting 00276 phy_params.ul_dwell_time_setting = 0; 00277 phy_params.dl_dwell_time_setting = 0; 00278 00279 // set initial and default parameters 00280 phy_params.duty_cycle_enabled = IN865_DUTY_CYCLE_ENABLED; 00281 phy_params.accept_tx_param_setup_req = false; 00282 phy_params.fsk_supported = true; 00283 phy_params.cflist_supported = true; 00284 phy_params.dl_channel_req_supported = true; 00285 phy_params.custom_channelplans_supported = true; 00286 phy_params.default_channel_cnt = IN865_NUMB_DEFAULT_CHANNELS; 00287 phy_params.max_channel_cnt = IN865_MAX_NB_CHANNELS; 00288 phy_params.cflist_channel_cnt = IN865_NUMB_CHANNELS_CF_LIST; 00289 phy_params.min_tx_datarate = IN865_TX_MIN_DATARATE; 00290 phy_params.max_tx_datarate = IN865_TX_MAX_DATARATE; 00291 phy_params.min_rx_datarate = IN865_RX_MIN_DATARATE; 00292 phy_params.max_rx_datarate = IN865_RX_MAX_DATARATE; 00293 phy_params.default_datarate = IN865_DEFAULT_DATARATE; 00294 phy_params.default_max_datarate = IN865_DEFAULT_MAX_DATARATE; 00295 phy_params.min_rx1_dr_offset = IN865_MIN_RX1_DR_OFFSET; 00296 phy_params.max_rx1_dr_offset = IN865_MAX_RX1_DR_OFFSET; 00297 phy_params.default_rx1_dr_offset = IN865_DEFAULT_RX1_DR_OFFSET; 00298 phy_params.min_tx_power = IN865_MIN_TX_POWER; 00299 phy_params.max_tx_power = IN865_MAX_TX_POWER; 00300 phy_params.default_tx_power = IN865_DEFAULT_TX_POWER; 00301 phy_params.default_max_eirp = IN865_DEFAULT_MAX_EIRP; 00302 phy_params.default_antenna_gain = IN865_DEFAULT_ANTENNA_GAIN; 00303 phy_params.adr_ack_limit = IN865_ADR_ACK_LIMIT; 00304 phy_params.adr_ack_delay = IN865_ADR_ACK_DELAY; 00305 phy_params.max_rx_window = IN865_MAX_RX_WINDOW; 00306 phy_params.recv_delay1 = IN865_RECEIVE_DELAY1; 00307 phy_params.recv_delay2 = IN865_RECEIVE_DELAY2; 00308 phy_params.join_channel_mask = IN865_JOIN_CHANNELS; 00309 phy_params.join_accept_delay1 = IN865_JOIN_ACCEPT_DELAY1; 00310 phy_params.join_accept_delay2 = IN865_JOIN_ACCEPT_DELAY2; 00311 phy_params.max_fcnt_gap = IN865_MAX_FCNT_GAP; 00312 phy_params.ack_timeout = IN865_ACKTIMEOUT; 00313 phy_params.ack_timeout_rnd = IN865_ACK_TIMEOUT_RND; 00314 phy_params.rx_window2_datarate = IN865_RX_WND_2_DR; 00315 phy_params.rx_window2_frequency = IN865_RX_WND_2_FREQ; 00316 } 00317 00318 LoRaPHYIN865::~LoRaPHYIN865() 00319 { 00320 } 00321 00322 uint8_t LoRaPHYIN865::apply_DR_offset(int8_t dr, int8_t dr_offset) 00323 { 00324 // Apply offset formula 00325 return MIN(DR_5, MAX(DR_0, dr - rx1_dr_offset_IN865 [dr_offset])); 00326 }
Generated on Tue Jul 12 2022 14:23:52 by
