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:
Sat Oct 08 09:55:41 2016 +0000
Revision:
7:87cbeafdba06
Parent:
1:fe242f3e341b
Child:
9:c4e378f4801d
LoRa Downlink Messages can now be received. Command Receiver and Handler implemented.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /*
mitea1 0:f2815503561f 2 * Application.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * Created on: Jun 3, 2016
mitea1 0:f2815503561f 5 * Author: Adrian
mitea1 0:f2815503561f 6 */
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 #include "ApplicationConfig.h"
mitea1 0:f2815503561f 9 #include "mbed.h"
mitea1 0:f2815503561f 10 #include "rtos.h"
mitea1 0:f2815503561f 11 #include "I2C_RT.h"
mitea1 0:f2815503561f 12 #include "MAX44009.h"
mitea1 0:f2815503561f 13 #include "BME280.h"
mitea1 0:f2815503561f 14 #include "MPU9250.h"
mitea1 0:f2815503561f 15 #include "SI1143.h"
mitea1 0:f2815503561f 16 #include "uBlox.h"
mitea1 0:f2815503561f 17 #include "mDot.h"
mitea1 0:f2815503561f 18 #include "LoRa.h"
mitea1 0:f2815503561f 19 #include "TaskLight.h"
mitea1 0:f2815503561f 20 #include "TaskTemperature.h"
mitea1 0:f2815503561f 21 #include "TaskHumidity.h"
mitea1 0:f2815503561f 22 #include "TaskPressure.h"
mitea1 0:f2815503561f 23 #include "TaskAcceleration.h"
mitea1 0:f2815503561f 24 #include "TaskGyroscope.h"
mitea1 0:f2815503561f 25 #include "TaskTesla.h"
mitea1 0:f2815503561f 26 #include "TaskProximity.h"
mitea1 0:f2815503561f 27 #include "TaskGPS.h"
mitea1 0:f2815503561f 28 #include "TaskLoRaMeasurement.h"
mitea1 0:f2815503561f 29 #include "TaskDatahandler.h"
mitea1 7:87cbeafdba06 30 #include "TaskCommandHandler.h"
mitea1 0:f2815503561f 31 #include "main.h"
mitea1 0:f2815503561f 32
mitea1 0:f2815503561f 33 #ifndef SENSORHANDLER_H_
mitea1 0:f2815503561f 34 #define SENSORHANDLER_H_
mitea1 0:f2815503561f 35
mitea1 0:f2815503561f 36 class Application {
mitea1 0:f2815503561f 37 public:
mitea1 0:f2815503561f 38 Application();
mitea1 0:f2815503561f 39 virtual ~Application();
mitea1 0:f2815503561f 40
mitea1 0:f2815503561f 41 /**
mitea1 0:f2815503561f 42 * @brief Start the Application in the desired Mode
mitea1 0:f2815503561f 43 * @return
mitea1 0:f2815503561f 44 */
mitea1 0:f2815503561f 45 void init(APPLICATION_MODE desiredMode);
mitea1 0:f2815503561f 46
mitea1 0:f2815503561f 47 private:
mitea1 0:f2815503561f 48 RawSerial* uart;
mitea1 0:f2815503561f 49 RawSerial* debugSerial;
mitea1 0:f2815503561f 50 I2C_RT* i2c_rt;
mitea1 0:f2815503561f 51 mDot* dot;
mitea1 0:f2815503561f 52 LoRa* lora;
mitea1 0:f2815503561f 53
mitea1 0:f2815503561f 54 TaskLight* taskLight;
mitea1 0:f2815503561f 55 TaskTemperature* taskTemperature;
mitea1 0:f2815503561f 56 TaskPressure* taskPressure;
mitea1 0:f2815503561f 57 TaskHumidity* taskHumidity;
mitea1 0:f2815503561f 58 TaskAcceleration* taskAcceleration;
mitea1 0:f2815503561f 59 TaskGyroscope* taskGyroscope;
mitea1 0:f2815503561f 60 TaskTesla* taskTesla;
mitea1 0:f2815503561f 61 TaskProximity* taskProximity;
mitea1 0:f2815503561f 62 TaskGPS* taskGps;
mitea1 0:f2815503561f 63 TaskLoRaMeasurement* taskLoRaMeasurement;
mitea1 0:f2815503561f 64 TaskDatahandler* taskDataHandler;
mitea1 7:87cbeafdba06 65 TaskCommandHandler* taskCommandHandler;
mitea1 0:f2815503561f 66
mitea1 0:f2815503561f 67 rtos::Mutex* mutexI2C;
mitea1 0:f2815503561f 68 rtos::Mutex* mutexUART1;
mitea1 0:f2815503561f 69 rtos::Mutex mutexBME280;
mitea1 0:f2815503561f 70 rtos::Mutex mutexMAX44009;
mitea1 0:f2815503561f 71 rtos::Mutex mutexMPU9250;
mitea1 0:f2815503561f 72 rtos::Mutex mutexSi4103;
mitea1 0:f2815503561f 73 rtos::Mutex mutexUBlox;
mitea1 0:f2815503561f 74 rtos::Mutex* mutexLoRa;
mitea1 0:f2815503561f 75
mitea1 0:f2815503561f 76 Queue<MAX44009Message,LIGHT_QUEUE_LENGHT> queueLight;
mitea1 0:f2815503561f 77 Queue<BME280TemperatureMessage,TEMPERATURE_QUEUE_LENGHT> queueTemperature;
mitea1 0:f2815503561f 78 Queue<BME280PressureMessage,PRESSURE_QUEUE_LENGHT> queuePressure;
mitea1 0:f2815503561f 79 Queue<BME280HumidityMessage,HUMIDITY_QUEUE_LENGHT> queueHumidity;
mitea1 0:f2815503561f 80 Queue<MPU9250AccelerationMessage,ACCELERATION_QUEUE_LENGHT> queueAcceleration;
mitea1 0:f2815503561f 81 Queue<MPU9250GyroscopeMessage,GYROSCOPE_QUEUE_LENGHT> queueGyro;
mitea1 0:f2815503561f 82 Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT> queueTesla;
mitea1 0:f2815503561f 83 Queue<SI1143ProximityMessage,PROXIMITY_QUEUE_LENGHT> queueProximity;
mitea1 0:f2815503561f 84 Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT> queueGps;
mitea1 0:f2815503561f 85 Queue<LoRaMeasurementMessage,LORA_MEASUREMENT_QUEUE_LENGHT> queueLoRaMeasurements;
mitea1 0:f2815503561f 86 Queue<CommandMessage,COMMAND_QUEUE_LENGHT> queueCommands;
mitea1 0:f2815503561f 87
mitea1 0:f2815503561f 88 QueueBundle queueBundle;
mitea1 0:f2815503561f 89
mitea1 0:f2815503561f 90 uBlox* gpsSensor;
mitea1 0:f2815503561f 91 MAX44009* max44009;
mitea1 0:f2815503561f 92 BME280* bme280;
mitea1 0:f2815503561f 93 MPU9250* mpu9250;
mitea1 0:f2815503561f 94 SI1143* si1143;
mitea1 0:f2815503561f 95
mitea1 0:f2815503561f 96 ApplicationConfig* config;
mitea1 0:f2815503561f 97
mitea1 0:f2815503561f 98 /**
mitea1 0:f2815503561f 99 * @brief Initializes all Interfaces such as I2C, UART and a Debug Serial via USB
mitea1 0:f2815503561f 100 */
mitea1 0:f2815503561f 101 void initInterfaces();
mitea1 0:f2815503561f 102
mitea1 0:f2815503561f 103 /**
mitea1 0:f2815503561f 104 * @brief Initializes (builds) all Sensors in their specific modes
mitea1 0:f2815503561f 105 */
mitea1 0:f2815503561f 106 void initSensors();
mitea1 0:f2815503561f 107
mitea1 0:f2815503561f 108 /**
mitea1 0:f2815503561f 109 * @brief Initializes (builds) all Tasks so that they are ready to run
mitea1 0:f2815503561f 110 */
mitea1 0:f2815503561f 111 void initTasks();
mitea1 0:f2815503561f 112
mitea1 0:f2815503561f 113 /**
mitea1 0:f2815503561f 114 * @brief Initializes (builds) all Mutexes so that they are ready to be used
mitea1 0:f2815503561f 115 */
mitea1 0:f2815503561f 116 void initMutexes();
mitea1 0:f2815503561f 117
mitea1 0:f2815503561f 118 /**
mitea1 0:f2815503561f 119 * @brief Initializes (builds) the ApplicationConfig which contains information about
mitea1 0:f2815503561f 120 * which Task has to be run and how the sensors have to be configured
mitea1 0:f2815503561f 121 */
mitea1 0:f2815503561f 122 void initApplicationConfig();
mitea1 0:f2815503561f 123
mitea1 0:f2815503561f 124 /**
mitea1 1:fe242f3e341b 125 * @brief Initializes (builds) the QueueBundle
mitea1 1:fe242f3e341b 126 */
mitea1 1:fe242f3e341b 127 void initQueueBundle();
mitea1 1:fe242f3e341b 128
mitea1 1:fe242f3e341b 129 /**
mitea1 0:f2815503561f 130 * @brief Stops all tasks that are currently running. Used to define a defined state to start the application
mitea1 0:f2815503561f 131 * in a new mode or when using a transition between two application modes it is neccessary to stop all task before
mitea1 0:f2815503561f 132 * starting them again
mitea1 0:f2815503561f 133 */
mitea1 0:f2815503561f 134 void stopAllRunningSensorTasks();
mitea1 0:f2815503561f 135
mitea1 0:f2815503561f 136 /**
mitea1 0:f2815503561f 137 * @brief Starts all task which are allowed to run by the Application Config
mitea1 0:f2815503561f 138 */
mitea1 0:f2815503561f 139 void startRunnableSensorTasks();
mitea1 0:f2815503561f 140
mitea1 0:f2815503561f 141 /**
mitea1 0:f2815503561f 142 * @brief Configures and builds the sensors according to they SensorMode specific parameters
mitea1 0:f2815503561f 143 */
mitea1 0:f2815503561f 144 void configureSensors();
mitea1 0:f2815503561f 145
mitea1 0:f2815503561f 146 /**
mitea1 0:f2815503561f 147 * @brief Configures and builds the LoRa Device according to its Mode specific parameters
mitea1 0:f2815503561f 148 */
mitea1 0:f2815503561f 149 void configureLora();
mitea1 0:f2815503561f 150
mitea1 0:f2815503561f 151 };
mitea1 0:f2815503561f 152
mitea1 0:f2815503561f 153 #endif /* APPLICATION_H_ */