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:
Wed Jul 06 20:40:36 2016 +0000
Revision:
0:f2815503561f
Child:
1:fe242f3e341b
initial commit;

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 0:f2815503561f 53 * @brief DON'T USE IT RESULUTS 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 0:f2815503561f 77
mitea1 0:f2815503561f 78 private:
mitea1 0:f2815503561f 79 mDot* dot;
mitea1 0:f2815503561f 80 RawSerial* debugSerial;
mitea1 0:f2815503561f 81
mitea1 0:f2815503561f 82 LoRaConfig* config;
mitea1 0:f2815503561f 83
mitea1 0:f2815503561f 84 int16_t rssi;
mitea1 0:f2815503561f 85 int16_t snr;
mitea1 0:f2815503561f 86 uint8_t spreadingFactor;
mitea1 0:f2815503561f 87 uint8_t txPowerdBm;
mitea1 0:f2815503561f 88
mitea1 0:f2815503561f 89 /**
mitea1 0:f2815503561f 90 * @brief Depending on the LoRaConfig it defines wheter the LoRa Module connects to a
mitea1 0:f2815503561f 91 * public network or not
mitea1 0:f2815503561f 92 * @return
mitea1 0:f2815503561f 93 */
mitea1 0:f2815503561f 94 int32_t setPublicNetwork();
mitea1 0:f2815503561f 95
mitea1 0:f2815503561f 96 /**
mitea1 0:f2815503561f 97 * @brief Depending on the LoRaConfig it defines the frequency SubBand that is used for
mitea1 0:f2815503561f 98 * transmission of Message to the Gateway
mitea1 0:f2815503561f 99 * @return
mitea1 0:f2815503561f 100 */
mitea1 0:f2815503561f 101 int32_t setFrequencySubBand();
mitea1 0:f2815503561f 102
mitea1 0:f2815503561f 103 /**
mitea1 0:f2815503561f 104 * @brief Depending on the LoRaConfig it defines the name of the Network the
mitea1 0:f2815503561f 105 * LoRa Module signs up
mitea1 0:f2815503561f 106 * @return
mitea1 0:f2815503561f 107 */
mitea1 0:f2815503561f 108 int32_t setNetworkName();
mitea1 0:f2815503561f 109
mitea1 0:f2815503561f 110 /**
mitea1 0:f2815503561f 111 * @brief Depending on the LoRaConfig it defines the Passphrase thats used to
mitea1 0:f2815503561f 112 * use the Network
mitea1 0:f2815503561f 113 * @return
mitea1 0:f2815503561f 114 */
mitea1 0:f2815503561f 115 int32_t setNetworkPassphrase();
mitea1 0:f2815503561f 116
mitea1 0:f2815503561f 117 /**
mitea1 0:f2815503561f 118 * @brief Depending on the LoRaConfig it defines the spreading Factor
mitea1 0:f2815503561f 119 * for transmissions via LoRa
mitea1 0:f2815503561f 120 * @return
mitea1 0:f2815503561f 121 */
mitea1 0:f2815503561f 122 int32_t setSpreadingFactor();
mitea1 0:f2815503561f 123
mitea1 0:f2815503561f 124 /**
mitea1 0:f2815503561f 125 * @brief Depending on the LoRaConfig it defines the number of Acknowledgment Retries
mitea1 0:f2815503561f 126 * that are made
mitea1 0:f2815503561f 127 * @return
mitea1 0:f2815503561f 128 */
mitea1 0:f2815503561f 129 int32_t setAckRetries();
mitea1 0:f2815503561f 130
mitea1 0:f2815503561f 131 /**
mitea1 0:f2815503561f 132 * @brief Depending on the LoRaConfig it defines the power of LoRa data Transmission
mitea1 0:f2815503561f 133 * @return
mitea1 0:f2815503561f 134 */
mitea1 0:f2815503561f 135 int32_t setTxPower();
mitea1 0:f2815503561f 136
mitea1 0:f2815503561f 137 /**
mitea1 0:f2815503561f 138 * @brief Saves parameters of the LoRa Module
mitea1 0:f2815503561f 139 */
mitea1 0:f2815503561f 140 void saveConfig();
mitea1 0:f2815503561f 141
mitea1 0:f2815503561f 142 /**
mitea1 0:f2815503561f 143 * @brief Resets Configuration of the LoRa Module
mitea1 0:f2815503561f 144 */
mitea1 0:f2815503561f 145 void resetConfig();
mitea1 0:f2815503561f 146
mitea1 0:f2815503561f 147 /**
mitea1 0:f2815503561f 148 * @brief Tries to join the Network defined by NetworkName and NetworkPassphrase
mitea1 0:f2815503561f 149 */
mitea1 0:f2815503561f 150 void joinNetwork();
mitea1 0:f2815503561f 151
mitea1 0:f2815503561f 152
mitea1 0:f2815503561f 153
mitea1 0:f2815503561f 154 };
mitea1 0:f2815503561f 155
mitea1 0:f2815503561f 156 #endif /* LORA_H_ */