1 /*! 2 * \file RegionNvm.h 3 * 4 * \brief Region independent non-volatile data. 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 Daniel Jaeckle ( STACKFORCE ) 28 * 29 * \addtogroup REGIONCOMMON 30 * 31 * \{ 32 */ 33 #ifndef __REGIONNVM_H__ 34 #define __REGIONNVM_H__ 35 36 #ifdef __cplusplus 37 extern "C" 38 { 39 #endif 40 41 #include "LoRaMacTypes.h" 42 43 /*! 44 * Channel plan for region CN470 45 */ 46 typedef enum eRegionCN470ChannelPlan 47 { 48 CHANNEL_PLAN_UNKNOWN, 49 CHANNEL_PLAN_20MHZ_TYPE_A, 50 CHANNEL_PLAN_20MHZ_TYPE_B, 51 CHANNEL_PLAN_26MHZ_TYPE_A, 52 CHANNEL_PLAN_26MHZ_TYPE_B 53 }RegionCN470ChannelPlan_t; 54 55 // Selection of REGION_NVM_MAX_NB_CHANNELS 56 #if defined( REGION_CN470 ) 57 #define REGION_NVM_MAX_NB_CHANNELS 96 58 #elif defined( REGION_US915 ) || defined( REGION_AU915 ) 59 #define REGION_NVM_MAX_NB_CHANNELS 72 60 #else 61 // All others 62 #define REGION_NVM_MAX_NB_CHANNELS 16 63 #endif 64 65 // Selection of REGION_NVM_MAX_NB_BANDS 66 #if defined( REGION_EU868 ) 67 #define REGION_NVM_MAX_NB_BANDS 6 68 #else 69 // All others 70 #define REGION_NVM_MAX_NB_BANDS 1 71 #endif 72 73 // Selection of REGION_NVM_CHANNELS_MASK_SIZE 74 #if defined( REGION_CN470 ) || defined( REGION_US915 ) || \ 75 defined( REGION_AU915 ) 76 #define REGION_NVM_CHANNELS_MASK_SIZE 6 77 #else 78 // All others 79 #define REGION_NVM_CHANNELS_MASK_SIZE 1 80 #endif 81 82 /*! 83 * Region specific data which must be stored in the NVM. 84 */ 85 typedef struct sRegionNvmDataGroup1 86 { 87 #if defined( REGION_US915 ) || defined( REGION_AU915 ) || defined( REGION_CN470 ) 88 /*! 89 * LoRaMac channels remaining 90 */ 91 uint16_t ChannelsMaskRemaining[ REGION_NVM_CHANNELS_MASK_SIZE ]; 92 #endif 93 #if defined( REGION_US915 ) || defined( REGION_AU915 ) 94 /*! 95 * Index of current in use 8 bit group (0: bit 0 - 7, 1: bit 8 - 15, ..., 96 * 7: bit 56 - 63) 97 */ 98 uint8_t JoinChannelGroupsCurrentIndex; 99 /*! 100 * Counter of join trials needed to alternate between datarates. 101 */ 102 uint8_t JoinTrialsCounter; 103 #endif 104 /*! 105 * CRC32 value of the Region data structure. 106 */ 107 uint32_t Crc32; 108 }RegionNvmDataGroup1_t; 109 110 /*! 111 * Region specific data which must be stored in the NVM. 112 * Parameters which do not change very frequently. 113 */ 114 typedef struct sRegionNvmDataGroup2 115 { 116 /*! 117 * LoRaMAC channels 118 */ 119 ChannelParams_t Channels[ REGION_NVM_MAX_NB_CHANNELS ]; 120 /*! 121 * LoRaMac channels mask 122 */ 123 uint16_t ChannelsMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; 124 /*! 125 * LoRaMac channels default mask 126 */ 127 uint16_t ChannelsDefaultMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; 128 #if defined( REGION_CN470 ) 129 /*! 130 * Holds the channel plan. 131 */ 132 RegionCN470ChannelPlan_t ChannelPlan; 133 /*! 134 * Holds the common join channel, if its an OTAA device, otherwise 135 * this value is 0. 136 */ 137 uint8_t CommonJoinChannelIndex; 138 /*! 139 * Identifier which specifies if the device is an OTAA device. Set 140 * to true, if its an OTAA device. 141 */ 142 bool IsOtaaDevice; 143 #endif 144 #if defined( REGION_KR920 ) || defined( REGION_AS923 ) 145 /*! 146 * RSSI threshold for a free channel [dBm] 147 */ 148 int16_t RssiFreeThreshold; 149 150 /*! 151 * Specifies the time the node performs a carrier sense 152 */ 153 uint32_t CarrierSenseTime; 154 #endif 155 156 /*! 157 * CRC32 value of the Region data structure. 158 */ 159 uint32_t Crc32; 160 }RegionNvmDataGroup2_t; 161 162 /*! \} addtogroup REGIONCOMMON */ 163 164 #ifdef __cplusplus 165 } 166 #endif 167 168 #endif // __REGIONNVM_H__ 169