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 * TaskTesla.cpp
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * Created on: 01.06.2016
mitea1 0:f2815503561f 5 * Author: Adrian
mitea1 0:f2815503561f 6 */
mitea1 0:f2815503561f 7
mitea1 0:f2815503561f 8 #include "TaskTesla.h"
mitea1 0:f2815503561f 9
mitea1 0:f2815503561f 10 TaskTesla::TaskTesla(MPU9250* mpu9250,Mutex* mutexI2C, Queue<MPU9250TeslaMessage,TESLA_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 0:f2815503561f 16 TaskTesla::TaskTesla(MPU9250* mpu9250,rtos::Mutex* mutexI2C,
mitea1 0:f2815503561f 17 rtos::Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT>* queue,
mitea1 0:f2815503561f 18 osPriority priority, uint32_t stackSize, unsigned char *stackPointer){
mitea1 0:f2815503561f 19 this->mpu9250 = mpu9250;
mitea1 0:f2815503561f 20 setMutex(mutexI2C);
mitea1 0:f2815503561f 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 TaskTesla::~TaskTesla() {
mitea1 0:f2815503561f 29 // TODO Auto-generated destructor stub
mitea1 0:f2815503561f 30 }
mitea1 0:f2815503561f 31
mitea1 0:f2815503561f 32 osStatus TaskTesla::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 TaskTesla::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 TaskTesla::callBack(void const* data){
mitea1 0:f2815503561f 44 // WOODHAMMER METHOD of Casting!
mitea1 0:f2815503561f 45 const TaskTesla* constInstance = static_cast<const TaskTesla* >(data);
mitea1 0:f2815503561f 46 TaskTesla* instance = const_cast<TaskTesla*>(constInstance);
mitea1 0:f2815503561f 47
mitea1 0:f2815503561f 48 instance->measureTesla();
mitea1 0:f2815503561f 49 }
mitea1 0:f2815503561f 50
mitea1 4:2674bd4168f8 51 void TaskTesla::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 TaskTesla::measureTesla(){
mitea1 0:f2815503561f 56 MPU9250TeslaMessage mpu9250TeslaMessage;
mitea1 0:f2815503561f 57
mitea1 0:f2815503561f 58 while(true){
mitea1 0:f2815503561f 59 mutexI2C->lock(osWaitForever);
mitea1 0:f2815503561f 60 mpu9250TeslaMessage.setXTesla(mpu9250->getXAxisTesla());
mitea1 0:f2815503561f 61 mpu9250TeslaMessage.setYTesla(mpu9250->getYAxisTesla());
mitea1 0:f2815503561f 62 mpu9250TeslaMessage.setZTesla(mpu9250->getZAxisTesla());
mitea1 0:f2815503561f 63 mutexI2C->unlock();
mitea1 0:f2815503561f 64
mitea1 0:f2815503561f 65 queue->put(&mpu9250TeslaMessage,osWaitForever);
mitea1 0:f2815503561f 66 osDelay(TESLA_TASK_DELAY_MS);
mitea1 0:f2815503561f 67 }
mitea1 0:f2815503561f 68 }
mitea1 0:f2815503561f 69
mitea1 0:f2815503561f 70 void TaskTesla::setQueue(Queue<MPU9250TeslaMessage,TESLA_QUEUE_LENGHT>* queue){
mitea1 0:f2815503561f 71 this->queue = queue;
mitea1 0:f2815503561f 72 }
mitea1 0:f2815503561f 73
mitea1 0:f2815503561f 74 void TaskTesla::setMutex(Mutex* mutex){
mitea1 0:f2815503561f 75 this->mutexI2C = mutex;
mitea1 0:f2815503561f 76 }
mitea1 0:f2815503561f 77
mitea1 0:f2815503561f 78 void TaskTesla::setPriority(osPriority priority){
mitea1 0:f2815503561f 79 this->priority = priority;
mitea1 0:f2815503561f 80 }
mitea1 0:f2815503561f 81
mitea1 0:f2815503561f 82 void TaskTesla::setStackSize(uint32_t stacksize){
mitea1 0:f2815503561f 83 this->stack_size = stacksize;
mitea1 0:f2815503561f 84 }
mitea1 0:f2815503561f 85
mitea1 0:f2815503561f 86 void TaskTesla::setStackPointer(unsigned char* stackPointer){
mitea1 0:f2815503561f 87 this->stack_pointer = stackPointer;
mitea1 0:f2815503561f 88 }
mitea1 0:f2815503561f 89
mitea1 0:f2815503561f 90 void TaskTesla::setState(TASK_STATE state){
mitea1 0:f2815503561f 91 this->state = state;
mitea1 0:f2815503561f 92 }
mitea1 0:f2815503561f 93
mitea1 0:f2815503561f 94 TASK_STATE TaskTesla::getState(){
mitea1 0:f2815503561f 95 return state;
mitea1 0:f2815503561f 96 }
mitea1 0:f2815503561f 97