A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

LoRa-Sensornode Firmware for Multitech mDot

A multifunctional and modular Firmware for Multitech's mDot which provides a widerange of functionality for several Sensors. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

/media/uploads/mitea1/logo-lora-600x370.png /media/uploads/mitea1/mt_mdot_family_642px.png

Supported Sensors

Idea

The Firmware has some predefined Application Modes running different Tasks(Measurements). Each mode can be used in a different Scenario. Application_Modes define which sensors are used, how often they aquire data and how often the data has to be sent via LoRa. Lets say you just want to measure the Light then you choose an Application_Mode (or define one) that only runs TaskLight for light measurement. As a standard all measurements are taken every second and sent via LoRa but you can change that interval depending on your usage Scenario

Committer:
mitea1
Date:
Tue Nov 01 19:42:40 2016 +0000
Revision:
8:4b4d58bd631c
Parent:
7:87cbeafdba06
Child:
9:c4e378f4801d
declared APP_EUI and APP_KEY for TTN OTAA as MSB

Who changed what in which revision?

UserRevisionLine numberNew 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
mitea1 8:4b4d58bd631c 65 static uint8_t LORA_APP_EUI_MSB[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
mitea1 8:4b4d58bd631c 66 static uint8_t LORA_APP_KEY_MSB[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
mitea1 8:4b4d58bd631c 67 static uint8_t LORA_DEVICE_EUI_MSB[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77};
mitea1 8:4b4d58bd631c 68
mitea1 1:fe242f3e341b 69
mitea1 1:fe242f3e341b 70 /**
mitea1 0:f2815503561f 71 * @class LoRaConfig
mitea1 0:f2815503561f 72 * @brief A configuration container for the LoRa Module.
mitea1 0:f2815503561f 73 * All its configuration values are stored an held inside
mitea1 0:f2815503561f 74 * this Class. Depending on the LORA_MODE it sets all the configuration values.
mitea1 0:f2815503561f 75 */
mitea1 0:f2815503561f 76 class LoRaConfig {
mitea1 0:f2815503561f 77 public:
mitea1 0:f2815503561f 78 LoRaConfig();
mitea1 0:f2815503561f 79 virtual ~LoRaConfig();
mitea1 0:f2815503561f 80
mitea1 0:f2815503561f 81 /**
mitea1 0:f2815503561f 82 * @brief Generates a configuration according to the chosen LORA_MODE
mitea1 0:f2815503561f 83 * by setting all LoRa Module specific configuration values depending on the chosen LORA_MODE
mitea1 0:f2815503561f 84 * @param desiredMode the mode to build the configuration according to
mitea1 0:f2815503561f 85 */
mitea1 0:f2815503561f 86 void build(LORA_MODE desiredMode);
mitea1 0:f2815503561f 87
mitea1 0:f2815503561f 88 /**
mitea1 0:f2815503561f 89 * @brief Gets info if the Network to which the LoRa Module sings up
mitea1 0:f2815503561f 90 * is public or not from its Configuration
mitea1 0:f2815503561f 91 */
mitea1 0:f2815503561f 92 bool isPublic();
mitea1 0:f2815503561f 93
mitea1 0:f2815503561f 94 /**
mitea1 0:f2815503561f 95 * @brief Gets info if LoRa Module will be active and run or not
mitea1 0:f2815503561f 96 * from its Configuration
mitea1 0:f2815503561f 97 * @return
mitea1 0:f2815503561f 98 */
mitea1 0:f2815503561f 99 bool isActiv();
mitea1 0:f2815503561f 100
mitea1 0:f2815503561f 101 /**
mitea1 0:f2815503561f 102 * @brief Gets the name of the Network to which the LoRa Module sings up
mitea1 0:f2815503561f 103 * from its Configuration
mitea1 0:f2815503561f 104 * @return
mitea1 0:f2815503561f 105 */
mitea1 0:f2815503561f 106 std::string getNetworkName();
mitea1 0:f2815503561f 107
mitea1 0:f2815503561f 108 /**
mitea1 0:f2815503561f 109 * @brief Gets the Passphrase of the Network to which the LoRa Module sings up
mitea1 0:f2815503561f 110 * from its Configuration
mitea1 0:f2815503561f 111 * @return
mitea1 0:f2815503561f 112 */
mitea1 0:f2815503561f 113 std::string getNetworkPassphrase();
mitea1 0:f2815503561f 114
mitea1 0:f2815503561f 115 /**
mitea1 1:fe242f3e341b 116 * @brief Gets the Network Address. Only used when using ABP JoinMode
mitea1 1:fe242f3e341b 117 * @return
mitea1 1:fe242f3e341b 118 */
mitea1 1:fe242f3e341b 119 std::string getNetworkAddress();
mitea1 1:fe242f3e341b 120
mitea1 1:fe242f3e341b 121 /**
mitea1 1:fe242f3e341b 122 * @brief Gets the App EUI
mitea1 1:fe242f3e341b 123 * @return
mitea1 1:fe242f3e341b 124 */
mitea1 1:fe242f3e341b 125 std::vector<uint8_t> getAppEUI();
mitea1 1:fe242f3e341b 126
mitea1 1:fe242f3e341b 127 /**
mitea1 1:fe242f3e341b 128 * @brief Gets the App Key
mitea1 1:fe242f3e341b 129 * @return
mitea1 1:fe242f3e341b 130 */
mitea1 1:fe242f3e341b 131 std::vector<uint8_t> getAppKey();
mitea1 1:fe242f3e341b 132
mitea1 1:fe242f3e341b 133 /**
mitea1 1:fe242f3e341b 134 * @brief Gets the Device EUI
mitea1 1:fe242f3e341b 135 * @return
mitea1 1:fe242f3e341b 136 */
mitea1 1:fe242f3e341b 137 std::vector<uint8_t> getDeviceEUI();
mitea1 1:fe242f3e341b 138
mitea1 1:fe242f3e341b 139 /**
mitea1 0:f2815503561f 140 * @brief Gets the frequency SubBand that will be used by the LoRa Module to
mitea1 0:f2815503561f 141 * send and receive its data from its Configuration
mitea1 0:f2815503561f 142 * @return
mitea1 0:f2815503561f 143 */
mitea1 0:f2815503561f 144 uint8_t getFrequencySubBand();
mitea1 0:f2815503561f 145
mitea1 0:f2815503561f 146 /**
mitea1 0:f2815503561f 147 * @brief Gets the spreading Factor that the LoRa Module will us for data transmission
mitea1 0:f2815503561f 148 * from its Configuration
mitea1 0:f2815503561f 149 * @return
mitea1 0:f2815503561f 150 */
mitea1 0:f2815503561f 151 uint8_t getSpreadingFactor();
mitea1 0:f2815503561f 152
mitea1 0:f2815503561f 153 /**
mitea1 0:f2815503561f 154 * @brief Gets the transmission Power of the LoRa Module from its Configuration
mitea1 0:f2815503561f 155 * @return
mitea1 0:f2815503561f 156 */
mitea1 0:f2815503561f 157 uint8_t getTxPowerdBm();
mitea1 0:f2815503561f 158
mitea1 0:f2815503561f 159 /**
mitea1 0:f2815503561f 160 * @brief Gets the number of Acknowledgment Retries that will be made
mitea1 0:f2815503561f 161 * from its Configuration
mitea1 0:f2815503561f 162 * @return
mitea1 0:f2815503561f 163 */
mitea1 0:f2815503561f 164 uint8_t getAcknowledgeRetries();
mitea1 0:f2815503561f 165
mitea1 0:f2815503561f 166 /**
mitea1 0:f2815503561f 167 * @brief Gets the Actual LORA_MODE of the built LoRaConfiguration
mitea1 0:f2815503561f 168 * from its Configuration
mitea1 0:f2815503561f 169 * @return
mitea1 0:f2815503561f 170 */
mitea1 0:f2815503561f 171 LORA_MODE getLORA_MODE();
mitea1 0:f2815503561f 172
mitea1 1:fe242f3e341b 173 /**
mitea1 1:fe242f3e341b 174 * @brief Gets the Actual JOIN_MODE of the built LoRaConfiguration
mitea1 1:fe242f3e341b 175 * form its Configuration
mitea1 1:fe242f3e341b 176 * @return
mitea1 1:fe242f3e341b 177 */
mitea1 1:fe242f3e341b 178 JOIN_MODE getJOIN_MODE();
mitea1 1:fe242f3e341b 179
mitea1 0:f2815503561f 180
mitea1 0:f2815503561f 181 private:
mitea1 0:f2815503561f 182 std::string* networkName;
mitea1 0:f2815503561f 183 std::string* networkPassphrase;
mitea1 1:fe242f3e341b 184 std::string* networkAddress;
mitea1 1:fe242f3e341b 185 std::vector<uint8_t>* appEUI;
mitea1 1:fe242f3e341b 186 std::vector<uint8_t>* appKey;
mitea1 1:fe242f3e341b 187 std::vector<uint8_t>* deviceEUI;
mitea1 0:f2815503561f 188 bool publicity;
mitea1 0:f2815503561f 189 bool activity;
mitea1 0:f2815503561f 190 uint8_t frequencySubBand;
mitea1 0:f2815503561f 191 uint8_t spreadingFactor;
mitea1 0:f2815503561f 192 uint8_t txPowerdBm;
mitea1 0:f2815503561f 193 uint8_t acknowledgeRetries;
mitea1 0:f2815503561f 194
mitea1 0:f2815503561f 195 LORA_MODE loraMode;
mitea1 1:fe242f3e341b 196 JOIN_MODE joinMode;
mitea1 0:f2815503561f 197
mitea1 0:f2815503561f 198
mitea1 0:f2815503561f 199 /**
mitea1 0:f2815503561f 200 * @brief Sets the Network publicity of the network that will be used in the Configuration
mitea1 0:f2815503561f 201 * @param
mitea1 0:f2815503561f 202 */
mitea1 0:f2815503561f 203 void setNetworkPublicity(bool publicity);
mitea1 0:f2815503561f 204
mitea1 0:f2815503561f 205 /**
mitea1 0:f2815503561f 206 * @brief Sets the Activity of the LoRa module for the Configuration
mitea1 0:f2815503561f 207 * @param activity true = module will be active false = module will not be active
mitea1 0:f2815503561f 208 */
mitea1 0:f2815503561f 209 void setActivity(bool activity);
mitea1 0:f2815503561f 210
mitea1 0:f2815503561f 211 /**
mitea1 0:f2815503561f 212 * @brief Sets the Name of the Network that will be used in the Configuration
mitea1 0:f2815503561f 213 * @param networkName the name of the network
mitea1 0:f2815503561f 214 */
mitea1 0:f2815503561f 215 void setNetworkName(char* networkName);
mitea1 0:f2815503561f 216
mitea1 0:f2815503561f 217 /**
mitea1 0:f2815503561f 218 * @brief Sets the Passphrase of the Network that will be used in the Configuration
mitea1 0:f2815503561f 219 * @param networkPassphrase passphrase of the Network
mitea1 0:f2815503561f 220 */
mitea1 0:f2815503561f 221 void setNetworkPassphrase(char* networkPassphrase);
mitea1 0:f2815503561f 222
mitea1 0:f2815503561f 223 /**
mitea1 1:fe242f3e341b 224 * @brief Sets the Networkaddress of the Network that will be used in the Configuration
mitea1 1:fe242f3e341b 225 * @param networkAddress
mitea1 1:fe242f3e341b 226 */
mitea1 1:fe242f3e341b 227 void setNetworkAddress(char* networkAddress);
mitea1 1:fe242f3e341b 228
mitea1 1:fe242f3e341b 229 /**
mitea1 1:fe242f3e341b 230 * @brief Sets the APP EUI for OTAA
mitea1 1:fe242f3e341b 231 * @param appEUI
mitea1 1:fe242f3e341b 232 */
mitea1 1:fe242f3e341b 233 void setAppEUI();
mitea1 1:fe242f3e341b 234
mitea1 1:fe242f3e341b 235 /**
mitea1 1:fe242f3e341b 236 * @brief Sets the APP Key for OTAA
mitea1 1:fe242f3e341b 237 * @param appKey
mitea1 1:fe242f3e341b 238 */
mitea1 1:fe242f3e341b 239 void setAppKey();
mitea1 1:fe242f3e341b 240
mitea1 1:fe242f3e341b 241 /**
mitea1 1:fe242f3e341b 242 * @brief Sets the device EUI for OTAA
mitea1 1:fe242f3e341b 243 * @param deviceEUI
mitea1 1:fe242f3e341b 244 */
mitea1 1:fe242f3e341b 245 void setDeviceEUI();
mitea1 1:fe242f3e341b 246
mitea1 1:fe242f3e341b 247
mitea1 1:fe242f3e341b 248 /**
mitea1 0:f2815503561f 249 * @brief Sets the SubBand that will be used in by the LoRa Module in the Configuration
mitea1 0:f2815503561f 250 * @param subBand the SubBand that will be used
mitea1 0:f2815503561f 251 */
mitea1 0:f2815503561f 252 void setFrequencySubBand(uint8_t subBand);
mitea1 0:f2815503561f 253
mitea1 0:f2815503561f 254 /**
mitea1 0:f2815503561f 255 * @brief Sets the spreading Factor of a LoRa Data Transmission in the Configuration
mitea1 0:f2815503561f 256 * @param spreadingFactor
mitea1 0:f2815503561f 257 */
mitea1 0:f2815503561f 258 void setSpreadingFactor(uint8_t spreadingFactor);
mitea1 0:f2815503561f 259
mitea1 0:f2815503561f 260 /**
mitea1 0:f2815503561f 261 * @brief Sets the Data transmission Power via LoRa in the Configuration
mitea1 0:f2815503561f 262 * @param
mitea1 0:f2815503561f 263 */
mitea1 0:f2815503561f 264 void setTxPowerdBm(uint8_t );
mitea1 0:f2815503561f 265
mitea1 0:f2815503561f 266 /**
mitea1 0:f2815503561f 267 * @brief Set the Acknowledgment Retries in the Configuration
mitea1 0:f2815503561f 268 * @param
mitea1 0:f2815503561f 269 */
mitea1 0:f2815503561f 270 void setAcknowledgeRetries(uint8_t);
mitea1 0:f2815503561f 271
mitea1 0:f2815503561f 272 /**
mitea1 0:f2815503561f 273 * @brief Sets the LORA_MODE of the Configuration
mitea1 0:f2815503561f 274 * @param
mitea1 0:f2815503561f 275 */
mitea1 0:f2815503561f 276 void setLORA_MODE(LORA_MODE);
mitea1 0:f2815503561f 277
mitea1 1:fe242f3e341b 278 /**
mitea1 1:fe242f3e341b 279 * @brief Sets the Join Mode to a Network
mitea1 1:fe242f3e341b 280 * @param
mitea1 1:fe242f3e341b 281 */
mitea1 1:fe242f3e341b 282 void setJOIN_MODE(JOIN_MODE);
mitea1 1:fe242f3e341b 283
mitea1 0:f2815503561f 284 };
mitea1 0:f2815503561f 285
mitea1 0:f2815503561f 286 #endif /* LORACONFIG_H_ */