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:
Sun Aug 21 08:41:01 2016 +0000
Revision:
4:2674bd4168f8
Parent:
1:fe242f3e341b
Child:
5:b73d4ca6a8cd
implementation of sleep() and deepsleep() for the Firmwares Tasks

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