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 Aug 12 11:19:14 2016 +0000
Revision:
1:fe242f3e341b
Parent:
0:f2815503561f
Child:
7:87cbeafdba06
added OTAA Join Mode for LoRa Connection

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