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 #elif defined( REGION_AS923 ) || defined( REGION_CN779 ) || \ 61 defined( REGION_EU433 ) || defined( REGION_EU868 ) || \ 62 defined( REGION_IN865 ) || defined( REGION_KR920 ) 63 #define REGION_NVM_MAX_NB_CHANNELS 16 64 #else 65 // Region_RU864 66 #define REGION_NVM_MAX_NB_CHANNELS 8 67 #endif 68 69 // Selection of REGION_NVM_MAX_NB_BANDS 70 #if defined( REGION_EU868 ) 71 #define REGION_NVM_MAX_NB_BANDS 6 72 #else 73 // All others 74 #define REGION_NVM_MAX_NB_BANDS 1 75 #endif 76 77 // Selection of REGION_NVM_CHANNELS_MASK_SIZE 78 #if defined( REGION_CN470 ) || defined( REGION_US915 ) || \ 79 defined( REGION_AU915 ) 80 #define REGION_NVM_CHANNELS_MASK_SIZE 6 81 #else 82 // All others 83 #define REGION_NVM_CHANNELS_MASK_SIZE 1 84 #endif 85 86 /*! 87 * Region specific data which must be stored in the NVM. 88 */ 89 typedef struct sRegionNvmDataGroup1 90 { 91 #if defined( REGION_US915 ) || defined( REGION_AU915 ) || defined( REGION_CN470 ) 92 /*! 93 * LoRaMac channels remaining 94 */ 95 uint16_t ChannelsMaskRemaining[ REGION_NVM_CHANNELS_MASK_SIZE ]; 96 #endif 97 #if defined( REGION_US915 ) || defined( REGION_AU915 ) 98 /*! 99 * Index of current in use 8 bit group (0: bit 0 - 7, 1: bit 8 - 15, ..., 100 * 7: bit 56 - 63) 101 */ 102 uint8_t JoinChannelGroupsCurrentIndex; 103 /*! 104 * Counter of join trials needed to alternate between datarates. 105 */ 106 uint8_t JoinTrialsCounter; 107 #endif 108 /*! 109 * CRC32 value of the Region data structure. 110 */ 111 uint32_t Crc32; 112 }RegionNvmDataGroup1_t; 113 114 /*! 115 * Region specific data which must be stored in the NVM. 116 * Parameters which do not change very frequently. 117 */ 118 typedef struct sRegionNvmDataGroup2 119 { 120 /*! 121 * LoRaMAC channels 122 */ 123 ChannelParams_t Channels[ REGION_NVM_MAX_NB_CHANNELS ]; 124 /*! 125 * LoRaMac channels mask 126 */ 127 uint16_t ChannelsMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; 128 /*! 129 * LoRaMac channels default mask 130 */ 131 uint16_t ChannelsDefaultMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; 132 #if defined( REGION_CN470 ) 133 /*! 134 * Holds the channel plan. 135 */ 136 RegionCN470ChannelPlan_t ChannelPlan; 137 /*! 138 * Holds the common join channel, if its an OTAA device, otherwise 139 * this value is 0. 140 */ 141 uint8_t CommonJoinChannelIndex; 142 /*! 143 * Identifier which specifies if the device is an OTAA device. Set 144 * to true, if its an OTAA device. 145 */ 146 bool IsOtaaDevice; 147 #endif 148 /*! 149 * CRC32 value of the Region data structure. 150 */ 151 uint32_t Crc32; 152 }RegionNvmDataGroup2_t; 153 154 /*! \} addtogroup REGIONCOMMON */ 155 156 #ifdef __cplusplus 157 } 158 #endif 159 160 #endif // __REGIONNVM_H__ 161