SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
LoRaConfig.h
00001 /** 00002 * @file LoRaConfig.h 00003 * 00004 * @author Adrian 00005 * @date Jun 11, 2016 00006 * 00007 */ 00008 00009 #include <string> 00010 #include <stdint.h> 00011 #include <vector> 00012 #ifndef LORACONFIG_H_ 00013 #define LORACONFIG_H_ 00014 00015 #define LORA_NETWORK_NAME "conduitgwy" 00016 #define LORA_NETWORK_PASSPHRASE "conduitgwy" 00017 00018 #define LORA_SUBBAND_0 0 00019 #define LORA_SUBBAND_1 1 00020 #define LORA_SUBBAND_2 2 00021 #define LORA_SUBBAND_3 3 00022 #define LORA_SUBBAND_4 4 00023 #define LORA_SUBBAND_5 5 00024 #define LORA_SUBBAND_6 6 00025 #define LORA_SUBBAND_7 7 00026 #define LORA_SUBBAND_8 8 00027 00028 #define LORA_SPREADING_FACTOR_7 7 00029 #define LORA_SPREADING_FACTOR_8 8 00030 #define LORA_SPREADING_FACTOR_9 9 00031 #define LORA_SPREADING_FACTOR_10 10 00032 #define LORA_SPREADING_FACTOR_11 11 00033 #define LORA_SPREADING_FACTOR_12 12 00034 00035 #define LORA_TX_POWER_2_DBM 2 00036 #define LORA_TX_POWER_4_DBM 4 00037 #define LORA_TX_POWER_8_DBM 8 00038 #define LORA_TX_POWER_16_DBM 16 00039 #define LORA_TX_POWER_20_DBM 20 00040 00041 #define LORA_ACKNOWLEDGE_RETRIES_0 0 00042 #define LORA_ACKNOWLEDGE_RETRIES_1 1 00043 #define LORA_ACKNOWLEDGE_RETRIES_2 2 00044 00045 /** 00046 * LoRa Modes. 00047 */ 00048 enum LORA_MODE{ 00049 LORA_MODE_0_OFF = 0,//!< LORA_MODE_0 00050 LORA_MODE_1 = 1,//!< LORA_MODE_1 00051 LORA_MODE_2 = 2,//!< LORA_MODE_2 00052 LORA_MODE_3 = 3,//!< LORA_MODE_3 00053 LORA_MODE_4 = 4,//!< LORA_MODE_4 00054 LORA_MODE_5 = 5,//!< LORA_MODE_5 00055 }; 00056 00057 /** 00058 * Join Modes for LoRa 00059 */ 00060 enum JOIN_MODE{ 00061 OTA = 0,//!< OTTA 00062 ABP = 1 //!< ABP 00063 }; 00064 00065 //static uint8_t LORA_APP_EUI[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88};/ 00066 //static uint8_t LORA_APP_KEY[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x00}; 00067 //static uint8_t LORA_DEVICE_EUI[] = {0x00,0x80,0x00,0x00,0x00,0x00,0xff,0xff}; 00068 00069 static uint8_t LORA_APP_EUI[] = { 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x00, 0x09, 0x08 };//msb from 'App EUI' of Devive type 'OTAA' 00070 static uint8_t LORA_APP_KEY[] = { 0xCF, 0x3F, 0x6C, 0xFC, 0x9C, 0x0E, 0x20, 0x64, 0x5E, 0x8D, 0x70, 0x97, 0xC3, 0x20, 0x12, 0x21 };//msb from 'App Key' of Devive type 'OTAA' 00071 static uint8_t LORA_DEVICE_EUI[] = { 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x36 };//msb from 'Dev EUI' of Devive type 'OTAA' 00072 00073 00074 00075 /** 00076 * @class LoRaConfig 00077 * @brief A configuration container for the LoRa Module. 00078 * All its configuration values are stored an held inside 00079 * this Class. Depending on the LORA_MODE it sets all the configuration values. 00080 */ 00081 class LoRaConfig { 00082 public: 00083 LoRaConfig(); 00084 virtual ~LoRaConfig(); 00085 00086 /** 00087 * @brief Generates a configuration according to the chosen LORA_MODE 00088 * by setting all LoRa Module specific configuration values depending on the chosen LORA_MODE 00089 * @param desiredMode the mode to build the configuration according to 00090 */ 00091 void build(LORA_MODE desiredMode); 00092 00093 /** 00094 * @brief Gets info if the Network to which the LoRa Module sings up 00095 * is public or not from its Configuration 00096 */ 00097 bool isPublic(); 00098 00099 /** 00100 * @brief Gets info if LoRa Module will be active and run or not 00101 * from its Configuration 00102 * @return 00103 */ 00104 bool isActiv(); 00105 00106 /** 00107 * @brief Gets the name of the Network to which the LoRa Module sings up 00108 * from its Configuration 00109 * @return 00110 */ 00111 std::string getNetworkName(); 00112 00113 /** 00114 * @brief Gets the Passphrase of the Network to which the LoRa Module sings up 00115 * from its Configuration 00116 * @return 00117 */ 00118 std::string getNetworkPassphrase(); 00119 00120 /** 00121 * @brief Gets the Network Address. Only used when using ABP JoinMode 00122 * @return 00123 */ 00124 std::string getNetworkAddress(); 00125 00126 /** 00127 * @brief Gets the App EUI 00128 * @return 00129 */ 00130 std::vector<uint8_t> getAppEUI(); 00131 00132 /** 00133 * @brief Gets the App Key 00134 * @return 00135 */ 00136 std::vector<uint8_t> getAppKey(); 00137 00138 /** 00139 * @brief Gets the Device EUI 00140 * @return 00141 */ 00142 std::vector<uint8_t> getDeviceEUI(); 00143 00144 /** 00145 * @brief Gets the frequency SubBand that will be used by the LoRa Module to 00146 * send and receive its data from its Configuration 00147 * @return 00148 */ 00149 uint8_t getFrequencySubBand(); 00150 00151 /** 00152 * @brief Gets the spreading Factor that the LoRa Module will us for data transmission 00153 * from its Configuration 00154 * @return 00155 */ 00156 uint8_t getSpreadingFactor(); 00157 00158 /** 00159 * @brief Gets the transmission Power of the LoRa Module from its Configuration 00160 * @return 00161 */ 00162 uint8_t getTxPowerdBm(); 00163 00164 /** 00165 * @brief Gets the number of Acknowledgment Retries that will be made 00166 * from its Configuration 00167 * @return 00168 */ 00169 uint8_t getAcknowledgeRetries(); 00170 00171 /** 00172 * @brief Gets the Actual LORA_MODE of the built LoRaConfiguration 00173 * from its Configuration 00174 * @return 00175 */ 00176 LORA_MODE getLORA_MODE(); 00177 00178 /** 00179 * @brief Gets the Actual JOIN_MODE of the built LoRaConfiguration 00180 * form its Configuration 00181 * @return 00182 */ 00183 JOIN_MODE getJOIN_MODE(); 00184 00185 00186 private: 00187 std::string* networkName; 00188 std::string* networkPassphrase; 00189 std::string* networkAddress; 00190 std::vector<uint8_t>* appEUI; 00191 std::vector<uint8_t>* appKey; 00192 std::vector<uint8_t>* deviceEUI; 00193 bool publicity; 00194 bool activity; 00195 uint8_t frequencySubBand; 00196 uint8_t spreadingFactor; 00197 uint8_t txPowerdBm; 00198 uint8_t acknowledgeRetries; 00199 00200 LORA_MODE loraMode; 00201 JOIN_MODE joinMode; 00202 00203 00204 /** 00205 * @brief Sets the Network publicity of the network that will be used in the Configuration 00206 * @param 00207 */ 00208 void setNetworkPublicity(bool publicity); 00209 00210 /** 00211 * @brief Sets the Activity of the LoRa module for the Configuration 00212 * @param activity true = module will be active false = module will not be active 00213 */ 00214 void setActivity(bool activity); 00215 00216 /** 00217 * @brief Sets the Name of the Network that will be used in the Configuration 00218 * @param networkName the name of the network 00219 */ 00220 void setNetworkName(char* networkName); 00221 00222 /** 00223 * @brief Sets the Passphrase of the Network that will be used in the Configuration 00224 * @param networkPassphrase passphrase of the Network 00225 */ 00226 void setNetworkPassphrase(char* networkPassphrase); 00227 00228 /** 00229 * @brief Sets the Networkaddress of the Network that will be used in the Configuration 00230 * @param networkAddress 00231 */ 00232 void setNetworkAddress(char* networkAddress); 00233 00234 /** 00235 * @brief Sets the APP EUI for OTAA 00236 * @param appEUI 00237 */ 00238 void setAppEUI(); 00239 00240 /** 00241 * @brief Sets the APP Key for OTAA 00242 * @param appKey 00243 */ 00244 void setAppKey(); 00245 00246 /** 00247 * @brief Sets the device EUI for OTAA 00248 * @param deviceEUI 00249 */ 00250 void setDeviceEUI(); 00251 00252 00253 /** 00254 * @brief Sets the SubBand that will be used in by the LoRa Module in the Configuration 00255 * @param subBand the SubBand that will be used 00256 */ 00257 void setFrequencySubBand(uint8_t subBand); 00258 00259 /** 00260 * @brief Sets the spreading Factor of a LoRa Data Transmission in the Configuration 00261 * @param spreadingFactor 00262 */ 00263 void setSpreadingFactor(uint8_t spreadingFactor); 00264 00265 /** 00266 * @brief Sets the Data transmission Power via LoRa in the Configuration 00267 * @param 00268 */ 00269 void setTxPowerdBm(uint8_t ); 00270 00271 /** 00272 * @brief Set the Acknowledgment Retries in the Configuration 00273 * @param 00274 */ 00275 void setAcknowledgeRetries(uint8_t); 00276 00277 /** 00278 * @brief Sets the LORA_MODE of the Configuration 00279 * @param 00280 */ 00281 void setLORA_MODE(LORA_MODE); 00282 00283 /** 00284 * @brief Sets the Join Mode to a Network 00285 * @param 00286 */ 00287 void setJOIN_MODE(JOIN_MODE); 00288 00289 }; 00290 00291 #endif /* LORACONFIG_H_ */
Generated on Wed Jul 13 2022 09:23:47 by 1.7.2