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:
Wed Jul 06 20:40:36 2016 +0000
Revision:
0:f2815503561f
Child:
4:2674bd4168f8
initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /*
mitea1 0:f2815503561f 2 * TaskGPS.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 "TaskGPS.h"
mitea1 0:f2815503561f 9
mitea1 0:f2815503561f 10 TaskGPS::TaskGPS(uBlox* uBlox,Mutex* mutexUART, Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue){
mitea1 0:f2815503561f 11 this->mUBlox = uBlox;
mitea1 0:f2815503561f 12 setMutex(mutexUART);
mitea1 0:f2815503561f 13 setQueue(queue);
mitea1 0:f2815503561f 14 }
mitea1 0:f2815503561f 15
mitea1 0:f2815503561f 16 TaskGPS::TaskGPS(uBlox* uBlox,rtos::Mutex* mutexUART,
mitea1 0:f2815503561f 17 rtos::Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue,
mitea1 0:f2815503561f 18 osPriority priority, uint32_t stackSize, unsigned char *stackPointer){
mitea1 0:f2815503561f 19 this->mUBlox = uBlox;
mitea1 0:f2815503561f 20 setMutex(mutexUART);
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 TaskGPS::~TaskGPS() {
mitea1 0:f2815503561f 29 // TODO Auto-generated destructor stub
mitea1 0:f2815503561f 30 }
mitea1 0:f2815503561f 31
mitea1 0:f2815503561f 32 osStatus TaskGPS::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 TaskGPS::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 TaskGPS::callBack(void const* data){
mitea1 0:f2815503561f 44 // WOODHAMMER METHOD of Casting!
mitea1 0:f2815503561f 45 const TaskGPS* constInstance = static_cast<const TaskGPS* >(data);
mitea1 0:f2815503561f 46 TaskGPS* instance = const_cast<TaskGPS*>(constInstance);
mitea1 0:f2815503561f 47
mitea1 0:f2815503561f 48 instance->measureGps();
mitea1 0:f2815503561f 49 }
mitea1 0:f2815503561f 50
mitea1 0:f2815503561f 51 void TaskGPS::measureGps(){
mitea1 0:f2815503561f 52 UBloxGPSMessage uBloxGPSMessage;
mitea1 0:f2815503561f 53
mitea1 0:f2815503561f 54 while(true){
mitea1 0:f2815503561f 55 mutexUART->lock(osWaitForever);
mitea1 0:f2815503561f 56 uBloxGPSMessage.setLongitude(mUBlox->getLongitude());
mitea1 0:f2815503561f 57 uBloxGPSMessage.setLatitude(mUBlox->getLatitude());
mitea1 0:f2815503561f 58 mutexUART->unlock();
mitea1 0:f2815503561f 59
mitea1 0:f2815503561f 60 queue->put(&uBloxGPSMessage,osWaitForever);
mitea1 0:f2815503561f 61 osDelay(GPS_TASK_DELAY_MS);
mitea1 0:f2815503561f 62 }
mitea1 0:f2815503561f 63
mitea1 0:f2815503561f 64
mitea1 0:f2815503561f 65 }
mitea1 0:f2815503561f 66
mitea1 0:f2815503561f 67 void TaskGPS::setQueue(Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue){
mitea1 0:f2815503561f 68 this->queue = queue;
mitea1 0:f2815503561f 69 }
mitea1 0:f2815503561f 70
mitea1 0:f2815503561f 71 void TaskGPS::setMutex(Mutex* mutex){
mitea1 0:f2815503561f 72 this->mutexUART = mutex;
mitea1 0:f2815503561f 73 }
mitea1 0:f2815503561f 74
mitea1 0:f2815503561f 75 void TaskGPS::setPriority(osPriority priority){
mitea1 0:f2815503561f 76 this->priority = priority;
mitea1 0:f2815503561f 77 }
mitea1 0:f2815503561f 78
mitea1 0:f2815503561f 79 void TaskGPS::setStackSize(uint32_t stacksize){
mitea1 0:f2815503561f 80 this->stack_size = stacksize;
mitea1 0:f2815503561f 81 }
mitea1 0:f2815503561f 82
mitea1 0:f2815503561f 83 void TaskGPS::setStackPointer(unsigned char* stackPointer){
mitea1 0:f2815503561f 84 this->stack_pointer = stackPointer;
mitea1 0:f2815503561f 85 }
mitea1 0:f2815503561f 86
mitea1 0:f2815503561f 87 void TaskGPS::setState(TASK_STATE state){
mitea1 0:f2815503561f 88 this->state = state;
mitea1 0:f2815503561f 89 }
mitea1 0:f2815503561f 90
mitea1 0:f2815503561f 91 TASK_STATE TaskGPS::getState(){
mitea1 0:f2815503561f 92 return state;
mitea1 0:f2815503561f 93 }
mitea1 0:f2815503561f 94