SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
app/LoRaConfig.h@4:135e5ebdf555, 2016-08-14 (annotated)
- Committer:
- skramer
- Date:
- Sun Aug 14 19:56:43 2016 +0000
- Revision:
- 4:135e5ebdf555
- Parent:
- 1:fe242f3e341b
- Child:
- 5:cbf3fce508e1
Working OTAA with BME280 sensor;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mitea1 | 0:f2815503561f | 1 | /** |
mitea1 | 0:f2815503561f | 2 | * @file LoRaConfig.h |
mitea1 | 0:f2815503561f | 3 | * |
mitea1 | 0:f2815503561f | 4 | * @author Adrian |
mitea1 | 0:f2815503561f | 5 | * @date Jun 11, 2016 |
mitea1 | 0:f2815503561f | 6 | * |
mitea1 | 0:f2815503561f | 7 | */ |
mitea1 | 0:f2815503561f | 8 | |
mitea1 | 0:f2815503561f | 9 | #include <string> |
mitea1 | 0:f2815503561f | 10 | #include <stdint.h> |
mitea1 | 1:fe242f3e341b | 11 | #include <vector> |
mitea1 | 0:f2815503561f | 12 | #ifndef LORACONFIG_H_ |
mitea1 | 0:f2815503561f | 13 | #define LORACONFIG_H_ |
mitea1 | 0:f2815503561f | 14 | |
mitea1 | 1:fe242f3e341b | 15 | #define LORA_NETWORK_NAME "conduitgwy" |
mitea1 | 1:fe242f3e341b | 16 | #define LORA_NETWORK_PASSPHRASE "conduitgwy" |
mitea1 | 0:f2815503561f | 17 | |
mitea1 | 0:f2815503561f | 18 | #define LORA_SUBBAND_0 0 |
mitea1 | 0:f2815503561f | 19 | #define LORA_SUBBAND_1 1 |
mitea1 | 0:f2815503561f | 20 | #define LORA_SUBBAND_2 2 |
mitea1 | 0:f2815503561f | 21 | #define LORA_SUBBAND_3 3 |
mitea1 | 0:f2815503561f | 22 | #define LORA_SUBBAND_4 4 |
mitea1 | 0:f2815503561f | 23 | #define LORA_SUBBAND_5 5 |
mitea1 | 0:f2815503561f | 24 | #define LORA_SUBBAND_6 6 |
mitea1 | 0:f2815503561f | 25 | #define LORA_SUBBAND_7 7 |
mitea1 | 0:f2815503561f | 26 | #define LORA_SUBBAND_8 8 |
mitea1 | 0:f2815503561f | 27 | |
mitea1 | 0:f2815503561f | 28 | #define LORA_SPREADING_FACTOR_7 7 |
mitea1 | 0:f2815503561f | 29 | #define LORA_SPREADING_FACTOR_8 8 |
mitea1 | 0:f2815503561f | 30 | #define LORA_SPREADING_FACTOR_9 9 |
mitea1 | 0:f2815503561f | 31 | #define LORA_SPREADING_FACTOR_10 10 |
mitea1 | 0:f2815503561f | 32 | #define LORA_SPREADING_FACTOR_11 11 |
mitea1 | 0:f2815503561f | 33 | #define LORA_SPREADING_FACTOR_12 12 |
mitea1 | 0:f2815503561f | 34 | |
mitea1 | 0:f2815503561f | 35 | #define LORA_TX_POWER_2_DBM 2 |
mitea1 | 0:f2815503561f | 36 | #define LORA_TX_POWER_4_DBM 4 |
mitea1 | 0:f2815503561f | 37 | #define LORA_TX_POWER_8_DBM 8 |
mitea1 | 0:f2815503561f | 38 | #define LORA_TX_POWER_16_DBM 16 |
mitea1 | 0:f2815503561f | 39 | #define LORA_TX_POWER_20_DBM 20 |
mitea1 | 0:f2815503561f | 40 | |
mitea1 | 0:f2815503561f | 41 | #define LORA_ACKNOWLEDGE_RETRIES_0 0 |
mitea1 | 0:f2815503561f | 42 | #define LORA_ACKNOWLEDGE_RETRIES_1 1 |
mitea1 | 0:f2815503561f | 43 | #define LORA_ACKNOWLEDGE_RETRIES_2 2 |
mitea1 | 0:f2815503561f | 44 | |
mitea1 | 0:f2815503561f | 45 | /** |
mitea1 | 0:f2815503561f | 46 | * LoRa Modes. |
mitea1 | 0:f2815503561f | 47 | */ |
mitea1 | 0:f2815503561f | 48 | enum LORA_MODE{ |
mitea1 | 0:f2815503561f | 49 | LORA_MODE_0_OFF = 0,//!< LORA_MODE_0 |
mitea1 | 0:f2815503561f | 50 | LORA_MODE_1 = 1,//!< LORA_MODE_1 |
mitea1 | 0:f2815503561f | 51 | LORA_MODE_2 = 2,//!< LORA_MODE_2 |
mitea1 | 0:f2815503561f | 52 | LORA_MODE_3 = 3,//!< LORA_MODE_3 |
mitea1 | 0:f2815503561f | 53 | LORA_MODE_4 = 4,//!< LORA_MODE_4 |
mitea1 | 0:f2815503561f | 54 | LORA_MODE_5 = 5,//!< LORA_MODE_5 |
mitea1 | 0:f2815503561f | 55 | }; |
mitea1 | 0:f2815503561f | 56 | |
mitea1 | 0:f2815503561f | 57 | /** |
mitea1 | 1:fe242f3e341b | 58 | * Join Modes for LoRa |
mitea1 | 1:fe242f3e341b | 59 | */ |
mitea1 | 1:fe242f3e341b | 60 | enum JOIN_MODE{ |
mitea1 | 1:fe242f3e341b | 61 | OTA = 0,//!< OTTA |
mitea1 | 1:fe242f3e341b | 62 | ABP = 1 //!< ABP |
mitea1 | 1:fe242f3e341b | 63 | }; |
mitea1 | 1:fe242f3e341b | 64 | |
skramer | 4:135e5ebdf555 | 65 | //static uint8_t LORA_APP_EUI[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88};/ |
skramer | 4:135e5ebdf555 | 66 | //static uint8_t LORA_APP_KEY[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,0x00}; |
skramer | 4:135e5ebdf555 | 67 | //static uint8_t LORA_DEVICE_EUI[] = {0x00,0x80,0x00,0x00,0x00,0x00,0xff,0xff}; |
skramer | 4:135e5ebdf555 | 68 | |
skramer | 4:135e5ebdf555 | 69 | static uint8_t LORA_APP_EUI[] = { 0x70, 0xB3, 0xD5, 0x7E, 0xD0, 0x00, 0x09, 0x08 }; |
skramer | 4:135e5ebdf555 | 70 | static uint8_t LORA_APP_KEY[] = { 0xCF, 0x3F, 0x6C, 0xFC, 0x9C, 0x0E, 0x20, 0x64, 0x5E, 0x8D, 0x70, 0x97, 0xC3, 0x20, 0x12, 0x21 }; |
skramer | 4:135e5ebdf555 | 71 | static uint8_t LORA_DEVICE_EUI[] = { 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xBF, 0x36 }; |
skramer | 4:135e5ebdf555 | 72 | |
skramer | 4:135e5ebdf555 | 73 | |
mitea1 | 1:fe242f3e341b | 74 | |
mitea1 | 1:fe242f3e341b | 75 | /** |
mitea1 | 0:f2815503561f | 76 | * @class LoRaConfig |
mitea1 | 0:f2815503561f | 77 | * @brief A configuration container for the LoRa Module. |
mitea1 | 0:f2815503561f | 78 | * All its configuration values are stored an held inside |
mitea1 | 0:f2815503561f | 79 | * this Class. Depending on the LORA_MODE it sets all the configuration values. |
mitea1 | 0:f2815503561f | 80 | */ |
mitea1 | 0:f2815503561f | 81 | class LoRaConfig { |
mitea1 | 0:f2815503561f | 82 | public: |
mitea1 | 0:f2815503561f | 83 | LoRaConfig(); |
mitea1 | 0:f2815503561f | 84 | virtual ~LoRaConfig(); |
mitea1 | 0:f2815503561f | 85 | |
mitea1 | 0:f2815503561f | 86 | /** |
mitea1 | 0:f2815503561f | 87 | * @brief Generates a configuration according to the chosen LORA_MODE |
mitea1 | 0:f2815503561f | 88 | * by setting all LoRa Module specific configuration values depending on the chosen LORA_MODE |
mitea1 | 0:f2815503561f | 89 | * @param desiredMode the mode to build the configuration according to |
mitea1 | 0:f2815503561f | 90 | */ |
mitea1 | 0:f2815503561f | 91 | void build(LORA_MODE desiredMode); |
mitea1 | 0:f2815503561f | 92 | |
mitea1 | 0:f2815503561f | 93 | /** |
mitea1 | 0:f2815503561f | 94 | * @brief Gets info if the Network to which the LoRa Module sings up |
mitea1 | 0:f2815503561f | 95 | * is public or not from its Configuration |
mitea1 | 0:f2815503561f | 96 | */ |
mitea1 | 0:f2815503561f | 97 | bool isPublic(); |
mitea1 | 0:f2815503561f | 98 | |
mitea1 | 0:f2815503561f | 99 | /** |
mitea1 | 0:f2815503561f | 100 | * @brief Gets info if LoRa Module will be active and run or not |
mitea1 | 0:f2815503561f | 101 | * from its Configuration |
mitea1 | 0:f2815503561f | 102 | * @return |
mitea1 | 0:f2815503561f | 103 | */ |
mitea1 | 0:f2815503561f | 104 | bool isActiv(); |
mitea1 | 0:f2815503561f | 105 | |
mitea1 | 0:f2815503561f | 106 | /** |
mitea1 | 0:f2815503561f | 107 | * @brief Gets the name of the Network to which the LoRa Module sings up |
mitea1 | 0:f2815503561f | 108 | * from its Configuration |
mitea1 | 0:f2815503561f | 109 | * @return |
mitea1 | 0:f2815503561f | 110 | */ |
mitea1 | 0:f2815503561f | 111 | std::string getNetworkName(); |
mitea1 | 0:f2815503561f | 112 | |
mitea1 | 0:f2815503561f | 113 | /** |
mitea1 | 0:f2815503561f | 114 | * @brief Gets the Passphrase of the Network to which the LoRa Module sings up |
mitea1 | 0:f2815503561f | 115 | * from its Configuration |
mitea1 | 0:f2815503561f | 116 | * @return |
mitea1 | 0:f2815503561f | 117 | */ |
mitea1 | 0:f2815503561f | 118 | std::string getNetworkPassphrase(); |
mitea1 | 0:f2815503561f | 119 | |
mitea1 | 0:f2815503561f | 120 | /** |
mitea1 | 1:fe242f3e341b | 121 | * @brief Gets the Network Address. Only used when using ABP JoinMode |
mitea1 | 1:fe242f3e341b | 122 | * @return |
mitea1 | 1:fe242f3e341b | 123 | */ |
mitea1 | 1:fe242f3e341b | 124 | std::string getNetworkAddress(); |
mitea1 | 1:fe242f3e341b | 125 | |
mitea1 | 1:fe242f3e341b | 126 | /** |
mitea1 | 1:fe242f3e341b | 127 | * @brief Gets the App EUI |
mitea1 | 1:fe242f3e341b | 128 | * @return |
mitea1 | 1:fe242f3e341b | 129 | */ |
mitea1 | 1:fe242f3e341b | 130 | std::vector<uint8_t> getAppEUI(); |
mitea1 | 1:fe242f3e341b | 131 | |
mitea1 | 1:fe242f3e341b | 132 | /** |
mitea1 | 1:fe242f3e341b | 133 | * @brief Gets the App Key |
mitea1 | 1:fe242f3e341b | 134 | * @return |
mitea1 | 1:fe242f3e341b | 135 | */ |
mitea1 | 1:fe242f3e341b | 136 | std::vector<uint8_t> getAppKey(); |
mitea1 | 1:fe242f3e341b | 137 | |
mitea1 | 1:fe242f3e341b | 138 | /** |
mitea1 | 1:fe242f3e341b | 139 | * @brief Gets the Device EUI |
mitea1 | 1:fe242f3e341b | 140 | * @return |
mitea1 | 1:fe242f3e341b | 141 | */ |
mitea1 | 1:fe242f3e341b | 142 | std::vector<uint8_t> getDeviceEUI(); |
mitea1 | 1:fe242f3e341b | 143 | |
mitea1 | 1:fe242f3e341b | 144 | /** |
mitea1 | 0:f2815503561f | 145 | * @brief Gets the frequency SubBand that will be used by the LoRa Module to |
mitea1 | 0:f2815503561f | 146 | * send and receive its data from its Configuration |
mitea1 | 0:f2815503561f | 147 | * @return |
mitea1 | 0:f2815503561f | 148 | */ |
mitea1 | 0:f2815503561f | 149 | uint8_t getFrequencySubBand(); |
mitea1 | 0:f2815503561f | 150 | |
mitea1 | 0:f2815503561f | 151 | /** |
mitea1 | 0:f2815503561f | 152 | * @brief Gets the spreading Factor that the LoRa Module will us for data transmission |
mitea1 | 0:f2815503561f | 153 | * from its Configuration |
mitea1 | 0:f2815503561f | 154 | * @return |
mitea1 | 0:f2815503561f | 155 | */ |
mitea1 | 0:f2815503561f | 156 | uint8_t getSpreadingFactor(); |
mitea1 | 0:f2815503561f | 157 | |
mitea1 | 0:f2815503561f | 158 | /** |
mitea1 | 0:f2815503561f | 159 | * @brief Gets the transmission Power of the LoRa Module from its Configuration |
mitea1 | 0:f2815503561f | 160 | * @return |
mitea1 | 0:f2815503561f | 161 | */ |
mitea1 | 0:f2815503561f | 162 | uint8_t getTxPowerdBm(); |
mitea1 | 0:f2815503561f | 163 | |
mitea1 | 0:f2815503561f | 164 | /** |
mitea1 | 0:f2815503561f | 165 | * @brief Gets the number of Acknowledgment Retries that will be made |
mitea1 | 0:f2815503561f | 166 | * from its Configuration |
mitea1 | 0:f2815503561f | 167 | * @return |
mitea1 | 0:f2815503561f | 168 | */ |
mitea1 | 0:f2815503561f | 169 | uint8_t getAcknowledgeRetries(); |
mitea1 | 0:f2815503561f | 170 | |
mitea1 | 0:f2815503561f | 171 | /** |
mitea1 | 0:f2815503561f | 172 | * @brief Gets the Actual LORA_MODE of the built LoRaConfiguration |
mitea1 | 0:f2815503561f | 173 | * from its Configuration |
mitea1 | 0:f2815503561f | 174 | * @return |
mitea1 | 0:f2815503561f | 175 | */ |
mitea1 | 0:f2815503561f | 176 | LORA_MODE getLORA_MODE(); |
mitea1 | 0:f2815503561f | 177 | |
mitea1 | 1:fe242f3e341b | 178 | /** |
mitea1 | 1:fe242f3e341b | 179 | * @brief Gets the Actual JOIN_MODE of the built LoRaConfiguration |
mitea1 | 1:fe242f3e341b | 180 | * form its Configuration |
mitea1 | 1:fe242f3e341b | 181 | * @return |
mitea1 | 1:fe242f3e341b | 182 | */ |
mitea1 | 1:fe242f3e341b | 183 | JOIN_MODE getJOIN_MODE(); |
mitea1 | 1:fe242f3e341b | 184 | |
mitea1 | 0:f2815503561f | 185 | |
mitea1 | 0:f2815503561f | 186 | private: |
mitea1 | 0:f2815503561f | 187 | std::string* networkName; |
mitea1 | 0:f2815503561f | 188 | std::string* networkPassphrase; |
mitea1 | 1:fe242f3e341b | 189 | std::string* networkAddress; |
mitea1 | 1:fe242f3e341b | 190 | std::vector<uint8_t>* appEUI; |
mitea1 | 1:fe242f3e341b | 191 | std::vector<uint8_t>* appKey; |
mitea1 | 1:fe242f3e341b | 192 | std::vector<uint8_t>* deviceEUI; |
mitea1 | 0:f2815503561f | 193 | bool publicity; |
mitea1 | 0:f2815503561f | 194 | bool activity; |
mitea1 | 0:f2815503561f | 195 | uint8_t frequencySubBand; |
mitea1 | 0:f2815503561f | 196 | uint8_t spreadingFactor; |
mitea1 | 0:f2815503561f | 197 | uint8_t txPowerdBm; |
mitea1 | 0:f2815503561f | 198 | uint8_t acknowledgeRetries; |
mitea1 | 0:f2815503561f | 199 | |
mitea1 | 0:f2815503561f | 200 | LORA_MODE loraMode; |
mitea1 | 1:fe242f3e341b | 201 | JOIN_MODE joinMode; |
mitea1 | 0:f2815503561f | 202 | |
mitea1 | 0:f2815503561f | 203 | |
mitea1 | 0:f2815503561f | 204 | /** |
mitea1 | 0:f2815503561f | 205 | * @brief Sets the Network publicity of the network that will be used in the Configuration |
mitea1 | 0:f2815503561f | 206 | * @param |
mitea1 | 0:f2815503561f | 207 | */ |
mitea1 | 0:f2815503561f | 208 | void setNetworkPublicity(bool publicity); |
mitea1 | 0:f2815503561f | 209 | |
mitea1 | 0:f2815503561f | 210 | /** |
mitea1 | 0:f2815503561f | 211 | * @brief Sets the Activity of the LoRa module for the Configuration |
mitea1 | 0:f2815503561f | 212 | * @param activity true = module will be active false = module will not be active |
mitea1 | 0:f2815503561f | 213 | */ |
mitea1 | 0:f2815503561f | 214 | void setActivity(bool activity); |
mitea1 | 0:f2815503561f | 215 | |
mitea1 | 0:f2815503561f | 216 | /** |
mitea1 | 0:f2815503561f | 217 | * @brief Sets the Name of the Network that will be used in the Configuration |
mitea1 | 0:f2815503561f | 218 | * @param networkName the name of the network |
mitea1 | 0:f2815503561f | 219 | */ |
mitea1 | 0:f2815503561f | 220 | void setNetworkName(char* networkName); |
mitea1 | 0:f2815503561f | 221 | |
mitea1 | 0:f2815503561f | 222 | /** |
mitea1 | 0:f2815503561f | 223 | * @brief Sets the Passphrase of the Network that will be used in the Configuration |
mitea1 | 0:f2815503561f | 224 | * @param networkPassphrase passphrase of the Network |
mitea1 | 0:f2815503561f | 225 | */ |
mitea1 | 0:f2815503561f | 226 | void setNetworkPassphrase(char* networkPassphrase); |
mitea1 | 0:f2815503561f | 227 | |
mitea1 | 0:f2815503561f | 228 | /** |
mitea1 | 1:fe242f3e341b | 229 | * @brief Sets the Networkaddress of the Network that will be used in the Configuration |
mitea1 | 1:fe242f3e341b | 230 | * @param networkAddress |
mitea1 | 1:fe242f3e341b | 231 | */ |
mitea1 | 1:fe242f3e341b | 232 | void setNetworkAddress(char* networkAddress); |
mitea1 | 1:fe242f3e341b | 233 | |
mitea1 | 1:fe242f3e341b | 234 | /** |
mitea1 | 1:fe242f3e341b | 235 | * @brief Sets the APP EUI for OTAA |
mitea1 | 1:fe242f3e341b | 236 | * @param appEUI |
mitea1 | 1:fe242f3e341b | 237 | */ |
mitea1 | 1:fe242f3e341b | 238 | void setAppEUI(); |
mitea1 | 1:fe242f3e341b | 239 | |
mitea1 | 1:fe242f3e341b | 240 | /** |
mitea1 | 1:fe242f3e341b | 241 | * @brief Sets the APP Key for OTAA |
mitea1 | 1:fe242f3e341b | 242 | * @param appKey |
mitea1 | 1:fe242f3e341b | 243 | */ |
mitea1 | 1:fe242f3e341b | 244 | void setAppKey(); |
mitea1 | 1:fe242f3e341b | 245 | |
mitea1 | 1:fe242f3e341b | 246 | /** |
mitea1 | 1:fe242f3e341b | 247 | * @brief Sets the device EUI for OTAA |
mitea1 | 1:fe242f3e341b | 248 | * @param deviceEUI |
mitea1 | 1:fe242f3e341b | 249 | */ |
mitea1 | 1:fe242f3e341b | 250 | void setDeviceEUI(); |
mitea1 | 1:fe242f3e341b | 251 | |
mitea1 | 1:fe242f3e341b | 252 | |
mitea1 | 1:fe242f3e341b | 253 | /** |
mitea1 | 0:f2815503561f | 254 | * @brief Sets the SubBand that will be used in by the LoRa Module in the Configuration |
mitea1 | 0:f2815503561f | 255 | * @param subBand the SubBand that will be used |
mitea1 | 0:f2815503561f | 256 | */ |
mitea1 | 0:f2815503561f | 257 | void setFrequencySubBand(uint8_t subBand); |
mitea1 | 0:f2815503561f | 258 | |
mitea1 | 0:f2815503561f | 259 | /** |
mitea1 | 0:f2815503561f | 260 | * @brief Sets the spreading Factor of a LoRa Data Transmission in the Configuration |
mitea1 | 0:f2815503561f | 261 | * @param spreadingFactor |
mitea1 | 0:f2815503561f | 262 | */ |
mitea1 | 0:f2815503561f | 263 | void setSpreadingFactor(uint8_t spreadingFactor); |
mitea1 | 0:f2815503561f | 264 | |
mitea1 | 0:f2815503561f | 265 | /** |
mitea1 | 0:f2815503561f | 266 | * @brief Sets the Data transmission Power via LoRa in the Configuration |
mitea1 | 0:f2815503561f | 267 | * @param |
mitea1 | 0:f2815503561f | 268 | */ |
mitea1 | 0:f2815503561f | 269 | void setTxPowerdBm(uint8_t ); |
mitea1 | 0:f2815503561f | 270 | |
mitea1 | 0:f2815503561f | 271 | /** |
mitea1 | 0:f2815503561f | 272 | * @brief Set the Acknowledgment Retries in the Configuration |
mitea1 | 0:f2815503561f | 273 | * @param |
mitea1 | 0:f2815503561f | 274 | */ |
mitea1 | 0:f2815503561f | 275 | void setAcknowledgeRetries(uint8_t); |
mitea1 | 0:f2815503561f | 276 | |
mitea1 | 0:f2815503561f | 277 | /** |
mitea1 | 0:f2815503561f | 278 | * @brief Sets the LORA_MODE of the Configuration |
mitea1 | 0:f2815503561f | 279 | * @param |
mitea1 | 0:f2815503561f | 280 | */ |
mitea1 | 0:f2815503561f | 281 | void setLORA_MODE(LORA_MODE); |
mitea1 | 0:f2815503561f | 282 | |
mitea1 | 1:fe242f3e341b | 283 | /** |
mitea1 | 1:fe242f3e341b | 284 | * @brief Sets the Join Mode to a Network |
mitea1 | 1:fe242f3e341b | 285 | * @param |
mitea1 | 1:fe242f3e341b | 286 | */ |
mitea1 | 1:fe242f3e341b | 287 | void setJOIN_MODE(JOIN_MODE); |
mitea1 | 1:fe242f3e341b | 288 | |
mitea1 | 0:f2815503561f | 289 | }; |
mitea1 | 0:f2815503561f | 290 | |
mitea1 | 0:f2815503561f | 291 | #endif /* LORACONFIG_H_ */ |