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 * @file TaskDatahandler.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * @author Adrian
mitea1 0:f2815503561f 5 * @date 27.05.2016
mitea1 0:f2815503561f 6 *
mitea1 0:f2815503561f 7 */
mitea1 0:f2815503561f 8
mitea1 0:f2815503561f 9 #ifndef TASKDATAHANDLER_H_
mitea1 0:f2815503561f 10 #define TASKDATAHANDLER_H_
mitea1 0:f2815503561f 11
mitea1 0:f2815503561f 12 #include <Thread.h>
mitea1 0:f2815503561f 13 #include <Queue.h>
mitea1 0:f2815503561f 14 #include <Mutex.h>
mitea1 0:f2815503561f 15 #include "LoRa.h"
mitea1 0:f2815503561f 16 #include "MAX44009Message.h"
mitea1 0:f2815503561f 17 #include "BME280TemperatureMessage.h"
mitea1 0:f2815503561f 18 #include "BME280PressureMessage.h"
mitea1 0:f2815503561f 19 #include "BME280HumidityMessage.h"
mitea1 0:f2815503561f 20 #include "CommandMessage.h"
mitea1 0:f2815503561f 21 #include "main.h"
mitea1 0:f2815503561f 22
mitea1 0:f2815503561f 23 /**
mitea1 0:f2815503561f 24 * @class TaskGyroscope
mitea1 0:f2815503561f 25 * @brief This TaskGyroscope Class handles all the acquired data from other Tasks
mitea1 0:f2815503561f 26 * that measure data using the different sensors of Sensbert.
mitea1 0:f2815503561f 27 * Starting the task using the start() starts the handling of the Data. The Task looks
mitea1 0:f2815503561f 28 * for queues that contains data and forwards the data from the queues via LoRa.
mitea1 0:f2815503561f 29 * The Task Class basically wraps mbeds Thread functionality.
mitea1 0:f2815503561f 30 */
mitea1 0:f2815503561f 31 class TaskDatahandler {
mitea1 0:f2815503561f 32 public:
mitea1 0:f2815503561f 33 TaskDatahandler(LoRa*,Mutex*,QueueBundle,
mitea1 0:f2815503561f 34 osPriority, uint32_t, unsigned char*);
mitea1 0:f2815503561f 35 virtual ~TaskDatahandler();
mitea1 0:f2815503561f 36
mitea1 0:f2815503561f 37
mitea1 0:f2815503561f 38 /**
mitea1 0:f2815503561f 39 * @brief Starts the task by building it and connecting a callback function to
mitea1 0:f2815503561f 40 * the mbed::Thread
mitea1 0:f2815503561f 41 * @return
mitea1 0:f2815503561f 42 */
mitea1 0:f2815503561f 43 osStatus start();
mitea1 0:f2815503561f 44
mitea1 0:f2815503561f 45 /**
mitea1 0:f2815503561f 46 * @brief Stops the task. Should only be used after start() was used
mitea1 0:f2815503561f 47 * @return
mitea1 0:f2815503561f 48 */
mitea1 0:f2815503561f 49 osStatus stop();
mitea1 0:f2815503561f 50
mitea1 0:f2815503561f 51
mitea1 0:f2815503561f 52 /**
mitea1 0:f2815503561f 53 * @brief Gets the actual state of the Task either RUNNING or SLEEPING
mitea1 0:f2815503561f 54 * @return
mitea1 0:f2815503561f 55 */
mitea1 0:f2815503561f 56 TASK_STATE getState();
mitea1 0:f2815503561f 57
mitea1 0:f2815503561f 58
mitea1 0:f2815503561f 59 /**
mitea1 0:f2815503561f 60 * @brief Set a serial interface thats used for debugging the datastream which
mitea1 0:f2815503561f 61 * will be sent via LoRa and to show data handling relevant information
mitea1 0:f2815503561f 62 * @param debugSerial the Serial interface used to show information
mitea1 0:f2815503561f 63 */
mitea1 0:f2815503561f 64 void setDebugSerial(RawSerial* debugSerial);
mitea1 0:f2815503561f 65
mitea1 0:f2815503561f 66 /**
mitea1 0:f2815503561f 67 * @brief Sets the LoRa interface thats used to forward acquired data form other
mitea1 0:f2815503561f 68 * Tasks.
mitea1 0:f2815503561f 69 * @param lora the lora interface that should be used to forward data via LoRa
mitea1 0:f2815503561f 70 */
mitea1 0:f2815503561f 71 void setLoRa(LoRa* lora);
mitea1 0:f2815503561f 72
mitea1 0:f2815503561f 73 private:
mitea1 0:f2815503561f 74 Thread* thread;
mitea1 0:f2815503561f 75 QueueBundle queueBundle;
mitea1 0:f2815503561f 76 RawSerial* debugSerial;
mitea1 0:f2815503561f 77 LoRa* lora;
mitea1 0:f2815503561f 78 Mutex* mutexLora;
mitea1 0:f2815503561f 79
mitea1 1:fe242f3e341b 80 osPriority priority;
mitea1 0:f2815503561f 81 uint32_t stack_size;
mitea1 0:f2815503561f 82 unsigned char *stack_pointer;
mitea1 0:f2815503561f 83
mitea1 0:f2815503561f 84 TASK_STATE state;
mitea1 0:f2815503561f 85
mitea1 0:f2815503561f 86 osEvent lightMeasureEvent;
mitea1 0:f2815503561f 87 osEvent temperatureMeasureEvent;
mitea1 0:f2815503561f 88 osEvent pressureMeasureEvent;
mitea1 0:f2815503561f 89 osEvent humidityMeasureEvent;
mitea1 0:f2815503561f 90 osEvent accelerationMeasureEvent;
mitea1 0:f2815503561f 91 osEvent gyroscopeMeasureEvent;
mitea1 0:f2815503561f 92 osEvent teslaMeasureEvent;
mitea1 0:f2815503561f 93 osEvent proximityMeasureEvent;
mitea1 0:f2815503561f 94 osEvent gpsMeasureEvent;
mitea1 0:f2815503561f 95 osEvent loraMeasureEvent;
mitea1 0:f2815503561f 96
mitea1 7:87cbeafdba06 97 CommandMessage commandMessage;
mitea1 7:87cbeafdba06 98
mitea1 0:f2815503561f 99
mitea1 0:f2815503561f 100 /**
mitea1 0:f2815503561f 101 * @brief A Callback function thats called by the mbed::Thread of this TaskClass
mitea1 0:f2815503561f 102 * @param
mitea1 0:f2815503561f 103 */
mitea1 0:f2815503561f 104 static void callBack(void const *);
mitea1 0:f2815503561f 105
mitea1 0:f2815503561f 106 /**
mitea1 1:fe242f3e341b 107 * @brief Attaches the idle_hook for this task
mitea1 1:fe242f3e341b 108 * @param
mitea1 1:fe242f3e341b 109 */
mitea1 1:fe242f3e341b 110 void attachIdleHook(void (*fptr) (void));
mitea1 1:fe242f3e341b 111
mitea1 1:fe242f3e341b 112 /**
mitea1 0:f2815503561f 113 * @brief A method thats handling the data which was acquired and stored into
mitea1 0:f2815503561f 114 * Message Queues
mitea1 0:f2815503561f 115 */
mitea1 0:f2815503561f 116 void handleData();
mitea1 0:f2815503561f 117
mitea1 0:f2815503561f 118 /**
mitea1 0:f2815503561f 119 * @brief Checks all queues for available data and gets it.
mitea1 0:f2815503561f 120 */
mitea1 0:f2815503561f 121 void getMessagesFromSensorQueues();
mitea1 0:f2815503561f 122
mitea1 0:f2815503561f 123 /**
mitea1 0:f2815503561f 124 * @brief Forwards all data which was in a Message Queue and
mitea1 0:f2815503561f 125 * via LoRa
mitea1 0:f2815503561f 126 */
mitea1 0:f2815503561f 127 void forwardSensorMessages();
mitea1 0:f2815503561f 128
mitea1 7:87cbeafdba06 129 /**
mitea1 7:87cbeafdba06 130 * @brief Forwards the received commands from LoRa to a CommandMessageQueue
mitea1 7:87cbeafdba06 131 */
mitea1 7:87cbeafdba06 132 void forwardCommandMessages();
mitea1 0:f2815503561f 133
mitea1 0:f2815503561f 134 /**
mitea1 0:f2815503561f 135 * @brief Sets the mutex for accessing and using the LoRa interface
mitea1 0:f2815503561f 136 * @param mutexLoRa
mitea1 0:f2815503561f 137 */
mitea1 0:f2815503561f 138 void setMutex(Mutex* mutexLoRa);
mitea1 0:f2815503561f 139
mitea1 0:f2815503561f 140 /**
mitea1 0:f2815503561f 141 * @brief Sets the bundle that holds all other queues that can store
mitea1 0:f2815503561f 142 * measured sensor data
mitea1 0:f2815503561f 143 * @param queueBundle bundle that holds all the other queues
mitea1 0:f2815503561f 144 */
mitea1 0:f2815503561f 145 void setQueueBundle(QueueBundle queueBundle);
mitea1 0:f2815503561f 146
mitea1 0:f2815503561f 147 /**
mitea1 0:f2815503561f 148 * @brief Sets the priority of the Task
mitea1 0:f2815503561f 149 * @param priority priority of the Task
mitea1 0:f2815503561f 150 */
mitea1 0:f2815503561f 151 void setPriority(osPriority priority);
mitea1 0:f2815503561f 152
mitea1 0:f2815503561f 153 /**
mitea1 0:f2815503561f 154 * @brief Sets the size of the Task
mitea1 0:f2815503561f 155 * @param stackSize the stack size in Bytes
mitea1 0:f2815503561f 156 */
mitea1 0:f2815503561f 157 void setStackSize(uint32_t stackSize);
mitea1 0:f2815503561f 158
mitea1 0:f2815503561f 159 /**
mitea1 0:f2815503561f 160 * @brief Sets the stack pointer of for the task stack
mitea1 0:f2815503561f 161 * @param stackPointer
mitea1 0:f2815503561f 162 */
mitea1 0:f2815503561f 163 void setStackPointer(unsigned char* stackPointer);
mitea1 0:f2815503561f 164
mitea1 0:f2815503561f 165 /**
mitea1 0:f2815503561f 166 * @brief Sets the actual state of the Task.
mitea1 0:f2815503561f 167 * @param taskState either RUNNING or SLEEPING
mitea1 0:f2815503561f 168 */
mitea1 0:f2815503561f 169 void setState(TASK_STATE taskState);
mitea1 0:f2815503561f 170
mitea1 0:f2815503561f 171 };
mitea1 0:f2815503561f 172
mitea1 0:f2815503561f 173 #endif /* TASKDATAHANDLER_H_ */