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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Task.cpp Source File

Task.cpp

00001 /*
00002  * Task.cpp
00003  *
00004  *  Created on: Sep 9, 2016
00005  *      Author: Adrian
00006  */
00007 
00008 #include "Task.h"
00009 
00010 Task::Task() {
00011     // TODO Auto-generated constructor stub
00012 
00013 }
00014 
00015 Task::~Task() {
00016     // TODO Auto-generated destructor stub
00017 }
00018 
00019 osStatus Task::start(){
00020     setState(RUNNING);
00021     this->thread = new rtos::Thread(callBack,this);
00022 }
00023 
00024 osStatus Task::stop(){
00025     thread->terminate();
00026     setState(SLEEPING);
00027     delete this->thread;
00028 }
00029 
00030 void Task::callBack(void const* data){
00031     // WOODHAMMER METHOD of Casting!
00032     const Task* constInstance = static_cast<const Task* >(data);
00033     Task* instance = const_cast<Task*>(constInstance);
00034 
00035     instance->measure();
00036 }
00037 
00038 void Task::attachIdleHook(void (*fptr) (void)){
00039     this->thread->attach_idle_hook(fptr);
00040 }
00041 
00042 void Task::setMutex(Mutex* mutex){
00043     this->mutexInterface = mutex;
00044 }
00045 
00046 void Task::setPriority(osPriority priority){
00047     this->priority = priority;
00048 }
00049 
00050 void Task::setStackSize(uint32_t stacksize){
00051     this->stack_size = stacksize;
00052 }
00053 
00054 void Task::setStackPointer(unsigned char* stackPointer){
00055     this->stack_pointer = stackPointer;
00056 }
00057 
00058 void Task::setState(TASK_STATE state){
00059     this->state = state;
00060 }
00061 
00062 TASK_STATE Task::getState(){
00063     return state;
00064 }
00065