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:
9:c4e378f4801d
wtf

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 9:c4e378f4801d 21 #include "FlowMeterMessage.h"
mitea1 0:f2815503561f 22 #include "main.h"
mitea1 0:f2815503561f 23
mitea1 0:f2815503561f 24 /**
mitea1 0:f2815503561f 25 * @class TaskGyroscope
mitea1 0:f2815503561f 26 * @brief This TaskGyroscope Class handles all the acquired data from other Tasks
mitea1 0:f2815503561f 27 * that measure data using the different sensors of Sensbert.
mitea1 0:f2815503561f 28 * Starting the task using the start() starts the handling of the Data. The Task looks
mitea1 0:f2815503561f 29 * for queues that contains data and forwards the data from the queues via LoRa.
mitea1 0:f2815503561f 30 * The Task Class basically wraps mbeds Thread functionality.
mitea1 0:f2815503561f 31 */
mitea1 0:f2815503561f 32 class TaskDatahandler {
mitea1 0:f2815503561f 33 public:
mitea1 0:f2815503561f 34 TaskDatahandler(LoRa*,Mutex*,QueueBundle,
mitea1 0:f2815503561f 35 osPriority, uint32_t, unsigned char*);
mitea1 0:f2815503561f 36 virtual ~TaskDatahandler();
mitea1 0:f2815503561f 37
mitea1 0:f2815503561f 38
mitea1 0:f2815503561f 39 /**
mitea1 0:f2815503561f 40 * @brief Starts the task by building it and connecting a callback function to
mitea1 0:f2815503561f 41 * the mbed::Thread
mitea1 0:f2815503561f 42 * @return
mitea1 0:f2815503561f 43 */
mitea1 0:f2815503561f 44 osStatus start();
mitea1 0:f2815503561f 45
mitea1 0:f2815503561f 46 /**
mitea1 0:f2815503561f 47 * @brief Stops the task. Should only be used after start() was used
mitea1 0:f2815503561f 48 * @return
mitea1 0:f2815503561f 49 */
mitea1 0:f2815503561f 50 osStatus stop();
mitea1 0:f2815503561f 51
mitea1 0:f2815503561f 52
mitea1 0:f2815503561f 53 /**
mitea1 0:f2815503561f 54 * @brief Gets the actual state of the Task either RUNNING or SLEEPING
mitea1 0:f2815503561f 55 * @return
mitea1 0:f2815503561f 56 */
mitea1 0:f2815503561f 57 TASK_STATE getState();
mitea1 0:f2815503561f 58
mitea1 0:f2815503561f 59
mitea1 0:f2815503561f 60 /**
mitea1 0:f2815503561f 61 * @brief Set a serial interface thats used for debugging the datastream which
mitea1 0:f2815503561f 62 * will be sent via LoRa and to show data handling relevant information
mitea1 0:f2815503561f 63 * @param debugSerial the Serial interface used to show information
mitea1 0:f2815503561f 64 */
mitea1 0:f2815503561f 65 void setDebugSerial(RawSerial* debugSerial);
mitea1 0:f2815503561f 66
mitea1 0:f2815503561f 67 /**
mitea1 0:f2815503561f 68 * @brief Sets the LoRa interface thats used to forward acquired data form other
mitea1 0:f2815503561f 69 * Tasks.
mitea1 0:f2815503561f 70 * @param lora the lora interface that should be used to forward data via LoRa
mitea1 0:f2815503561f 71 */
mitea1 0:f2815503561f 72 void setLoRa(LoRa* lora);
mitea1 0:f2815503561f 73
mitea1 0:f2815503561f 74 private:
mitea1 0:f2815503561f 75 Thread* thread;
mitea1 0:f2815503561f 76 QueueBundle queueBundle;
mitea1 0:f2815503561f 77 RawSerial* debugSerial;
mitea1 0:f2815503561f 78 LoRa* lora;
mitea1 0:f2815503561f 79 Mutex* mutexLora;
mitea1 0:f2815503561f 80
mitea1 1:fe242f3e341b 81 osPriority priority;
mitea1 0:f2815503561f 82 uint32_t stack_size;
mitea1 0:f2815503561f 83 unsigned char *stack_pointer;
mitea1 0:f2815503561f 84
mitea1 0:f2815503561f 85 TASK_STATE state;
mitea1 0:f2815503561f 86
mitea1 0:f2815503561f 87 osEvent lightMeasureEvent;
mitea1 0:f2815503561f 88 osEvent temperatureMeasureEvent;
mitea1 0:f2815503561f 89 osEvent pressureMeasureEvent;
mitea1 0:f2815503561f 90 osEvent humidityMeasureEvent;
mitea1 0:f2815503561f 91 osEvent accelerationMeasureEvent;
mitea1 0:f2815503561f 92 osEvent gyroscopeMeasureEvent;
mitea1 0:f2815503561f 93 osEvent teslaMeasureEvent;
mitea1 0:f2815503561f 94 osEvent proximityMeasureEvent;
mitea1 0:f2815503561f 95 osEvent gpsMeasureEvent;
mitea1 9:c4e378f4801d 96 osEvent flowMeasureEvent;
mitea1 0:f2815503561f 97 osEvent loraMeasureEvent;
mitea1 0:f2815503561f 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 0:f2815503561f 129
mitea1 0:f2815503561f 130 /**
mitea1 0:f2815503561f 131 * @brief Sets the mutex for accessing and using the LoRa interface
mitea1 0:f2815503561f 132 * @param mutexLoRa
mitea1 0:f2815503561f 133 */
mitea1 0:f2815503561f 134 void setMutex(Mutex* mutexLoRa);
mitea1 0:f2815503561f 135
mitea1 0:f2815503561f 136 /**
mitea1 0:f2815503561f 137 * @brief Sets the bundle that holds all other queues that can store
mitea1 0:f2815503561f 138 * measured sensor data
mitea1 0:f2815503561f 139 * @param queueBundle bundle that holds all the other queues
mitea1 0:f2815503561f 140 */
mitea1 0:f2815503561f 141 void setQueueBundle(QueueBundle queueBundle);
mitea1 0:f2815503561f 142
mitea1 0:f2815503561f 143 /**
mitea1 0:f2815503561f 144 * @brief Sets the priority of the Task
mitea1 0:f2815503561f 145 * @param priority priority of the Task
mitea1 0:f2815503561f 146 */
mitea1 0:f2815503561f 147 void setPriority(osPriority priority);
mitea1 0:f2815503561f 148
mitea1 0:f2815503561f 149 /**
mitea1 0:f2815503561f 150 * @brief Sets the size of the Task
mitea1 0:f2815503561f 151 * @param stackSize the stack size in Bytes
mitea1 0:f2815503561f 152 */
mitea1 0:f2815503561f 153 void setStackSize(uint32_t stackSize);
mitea1 0:f2815503561f 154
mitea1 0:f2815503561f 155 /**
mitea1 0:f2815503561f 156 * @brief Sets the stack pointer of for the task stack
mitea1 0:f2815503561f 157 * @param stackPointer
mitea1 0:f2815503561f 158 */
mitea1 0:f2815503561f 159 void setStackPointer(unsigned char* stackPointer);
mitea1 0:f2815503561f 160
mitea1 0:f2815503561f 161 /**
mitea1 0:f2815503561f 162 * @brief Sets the actual state of the Task.
mitea1 0:f2815503561f 163 * @param taskState either RUNNING or SLEEPING
mitea1 0:f2815503561f 164 */
mitea1 0:f2815503561f 165 void setState(TASK_STATE taskState);
mitea1 0:f2815503561f 166
mitea1 0:f2815503561f 167 };
mitea1 0:f2815503561f 168
mitea1 0:f2815503561f 169 #endif /* TASKDATAHANDLER_H_ */