1 /*! 2 * \file RegionAU915.h 3 * 4 * \brief Region definition for AU915 5 * 6 * \copyright Revised BSD License, see section \ref LICENSE. 7 * 8 * \code 9 * ______ _ 10 * / _____) _ | | 11 * ( (____ _____ ____ _| |_ _____ ____| |__ 12 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 * _____) ) ____| | | || |_| ____( (___| | | | 14 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 * (C)2013-2017 Semtech 16 * 17 * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 * embedded.connectivity.solutions=============== 22 * 23 * \endcode 24 * 25 * \author Miguel Luis ( Semtech ) 26 * 27 * \author Gregory Cristian ( Semtech ) 28 * 29 * \author Daniel Jaeckle ( STACKFORCE ) 30 * 31 * \author Johannes Bruder ( STACKFORCE ) 32 * 33 * \defgroup REGIONAU915 Region AU915 34 * Implementation according to LoRaWAN Specification v1.0.2. 35 * \{ 36 */ 37 #ifndef __REGION_AU915_H__ 38 #define __REGION_AU915_H__ 39 40 #ifdef __cplusplus 41 extern "C" 42 { 43 #endif 44 45 #include "region/Region.h" 46 47 /*! 48 * LoRaMac maximum number of channels 49 */ 50 #define AU915_MAX_NB_CHANNELS 72 51 52 /*! 53 * Minimal datarate that can be used by the node 54 */ 55 #define AU915_TX_MIN_DATARATE DR_0 56 57 /*! 58 * Maximal datarate that can be used by the node 59 */ 60 #define AU915_TX_MAX_DATARATE DR_13 61 62 /*! 63 * Minimal datarate that can be used by the node 64 */ 65 #define AU915_RX_MIN_DATARATE DR_8 66 67 /*! 68 * Maximal datarate that can be used by the node 69 */ 70 #define AU915_RX_MAX_DATARATE DR_13 71 72 /*! 73 * Default datarate used by the node 74 */ 75 #define AU915_DEFAULT_DATARATE DR_2 76 77 /*! 78 * The minimum datarate which is used when the 79 * dwell time is limited. 80 */ 81 #define AU915_DWELL_LIMIT_DATARATE DR_2 82 83 /*! 84 * Minimal Rx1 receive datarate offset 85 */ 86 #define AU915_MIN_RX1_DR_OFFSET 0 87 88 /*! 89 * Maximal Rx1 receive datarate offset 90 */ 91 #define AU915_MAX_RX1_DR_OFFSET 5 92 93 /*! 94 * Minimal Tx output power that can be used by the node 95 */ 96 #define AU915_MIN_TX_POWER TX_POWER_14 97 98 /*! 99 * Maximal Tx output power that can be used by the node 100 */ 101 #define AU915_MAX_TX_POWER TX_POWER_0 102 103 /*! 104 * Default Tx output power used by the node 105 */ 106 #define AU915_DEFAULT_TX_POWER TX_POWER_0 107 108 /*! 109 * Default uplink dwell time configuration 110 */ 111 #define AU915_DEFAULT_UPLINK_DWELL_TIME 1 112 113 /*! 114 * Default Max EIRP 115 */ 116 #define AU915_DEFAULT_MAX_EIRP 30.0f 117 118 /*! 119 * Default antenna gain 120 */ 121 #define AU915_DEFAULT_ANTENNA_GAIN 2.15f 122 123 /*! 124 * Enabled or disabled the duty cycle 125 */ 126 #define AU915_DUTY_CYCLE_ENABLED 0 127 128 /*! 129 * Maximum RX window duration 130 */ 131 #define AU915_MAX_RX_WINDOW 3000 132 133 /*! 134 * Second reception window channel frequency definition. 135 */ 136 #define AU915_RX_WND_2_FREQ 923300000 137 138 /*! 139 * Second reception window channel datarate definition. 140 */ 141 #define AU915_RX_WND_2_DR DR_8 142 143 /* 144 * CLASS B 145 */ 146 /*! 147 * Beacon frequency 148 */ 149 #define AU915_BEACON_CHANNEL_FREQ 923300000 150 151 /*! 152 * Beacon frequency channel stepwidth 153 */ 154 #define AU915_BEACON_CHANNEL_STEPWIDTH 600000 155 156 /*! 157 * Ping slot channel frequency 158 */ 159 #define AU915_PING_SLOT_CHANNEL_FREQ 923300000 160 161 /*! 162 * Number of possible beacon channels 163 */ 164 #define AU915_BEACON_NB_CHANNELS 8 165 166 /*! 167 * Payload size of a beacon frame 168 */ 169 #define AU915_BEACON_SIZE 23 170 171 /*! 172 * Size of RFU 1 field 173 */ 174 #define AU915_RFU1_SIZE 4 175 176 /*! 177 * Size of RFU 2 field 178 */ 179 #define AU915_RFU2_SIZE 3 180 181 /*! 182 * Datarate of the beacon channel 183 */ 184 #define AU915_BEACON_CHANNEL_DR DR_8 185 186 /*! 187 * Bandwith of the beacon channel 188 */ 189 #define AU915_BEACON_CHANNEL_BW 2 190 191 /*! 192 * Ping slot channel datarate 193 */ 194 #define AU915_PING_SLOT_CHANNEL_DR DR_8 195 196 /*! 197 * LoRaMac maximum number of bands 198 */ 199 #define AU915_MAX_NB_BANDS 1 200 201 /*! 202 * Band 0 definition 203 * Band = { DutyCycle, TxMaxPower, LastBandUpdateTime, LastMaxCreditAssignTime, TimeCredits, MaxTimeCredits, ReadyForTransmission } 204 */ 205 #define AU915_BAND0 { 1, AU915_MAX_TX_POWER, 0, 0, 0, 0, 0 } // 100.0 % 206 207 /*! 208 * Defines the first channel for RX window 1 for US band 209 */ 210 #define AU915_FIRST_RX1_CHANNEL ( (uint32_t) 923300000 ) 211 212 /*! 213 * Defines the last channel for RX window 1 for US band 214 */ 215 #define AU915_LAST_RX1_CHANNEL ( (uint32_t) 927500000 ) 216 217 /*! 218 * Defines the step width of the channels for RX window 1 219 */ 220 #define AU915_STEPWIDTH_RX1_CHANNEL ( (uint32_t) 600000 ) 221 222 /*! 223 * Data rates table definition 224 */ 225 static const uint8_t DataratesAU915[] = { 12, 11, 10, 9, 8, 7, 8, 0, 12, 11, 10, 9, 8, 7, 0, 0 }; 226 227 /*! 228 * Bandwidths table definition in Hz 229 */ 230 static const uint32_t BandwidthsAU915[] = { 125000, 125000, 125000, 125000, 125000, 125000, 500000, 0, 500000, 500000, 500000, 500000, 500000, 500000, 0, 0 }; 231 232 /*! 233 * Up/Down link data rates offset definition 234 */ 235 static const int8_t DatarateOffsetsAU915[7][6] = 236 { 237 { DR_8 , DR_8 , DR_8 , DR_8 , DR_8 , DR_8 }, // DR_0 238 { DR_9 , DR_8 , DR_8 , DR_8 , DR_8 , DR_8 }, // DR_1 239 { DR_10, DR_9 , DR_8 , DR_8 , DR_8 , DR_8 }, // DR_2 240 { DR_11, DR_10, DR_9 , DR_8 , DR_8 , DR_8 }, // DR_3 241 { DR_12, DR_11, DR_10, DR_9 , DR_8 , DR_8 }, // DR_4 242 { DR_13, DR_12, DR_11, DR_10, DR_9 , DR_8 }, // DR_5 243 { DR_13, DR_13, DR_12, DR_11, DR_10, DR_9 }, // DR_6 244 }; 245 246 /*! 247 * Maximum payload with respect to the datarate index. 248 * The table is valid for the dwell time configuration of 0 for uplinks. 249 */ 250 static const uint8_t MaxPayloadOfDatarateDwell0AU915[] = { 51, 51, 51, 115, 242, 242, 242, 0, 53, 129, 242, 242, 242, 242 }; 251 252 /*! 253 * Maximum payload with respect to the datarate index. 254 * The table is valid for the dwell time configuration of 1 for uplinks. 255 */ 256 static const uint8_t MaxPayloadOfDatarateDwell1AU915[] = { 0, 0, 11, 53, 125, 242, 242, 0, 53, 129, 242, 242, 242, 242 }; 257 258 /*! 259 * \brief The function gets a value of a specific phy attribute. 260 * 261 * \param [IN] getPhy Pointer to the function parameters. 262 * 263 * \retval Returns a structure containing the PHY parameter. 264 */ 265 PhyParam_t RegionAU915GetPhyParam( GetPhyParams_t* getPhy ); 266 267 /*! 268 * \brief Updates the last TX done parameters of the current channel. 269 * 270 * \param [IN] txDone Pointer to the function parameters. 271 */ 272 void RegionAU915SetBandTxDone( SetBandTxDoneParams_t* txDone ); 273 274 /*! 275 * \brief Initializes the channels masks and the channels. 276 * 277 * \param [IN] type Sets the initialization type. 278 */ 279 void RegionAU915InitDefaults( InitDefaultsParams_t* params ); 280 281 /*! 282 * \brief Verifies a parameter. 283 * 284 * \param [IN] verify Pointer to the function parameters. 285 * 286 * \param [IN] type Sets the initialization type. 287 * 288 * \retval Returns true, if the parameter is valid. 289 */ 290 bool RegionAU915Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute ); 291 292 /*! 293 * \brief The function parses the input buffer and sets up the channels of the 294 * CF list. 295 * 296 * \param [IN] applyCFList Pointer to the function parameters. 297 */ 298 void RegionAU915ApplyCFList( ApplyCFListParams_t* applyCFList ); 299 300 /*! 301 * \brief Sets a channels mask. 302 * 303 * \param [IN] chanMaskSet Pointer to the function parameters. 304 * 305 * \retval Returns true, if the channels mask could be set. 306 */ 307 bool RegionAU915ChanMaskSet( ChanMaskSetParams_t* chanMaskSet ); 308 309 /*! 310 * Computes the Rx window timeout and offset. 311 * 312 * \param [IN] datarate Rx window datarate index to be used 313 * 314 * \param [IN] minRxSymbols Minimum required number of symbols to detect an Rx frame. 315 * 316 * \param [IN] rxError System maximum timing error of the receiver. In milliseconds 317 * The receiver will turn on in a [-rxError : +rxError] ms 318 * interval around RxOffset 319 * 320 * \param [OUT]rxConfigParams Returns updated WindowTimeout and WindowOffset fields. 321 */ 322 void RegionAU915ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams ); 323 324 /*! 325 * \brief Configuration of the RX windows. 326 * 327 * \param [IN] rxConfig Pointer to the function parameters. 328 * 329 * \param [OUT] datarate The datarate index which was set. 330 * 331 * \retval Returns true, if the configuration was applied successfully. 332 */ 333 bool RegionAU915RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate ); 334 335 /*! 336 * \brief TX configuration. 337 * 338 * \param [IN] txConfig Pointer to the function parameters. 339 * 340 * \param [OUT] txPower The tx power index which was set. 341 * 342 * \param [OUT] txTimeOnAir The time-on-air of the frame. 343 * 344 * \retval Returns true, if the configuration was applied successfully. 345 */ 346 bool RegionAU915TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime_t* txTimeOnAir ); 347 348 /*! 349 * \brief The function processes a Link ADR Request. 350 * 351 * \param [IN] linkAdrReq Pointer to the function parameters. 352 * 353 * \retval Returns the status of the operation, according to the LoRaMAC specification. 354 */ 355 uint8_t RegionAU915LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed ); 356 357 /*! 358 * \brief The function processes a RX Parameter Setup Request. 359 * 360 * \param [IN] rxParamSetupReq Pointer to the function parameters. 361 * 362 * \retval Returns the status of the operation, according to the LoRaMAC specification. 363 */ 364 uint8_t RegionAU915RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq ); 365 366 /*! 367 * \brief The function processes a Channel Request. 368 * 369 * \param [IN] newChannelReq Pointer to the function parameters. 370 * 371 * \retval Returns the status of the operation, according to the LoRaMAC specification. 372 */ 373 int8_t RegionAU915NewChannelReq( NewChannelReqParams_t* newChannelReq ); 374 375 /*! 376 * \brief The function processes a TX ParamSetup Request. 377 * 378 * \param [IN] txParamSetupReq Pointer to the function parameters. 379 * 380 * \retval Returns the status of the operation, according to the LoRaMAC specification. 381 * Returns -1, if the functionality is not implemented. In this case, the end node 382 * shall not process the command. 383 */ 384 int8_t RegionAU915TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq ); 385 386 /*! 387 * \brief The function processes a DlChannel Request. 388 * 389 * \param [IN] dlChannelReq Pointer to the function parameters. 390 * 391 * \retval Returns the status of the operation, according to the LoRaMAC specification. 392 */ 393 int8_t RegionAU915DlChannelReq( DlChannelReqParams_t* dlChannelReq ); 394 395 /*! 396 * \brief Alternates the datarate of the channel for the join request. 397 * 398 * \param [IN] currentDr Current datarate. 399 * 400 * \retval Datarate to apply. 401 */ 402 int8_t RegionAU915AlternateDr( int8_t currentDr, AlternateDrType_t type ); 403 404 /*! 405 * \brief Searches and set the next random available channel 406 * 407 * \param [OUT] channel Next channel to use for TX. 408 * 409 * \param [OUT] time Time to wait for the next transmission according to the duty 410 * cycle. 411 * 412 * \param [OUT] aggregatedTimeOff Updates the aggregated time off. 413 * 414 * \retval Function status [1: OK, 0: Unable to find a channel on the current datarate] 415 */ 416 LoRaMacStatus_t RegionAU915NextChannel( NextChanParams_t* nextChanParams, uint8_t* channel, TimerTime_t* time, TimerTime_t* aggregatedTimeOff ); 417 418 /*! 419 * \brief Adds a channel. 420 * 421 * \param [IN] channelAdd Pointer to the function parameters. 422 * 423 * \retval Status of the operation. 424 */ 425 LoRaMacStatus_t RegionAU915ChannelAdd( ChannelAddParams_t* channelAdd ); 426 427 /*! 428 * \brief Removes a channel. 429 * 430 * \param [IN] channelRemove Pointer to the function parameters. 431 * 432 * \retval Returns true, if the channel was removed successfully. 433 */ 434 bool RegionAU915ChannelsRemove( ChannelRemoveParams_t* channelRemove ); 435 436 /*! 437 * \brief Computes new datarate according to the given offset 438 * 439 * \param [IN] downlinkDwellTime Downlink dwell time configuration. 0: No limit, 1: 400ms 440 * 441 * \param [IN] dr Current datarate 442 * 443 * \param [IN] drOffset Offset to be applied 444 * 445 * \retval newDr Computed datarate. 446 */ 447 uint8_t RegionAU915ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset ); 448 449 /*! 450 * \brief Sets the radio into beacon reception mode 451 * 452 * \param [IN] rxBeaconSetup Pointer to the function parameters 453 */ 454 void RegionAU915RxBeaconSetup( RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr ); 455 456 /*! \} defgroup REGIONAU915 */ 457 458 #ifdef __cplusplus 459 } 460 #endif 461 462 #endif // __REGION_AU915_H__ 463