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:
Fri Nov 02 17:01:02 2018 +0000
Revision:
10:4051c38bf73f
Parent:
1:fe242f3e341b
wtf

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /**
mitea1 0:f2815503561f 2 * @file LoRa.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * @author Adrian
mitea1 0:f2815503561f 5 * @date May 31, 2016
mitea1 0:f2815503561f 6 *
mitea1 0:f2815503561f 7 */
mitea1 0:f2815503561f 8 #include "mDot.h"
mitea1 0:f2815503561f 9 #include "MTSLog.h"
mitea1 0:f2815503561f 10 #include "LoRaConfig.h"
mitea1 0:f2815503561f 11
mitea1 0:f2815503561f 12 #ifndef LORA_H_
mitea1 0:f2815503561f 13 #define LORA_H_
mitea1 0:f2815503561f 14
mitea1 0:f2815503561f 15 /**
mitea1 0:f2815503561f 16 * @class LoRa
mitea1 0:f2815503561f 17 * @brief Represents the LoRa Module with all its functionality. It wraps Multitech owns mDot Library functions.
mitea1 0:f2815503561f 18 * It's possible to wrap other functionality from other LoRa Module Manufactures for future use cases
mitea1 0:f2815503561f 19 */
mitea1 0:f2815503561f 20 class LoRa {
mitea1 0:f2815503561f 21 public:
mitea1 0:f2815503561f 22 LoRa(mDot*,RawSerial*);
mitea1 0:f2815503561f 23 virtual ~LoRa();
mitea1 0:f2815503561f 24
mitea1 0:f2815503561f 25 /**
mitea1 0:f2815503561f 26 * @brief Initializes and start the LoRa Module depending on the desireMode
mitea1 0:f2815503561f 27 * @param desiredMode
mitea1 0:f2815503561f 28 */
mitea1 0:f2815503561f 29 void init(LORA_MODE desiredMode);
mitea1 0:f2815503561f 30
mitea1 0:f2815503561f 31 /**
mitea1 0:f2815503561f 32 * @brief Sends data stored inside a vector via LoRa
mitea1 0:f2815503561f 33 * @param dataToSend the vector that contains the Data that needs to be sent
mitea1 0:f2815503561f 34 * @return
mitea1 0:f2815503561f 35 */
mitea1 0:f2815503561f 36 int32_t send(std::vector<uint8_t>& dataToSend);
mitea1 0:f2815503561f 37
mitea1 0:f2815503561f 38 /**
mitea1 0:f2815503561f 39 * @brief Receives data via LoRa and stores it inside a vector
mitea1 0:f2815503561f 40 * @param receivedData the vector where the received data needs to be stored
mitea1 0:f2815503561f 41 * @return
mitea1 0:f2815503561f 42 */
mitea1 0:f2815503561f 43 int32_t recv(std::vector<uint8_t>& receivedData);
mitea1 0:f2815503561f 44
mitea1 0:f2815503561f 45 /**
mitea1 0:f2815503561f 46 * @brief Gets the Rssi of the last sent Message. It's important that at least 1
mitea1 0:f2815503561f 47 * Acknowledgment Retries is set by setAckRetries()
mitea1 0:f2815503561f 48 * @return
mitea1 0:f2815503561f 49 */
mitea1 0:f2815503561f 50 int16_t getLastRssi();
mitea1 0:f2815503561f 51
mitea1 0:f2815503561f 52 /**
mitea1 1:fe242f3e341b 53 * @brief DON'T USE IT RESULTS IN HARDFAULT!
mitea1 0:f2815503561f 54 * Gets the SNR of the last sent Message.
mitea1 0:f2815503561f 55 * @return
mitea1 0:f2815503561f 56 */
mitea1 0:f2815503561f 57 int16_t getLastSnr();
mitea1 0:f2815503561f 58
mitea1 0:f2815503561f 59 /**
mitea1 0:f2815503561f 60 * @brief Gets the actual spreading Factor from 7 to 12 from the LoRa Module
mitea1 0:f2815503561f 61 * @return
mitea1 0:f2815503561f 62 */
mitea1 0:f2815503561f 63 uint8_t getSpreadingFactor();
mitea1 0:f2815503561f 64
mitea1 0:f2815503561f 65 /**
mitea1 0:f2815503561f 66 * @brief Gets the actual transmit Power in dBm from the LoRa Module
mitea1 0:f2815503561f 67 * @return
mitea1 0:f2815503561f 68 */
mitea1 0:f2815503561f 69 uint8_t getTxPowerdBm();
mitea1 0:f2815503561f 70
mitea1 0:f2815503561f 71 /**
mitea1 0:f2815503561f 72 * @brief Sends a 0 Byte long ping message to the gateway
mitea1 0:f2815503561f 73 */
mitea1 0:f2815503561f 74 void ping();
mitea1 0:f2815503561f 75
mitea1 0:f2815503561f 76
mitea1 1:fe242f3e341b 77 /**
mitea1 1:fe242f3e341b 78 * @brief Get ms until next free channel
mitea1 1:fe242f3e341b 79 * only applicable for European models, US models return 0
mitea1 1:fe242f3e341b 80 */
mitea1 1:fe242f3e341b 81 uint32_t getNextTxMs();
mitea1 1:fe242f3e341b 82
mitea1 1:fe242f3e341b 83
mitea1 0:f2815503561f 84
mitea1 0:f2815503561f 85 private:
mitea1 0:f2815503561f 86 mDot* dot;
mitea1 0:f2815503561f 87 RawSerial* debugSerial;
mitea1 0:f2815503561f 88
mitea1 0:f2815503561f 89 LoRaConfig* config;
mitea1 0:f2815503561f 90
mitea1 0:f2815503561f 91 int16_t rssi;
mitea1 0:f2815503561f 92 int16_t snr;
mitea1 0:f2815503561f 93 uint8_t spreadingFactor;
mitea1 0:f2815503561f 94 uint8_t txPowerdBm;
mitea1 0:f2815503561f 95
mitea1 0:f2815503561f 96 /**
mitea1 0:f2815503561f 97 * @brief Depending on the LoRaConfig it defines wheter the LoRa Module connects to a
mitea1 0:f2815503561f 98 * public network or not
mitea1 0:f2815503561f 99 * @return
mitea1 0:f2815503561f 100 */
mitea1 0:f2815503561f 101 int32_t setPublicNetwork();
mitea1 0:f2815503561f 102
mitea1 0:f2815503561f 103 /**
mitea1 0:f2815503561f 104 * @brief Depending on the LoRaConfig it defines the frequency SubBand that is used for
mitea1 0:f2815503561f 105 * transmission of Message to the Gateway
mitea1 0:f2815503561f 106 * @return
mitea1 0:f2815503561f 107 */
mitea1 0:f2815503561f 108 int32_t setFrequencySubBand();
mitea1 0:f2815503561f 109
mitea1 0:f2815503561f 110 /**
mitea1 0:f2815503561f 111 * @brief Depending on the LoRaConfig it defines the name of the Network the
mitea1 0:f2815503561f 112 * LoRa Module signs up
mitea1 0:f2815503561f 113 * @return
mitea1 0:f2815503561f 114 */
mitea1 0:f2815503561f 115 int32_t setNetworkName();
mitea1 0:f2815503561f 116
mitea1 0:f2815503561f 117 /**
mitea1 0:f2815503561f 118 * @brief Depending on the LoRaConfig it defines the Passphrase thats used to
mitea1 0:f2815503561f 119 * use the Network
mitea1 0:f2815503561f 120 * @return
mitea1 0:f2815503561f 121 */
mitea1 0:f2815503561f 122 int32_t setNetworkPassphrase();
mitea1 0:f2815503561f 123
mitea1 0:f2815503561f 124 /**
mitea1 1:fe242f3e341b 125 * @brief Depending on the LoRaConfig it defines that AppEUI thats used for OTAA
mitea1 1:fe242f3e341b 126 * @return
mitea1 1:fe242f3e341b 127 */
mitea1 1:fe242f3e341b 128 int32_t setAppEUI();
mitea1 1:fe242f3e341b 129
mitea1 1:fe242f3e341b 130 /**
mitea1 1:fe242f3e341b 131 * @brief Depending on the LoRaConfig it defines that AppKey thats used for OTAA
mitea1 1:fe242f3e341b 132 * @return
mitea1 1:fe242f3e341b 133 */
mitea1 1:fe242f3e341b 134 int32_t setAppKey();
mitea1 1:fe242f3e341b 135
mitea1 1:fe242f3e341b 136 /**
mitea1 1:fe242f3e341b 137 * @brief Depending on the LoRaConfig it defines that DeviceEUI thats used for OTAA
mitea1 1:fe242f3e341b 138 * @return
mitea1 1:fe242f3e341b 139 */
mitea1 1:fe242f3e341b 140 int32_t setDeviceEUI();
mitea1 1:fe242f3e341b 141
mitea1 1:fe242f3e341b 142
mitea1 1:fe242f3e341b 143 /**
mitea1 1:fe242f3e341b 144 * @brief Depending on the LoRaConfig it sets the join mode of the Node.
mitea1 1:fe242f3e341b 145 * Either OTTA (Over the Air Activation or ABP (Activation by Personalization)
mitea1 1:fe242f3e341b 146 * @param
mitea1 1:fe242f3e341b 147 * @return
mitea1 1:fe242f3e341b 148 */
mitea1 1:fe242f3e341b 149 int32_t setJoinMode();
mitea1 1:fe242f3e341b 150
mitea1 1:fe242f3e341b 151 /**
mitea1 0:f2815503561f 152 * @brief Depending on the LoRaConfig it defines the spreading Factor
mitea1 0:f2815503561f 153 * for transmissions via LoRa
mitea1 0:f2815503561f 154 * @return
mitea1 0:f2815503561f 155 */
mitea1 0:f2815503561f 156 int32_t setSpreadingFactor();
mitea1 0:f2815503561f 157
mitea1 0:f2815503561f 158 /**
mitea1 0:f2815503561f 159 * @brief Depending on the LoRaConfig it defines the number of Acknowledgment Retries
mitea1 0:f2815503561f 160 * that are made
mitea1 0:f2815503561f 161 * @return
mitea1 0:f2815503561f 162 */
mitea1 0:f2815503561f 163 int32_t setAckRetries();
mitea1 0:f2815503561f 164
mitea1 0:f2815503561f 165 /**
mitea1 0:f2815503561f 166 * @brief Depending on the LoRaConfig it defines the power of LoRa data Transmission
mitea1 0:f2815503561f 167 * @return
mitea1 0:f2815503561f 168 */
mitea1 0:f2815503561f 169 int32_t setTxPower();
mitea1 0:f2815503561f 170
mitea1 0:f2815503561f 171 /**
mitea1 0:f2815503561f 172 * @brief Saves parameters of the LoRa Module
mitea1 0:f2815503561f 173 */
mitea1 0:f2815503561f 174 void saveConfig();
mitea1 0:f2815503561f 175
mitea1 0:f2815503561f 176 /**
mitea1 0:f2815503561f 177 * @brief Resets Configuration of the LoRa Module
mitea1 0:f2815503561f 178 */
mitea1 0:f2815503561f 179 void resetConfig();
mitea1 0:f2815503561f 180
mitea1 0:f2815503561f 181 /**
mitea1 0:f2815503561f 182 * @brief Tries to join the Network defined by NetworkName and NetworkPassphrase
mitea1 0:f2815503561f 183 */
mitea1 0:f2815503561f 184 void joinNetwork();
mitea1 0:f2815503561f 185
mitea1 0:f2815503561f 186
mitea1 0:f2815503561f 187
mitea1 0:f2815503561f 188 };
mitea1 0:f2815503561f 189
mitea1 0:f2815503561f 190 #endif /* LORA_H_ */