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:
Sun Aug 21 08:41:01 2016 +0000
Revision:
4:2674bd4168f8
Parent:
0:f2815503561f
Child:
6:90655031d4f7
implementation of sleep() and deepsleep() for the Firmwares Tasks

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /**
mitea1 0:f2815503561f 2 * @file TaksHumidity.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * @author Adrian
mitea1 0:f2815503561f 5 * @date 30.05.2016
mitea1 0:f2815503561f 6 *
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 */
mitea1 0:f2815503561f 9 #include "BME280.h"
mitea1 0:f2815503561f 10 #include "BME280HumidityMessage.h"
mitea1 0:f2815503561f 11 #include "main.h"
mitea1 0:f2815503561f 12
mitea1 0:f2815503561f 13 #ifndef TASKHUMIDITY_H_
mitea1 0:f2815503561f 14 #define TASKHUMIDITY_H_
mitea1 0:f2815503561f 15
mitea1 0:f2815503561f 16 /**
mitea1 0:f2815503561f 17 * @class TaskHumidity
mitea1 0:f2815503561f 18 * @brief This TaskHumidity Class handles the humidity measurement using the BME280.
mitea1 0:f2815503561f 19 * Starting the task using the start() starts the measurement.
mitea1 0:f2815503561f 20 * It can be used alongside with other measurement Tasks inside the mbed::rtos
mitea1 0:f2815503561f 21 * environment. The Task Class basically wraps mbeds Thread functionality.
mitea1 0:f2815503561f 22 */
mitea1 0:f2815503561f 23 class TaskHumidity {
mitea1 0:f2815503561f 24
mitea1 0:f2815503561f 25 public:
mitea1 0:f2815503561f 26 TaskHumidity(BME280*,Mutex*, Queue<BME280HumidityMessage,HUMIDITY_QUEUE_LENGHT>*);
mitea1 0:f2815503561f 27 TaskHumidity(BME280*,Mutex*,Queue<BME280HumidityMessage,HUMIDITY_QUEUE_LENGHT>*,
mitea1 0:f2815503561f 28 osPriority, uint32_t, unsigned char*);
mitea1 0:f2815503561f 29 virtual ~TaskHumidity();
mitea1 0:f2815503561f 30
mitea1 0:f2815503561f 31
mitea1 0:f2815503561f 32 /**
mitea1 0:f2815503561f 33 * Starts the task by building and its measurement
mitea1 0:f2815503561f 34 * @return
mitea1 0:f2815503561f 35 */
mitea1 0:f2815503561f 36 osStatus start();
mitea1 0:f2815503561f 37
mitea1 0:f2815503561f 38 /**
mitea1 0:f2815503561f 39 * Stops the task. Should only be used after start() was used
mitea1 0:f2815503561f 40 * @return
mitea1 0:f2815503561f 41 */
mitea1 0:f2815503561f 42 osStatus stop();
mitea1 0:f2815503561f 43
mitea1 0:f2815503561f 44
mitea1 0:f2815503561f 45 /**
mitea1 0:f2815503561f 46 * Gets the actual state of the Task either RUNNING or SLEEPING
mitea1 0:f2815503561f 47 * @return
mitea1 0:f2815503561f 48 */
mitea1 0:f2815503561f 49 TASK_STATE getState();
mitea1 0:f2815503561f 50
mitea1 0:f2815503561f 51 private:
mitea1 0:f2815503561f 52 rtos::Thread* thread;
mitea1 0:f2815503561f 53 rtos::Queue<BME280HumidityMessage,HUMIDITY_QUEUE_LENGHT>* queue;
mitea1 0:f2815503561f 54 rtos::Mutex* mutexI2C ;
mitea1 0:f2815503561f 55 osPriority priority;
mitea1 0:f2815503561f 56 uint32_t stack_size;
mitea1 0:f2815503561f 57 unsigned char *stack_pointer;
mitea1 0:f2815503561f 58
mitea1 0:f2815503561f 59 TASK_STATE state;
mitea1 0:f2815503561f 60
mitea1 0:f2815503561f 61 BME280* bme280;
mitea1 0:f2815503561f 62 BME280_MODE bme280Mode;
mitea1 0:f2815503561f 63
mitea1 0:f2815503561f 64
mitea1 0:f2815503561f 65 /**
mitea1 0:f2815503561f 66 * @brief A Callback function thats called by the mbed::Thread of this TaskClass
mitea1 0:f2815503561f 67 * @param
mitea1 0:f2815503561f 68 */
mitea1 0:f2815503561f 69 static void callBack(void const *);
mitea1 0:f2815503561f 70
mitea1 0:f2815503561f 71 /**
mitea1 0:f2815503561f 72 * @brief A thread safe method that measures the humidity. After measuring the humidity
mitea1 0:f2815503561f 73 * it stores the humidity value inside a BME280HumidityMessage
mitea1 0:f2815503561f 74 */
mitea1 0:f2815503561f 75 void measureHumidity();
mitea1 0:f2815503561f 76
mitea1 4:2674bd4168f8 77 /**
mitea1 4:2674bd4168f8 78 * @brief Attaches the idle_hook for this task
mitea1 4:2674bd4168f8 79 * @param
mitea1 4:2674bd4168f8 80 */
mitea1 4:2674bd4168f8 81 void attachIdleHook(void (*fptr) (void));
mitea1 0:f2815503561f 82
mitea1 0:f2815503561f 83 /**
mitea1 0:f2815503561f 84 * @brief Sets the message Queue of the Task where the measured values will be stored
mitea1 0:f2815503561f 85 * after the measurement
mitea1 0:f2815503561f 86 * @param queueHumidity the queue where the BME280Humidity will be stored
mitea1 0:f2815503561f 87 */
mitea1 0:f2815503561f 88 void setQueue(Queue<BME280HumidityMessage,HUMIDITY_QUEUE_LENGHT>* queueHumdity);
mitea1 0:f2815503561f 89
mitea1 0:f2815503561f 90 /**
mitea1 0:f2815503561f 91 * @brief Sets the mutex thats used for a thread safe measurement
mitea1 0:f2815503561f 92 * @param mutexI2C the I2C mutex
mitea1 0:f2815503561f 93 */
mitea1 0:f2815503561f 94 void setMutex(Mutex* mutexI2C);
mitea1 0:f2815503561f 95
mitea1 0:f2815503561f 96 /**
mitea1 0:f2815503561f 97 * @brief Sets the priority of the Task
mitea1 0:f2815503561f 98 * @param priority priority of the Task
mitea1 0:f2815503561f 99 */
mitea1 0:f2815503561f 100 void setPriority(osPriority priority);
mitea1 0:f2815503561f 101
mitea1 0:f2815503561f 102 /**
mitea1 0:f2815503561f 103 * @brief Sets the size of the Task
mitea1 0:f2815503561f 104 * @param stackSize the stack size in Bytes
mitea1 0:f2815503561f 105 */
mitea1 0:f2815503561f 106 void setStackSize(uint32_t stackSize);
mitea1 0:f2815503561f 107
mitea1 0:f2815503561f 108 /**
mitea1 0:f2815503561f 109 * @brief Sets the stack pointer of for the task stack
mitea1 0:f2815503561f 110 * @param stackPointer
mitea1 0:f2815503561f 111 */
mitea1 0:f2815503561f 112 void setStackPointer(unsigned char* stackPointer);
mitea1 0:f2815503561f 113
mitea1 0:f2815503561f 114
mitea1 0:f2815503561f 115 /**
mitea1 0:f2815503561f 116 * @brief Sets the actual state of the Task.
mitea1 0:f2815503561f 117 * @param taskState either RUNNING or SLEEPING
mitea1 0:f2815503561f 118 */
mitea1 0:f2815503561f 119 void setState(TASK_STATE);
mitea1 0:f2815503561f 120 };
mitea1 0:f2815503561f 121
mitea1 0:f2815503561f 122
mitea1 0:f2815503561f 123 #endif /* TASKHUMIDITY_H_ */