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 * TaskAcceleration.cpp
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * Created on: May 30, 2016
mitea1 0:f2815503561f 5 * Author: Adrian
mitea1 0:f2815503561f 6 */
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 #include "TaskAcceleration.h"
mitea1 0:f2815503561f 9
mitea1 0:f2815503561f 10 TaskAcceleration::TaskAcceleration(MPU9250* mpu9250,Mutex* mutexI2C, Queue<MPU9250AccelerationMessage,ACCELERATION_QUEUE_LENGHT>* queue){
mitea1 0:f2815503561f 11 this->mpu9250 = mpu9250;
mitea1 0:f2815503561f 12 setMutex(mutexI2C);
mitea1 0:f2815503561f 13 setQueue(queue);
mitea1 0:f2815503561f 14 }
mitea1 0:f2815503561f 15
mitea1 4:2674bd4168f8 16 TaskAcceleration::TaskAcceleration(MPU9250* mpu9250,rtos::Mutex* mutexI2C,
mitea1 4:2674bd4168f8 17 rtos::Queue<MPU9250AccelerationMessage,ACCELERATION_QUEUE_LENGHT>* queue,
mitea1 0:f2815503561f 18 osPriority priority, uint32_t stackSize, unsigned char *stackPointer){
mitea1 0:f2815503561f 19 this->mpu9250 = mpu9250;
mitea1 4:2674bd4168f8 20 setMutex(mutexI2C);
mitea1 4:2674bd4168f8 21 setQueue(queue);
mitea1 0:f2815503561f 22 setPriority(priority);
mitea1 0:f2815503561f 23 setStackSize(stackSize);
mitea1 0:f2815503561f 24 setStackPointer(stackPointer);
mitea1 0:f2815503561f 25 setState(SLEEPING);
mitea1 0:f2815503561f 26 }
mitea1 0:f2815503561f 27
mitea1 0:f2815503561f 28 TaskAcceleration::~TaskAcceleration() {
mitea1 0:f2815503561f 29 // TODO Auto-generated destructor stub
mitea1 0:f2815503561f 30 }
mitea1 0:f2815503561f 31
mitea1 0:f2815503561f 32 osStatus TaskAcceleration::start(){
mitea1 0:f2815503561f 33 setState(RUNNING);
mitea1 0:f2815503561f 34 this->thread = new rtos::Thread(callBack,this);
mitea1 0:f2815503561f 35 }
mitea1 0:f2815503561f 36
mitea1 0:f2815503561f 37 osStatus TaskAcceleration::stop(){
mitea1 0:f2815503561f 38 thread->terminate();
mitea1 0:f2815503561f 39 setState(SLEEPING);
mitea1 0:f2815503561f 40 delete this->thread;
mitea1 0:f2815503561f 41 }
mitea1 0:f2815503561f 42
mitea1 0:f2815503561f 43 void TaskAcceleration::callBack(void const* data){
mitea1 0:f2815503561f 44 // WOODHAMMER METHOD of Casting!
mitea1 0:f2815503561f 45 const TaskAcceleration* constInstance = static_cast<const TaskAcceleration* >(data);
mitea1 0:f2815503561f 46 TaskAcceleration* instance = const_cast<TaskAcceleration*>(constInstance);
mitea1 0:f2815503561f 47
mitea1 0:f2815503561f 48 instance->measureAcceleration();
mitea1 0:f2815503561f 49 }
mitea1 0:f2815503561f 50
mitea1 4:2674bd4168f8 51 void TaskAcceleration::attachIdleHook(void (*fptr) (void)){
mitea1 4:2674bd4168f8 52 this->thread->attach_idle_hook(fptr);
mitea1 4:2674bd4168f8 53 }
mitea1 4:2674bd4168f8 54
mitea1 0:f2815503561f 55 void TaskAcceleration::measureAcceleration(){
mitea1 0:f2815503561f 56 MPU9250AccelerationMessage mpu9250AccelerationMessage;
mitea1 0:f2815503561f 57
mitea1 0:f2815503561f 58 while(true){
mitea1 0:f2815503561f 59 mutexI2C->lock(osWaitForever);
mitea1 0:f2815503561f 60 mpu9250AccelerationMessage.setXAcceleration(mpu9250->getXAxisAcceleration());
mitea1 0:f2815503561f 61 mpu9250AccelerationMessage.setYAcceleration(mpu9250->getYAxisAcceleration());
mitea1 0:f2815503561f 62 mpu9250AccelerationMessage.setZAcceleration(mpu9250->getZAxisAcceleration());
mitea1 0:f2815503561f 63 mutexI2C->unlock();
mitea1 0:f2815503561f 64
mitea1 0:f2815503561f 65 queue->put(&mpu9250AccelerationMessage,osWaitForever);
mitea1 0:f2815503561f 66 osDelay(ACCELERATION_TASK_DELAY_MS);
mitea1 0:f2815503561f 67 }
mitea1 0:f2815503561f 68
mitea1 0:f2815503561f 69
mitea1 0:f2815503561f 70 }
mitea1 0:f2815503561f 71
mitea1 0:f2815503561f 72 void TaskAcceleration::setQueue(Queue<MPU9250AccelerationMessage,ACCELERATION_QUEUE_LENGHT>* queue){
mitea1 0:f2815503561f 73 this->queue = queue;
mitea1 0:f2815503561f 74 }
mitea1 0:f2815503561f 75
mitea1 0:f2815503561f 76 void TaskAcceleration::setMutex(Mutex* mutex){
mitea1 0:f2815503561f 77 this->mutexI2C = mutex;
mitea1 0:f2815503561f 78 }
mitea1 0:f2815503561f 79
mitea1 0:f2815503561f 80 void TaskAcceleration::setPriority(osPriority priority){
mitea1 0:f2815503561f 81 this->priority = priority;
mitea1 0:f2815503561f 82 }
mitea1 0:f2815503561f 83
mitea1 0:f2815503561f 84 void TaskAcceleration::setStackSize(uint32_t stacksize){
mitea1 0:f2815503561f 85 this->stack_size = stacksize;
mitea1 0:f2815503561f 86 }
mitea1 0:f2815503561f 87
mitea1 0:f2815503561f 88 void TaskAcceleration::setStackPointer(unsigned char* stackPointer){
mitea1 0:f2815503561f 89 this->stack_pointer = stackPointer;
mitea1 0:f2815503561f 90 }
mitea1 0:f2815503561f 91
mitea1 0:f2815503561f 92 void TaskAcceleration::setState(TASK_STATE state){
mitea1 0:f2815503561f 93 this->state = state;
mitea1 0:f2815503561f 94 }
mitea1 0:f2815503561f 95
mitea1 0:f2815503561f 96 TASK_STATE TaskAcceleration::getState(){
mitea1 0:f2815503561f 97 return state;
mitea1 0:f2815503561f 98 }
mitea1 0:f2815503561f 99