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 TaskCommandHandler.h Source File

TaskCommandHandler.h

Go to the documentation of this file.
00001 /**
00002  * @file TaskCommandHandler.h
00003  *
00004  * @author Adrian
00005  * @date 11.09.2016
00006  *
00007  */
00008 
00009 #ifndef TASKCOMMANDHANDLER_H_
00010 #define TASKCOMMANDHANDLER_H_
00011 
00012 #include <Thread.h>
00013 #include <Queue.h>
00014 #include <Mutex.h>
00015 #include "LoRa.h "
00016 #include "MAX44009Message.h "
00017 #include "CommandMessage.h "
00018 #include "main.h"
00019 
00020 /**
00021  * @class TaskCommandHandler
00022  * @brief This TaskCommandHandler Class handles all the received Commands from LoRa
00023  */
00024 class TaskCommandHandler {
00025 public:
00026 
00027     TaskCommandHandler(Queue<CommandMessage,COMMAND_QUEUE_LENGHT>*,
00028             osPriority, uint32_t, unsigned char*);
00029     virtual ~TaskCommandHandler();
00030     /**
00031      * @brief Starts the task by building it and connecting a callback function to
00032      * the mbed::Thread
00033      * @return
00034      */
00035     osStatus start();
00036 
00037     /**
00038      * @brief Stops the task. Should only be used after start() was used
00039      * @return
00040      */
00041     osStatus stop();
00042 
00043 
00044     /**
00045      * @brief Gets the actual state of the Task either RUNNING or SLEEPING
00046      * @return
00047      */
00048     TASK_STATE getState();
00049 
00050 
00051     /**
00052      * @brief Set a serial interface thats used for debugging the datastream which
00053      * will be sent via LoRa and to show data handling relevant information
00054      * @param debugSerial the Serial interface used to show information
00055      */
00056     void setDebugSerial(RawSerial* debugSerial);
00057 
00058 private:
00059     Thread* thread;
00060     RawSerial* debugSerial;
00061     rtos::Queue<CommandMessage,COMMAND_QUEUE_LENGHT>* queue;
00062 
00063     osPriority priority;
00064     uint32_t stack_size;
00065     unsigned char *stack_pointer;
00066 
00067     TASK_STATE state;
00068 
00069     osEvent commandReceiveEvent;
00070 
00071 
00072     /**
00073      * @brief A Callback function thats called by the mbed::Thread of this TaskClass
00074      * @param
00075      */
00076     static void callBack(void const *);
00077 
00078     /**
00079      * @brief Attaches the idle_hook for this task
00080      * @param
00081      */
00082     void attachIdleHook(void (*fptr) (void));
00083 
00084     /**
00085      * @brief A method thats handling the data which was acquired and stored into
00086      * Message Queues
00087      */
00088     void handleCommands();
00089 
00090     /**
00091      * @brief Checks all queues for available data and gets it.
00092      */
00093     void getCommandMessages();
00094 
00095     /**
00096      * @brief Processes received commands from command Queue
00097      */
00098     void processCommands();
00099 
00100 
00101     /**
00102      * @brief Sets the message Queue of the Task where the received commands are stored
00103      * after the reception via LoRa
00104      * @param queueCommand the queue where the CommandMessage will be stored
00105      */
00106     void setQueue(Queue<CommandMessage,COMMAND_QUEUE_LENGHT>* queueCommand);
00107 
00108     /**
00109      * @brief Sets the priority of the Task
00110      * @param priority priority of the Task
00111      */
00112     void setPriority(osPriority priority);
00113 
00114     /**
00115      * @brief Sets the size of the Task
00116      * @param stackSize the stack size in Bytes
00117      */
00118     void setStackSize(uint32_t stackSize);
00119 
00120     /**
00121      * @brief Sets the stack pointer of for the task stack
00122      * @param stackPointer
00123      */
00124     void setStackPointer(unsigned char* stackPointer);
00125 
00126     /**
00127      * @brief Sets the actual state of the Task.
00128      * @param taskState either RUNNING or SLEEPING
00129      */
00130     void setState(TASK_STATE taskState);
00131 
00132 };
00133 
00134 #endif /* TASKCOMMANDHANDLER_H_ */