SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
TaskDatahandler.h
00001 /** 00002 * @file TaskDatahandler.h 00003 * 00004 * @author Adrian 00005 * @date 27.05.2016 00006 * 00007 */ 00008 00009 #ifndef TASKDATAHANDLER_H_ 00010 #define TASKDATAHANDLER_H_ 00011 00012 #include <Thread.h> 00013 #include <Queue.h> 00014 #include <Mutex.h> 00015 #include "LoRa.h " 00016 #include "MAX44009Message.h " 00017 #include "BME280TemperatureMessage.h " 00018 #include "BME280PressureMessage.h " 00019 #include "BME280HumidityMessage.h " 00020 #include "CommandMessage.h" 00021 #include "main.h" 00022 00023 /** 00024 * @class TaskGyroscope 00025 * @brief This TaskGyroscope Class handles all the acquired data from other Tasks 00026 * that measure data using the different sensors of Sensbert. 00027 * Starting the task using the start() starts the handling of the Data. The Task looks 00028 * for queues that contains data and forwards the data from the queues via LoRa. 00029 * The Task Class basically wraps mbeds Thread functionality. 00030 */ 00031 class TaskDatahandler { 00032 public: 00033 TaskDatahandler(LoRa*,Mutex*,QueueBundle, 00034 osPriority, uint32_t, unsigned char*); 00035 virtual ~TaskDatahandler(); 00036 00037 00038 /** 00039 * @brief Starts the task by building it and connecting a callback function to 00040 * the mbed::Thread 00041 * @return 00042 */ 00043 osStatus start(); 00044 00045 /** 00046 * @brief Stops the task. Should only be used after start() was used 00047 * @return 00048 */ 00049 osStatus stop(); 00050 00051 00052 /** 00053 * @brief Gets the actual state of the Task either RUNNING or SLEEPING 00054 * @return 00055 */ 00056 TASK_STATE getState(); 00057 00058 00059 /** 00060 * @brief Set a serial interface thats used for debugging the datastream which 00061 * will be sent via LoRa and to show data handling relevant information 00062 * @param debugSerial the Serial interface used to show information 00063 */ 00064 void setDebugSerial(RawSerial* debugSerial); 00065 00066 /** 00067 * @brief Sets the LoRa interface thats used to forward acquired data form other 00068 * Tasks. 00069 * @param lora the lora interface that should be used to forward data via LoRa 00070 */ 00071 void setLoRa(LoRa* lora); 00072 00073 private: 00074 Thread* thread; 00075 QueueBundle queueBundle; 00076 RawSerial* debugSerial; 00077 LoRa* lora; 00078 Mutex* mutexLora; 00079 00080 osPriority priority; 00081 uint32_t stack_size; 00082 unsigned char *stack_pointer; 00083 00084 TASK_STATE state; 00085 00086 osEvent lightMeasureEvent; 00087 osEvent temperatureMeasureEvent; 00088 osEvent pressureMeasureEvent; 00089 osEvent humidityMeasureEvent; 00090 osEvent accelerationMeasureEvent; 00091 osEvent gyroscopeMeasureEvent; 00092 osEvent teslaMeasureEvent; 00093 osEvent proximityMeasureEvent; 00094 osEvent gpsMeasureEvent; 00095 osEvent loraMeasureEvent; 00096 00097 00098 /** 00099 * @brief A Callback function thats called by the mbed::Thread of this TaskClass 00100 * @param 00101 */ 00102 static void callBack(void const *); 00103 00104 /** 00105 * @brief Attaches the idle_hook for this task 00106 * @param 00107 */ 00108 void attachIdleHook(void (*fptr) (void)); 00109 00110 /** 00111 * @brief A method thats handling the data which was acquired and stored into 00112 * Message Queues 00113 */ 00114 void handleData(); 00115 00116 /** 00117 * @brief Checks all queues for available data and gets it. 00118 */ 00119 void getMessagesFromSensorQueues(); 00120 00121 /** 00122 * @brief Forwards all data which was in a Message Queue and 00123 * via LoRa 00124 */ 00125 void forwardSensorMessages(); 00126 00127 00128 /** 00129 * @brief Sets the mutex for accessing and using the LoRa interface 00130 * @param mutexLoRa 00131 */ 00132 void setMutex(Mutex* mutexLoRa); 00133 00134 /** 00135 * @brief Sets the bundle that holds all other queues that can store 00136 * measured sensor data 00137 * @param queueBundle bundle that holds all the other queues 00138 */ 00139 void setQueueBundle(QueueBundle queueBundle); 00140 00141 /** 00142 * @brief Sets the priority of the Task 00143 * @param priority priority of the Task 00144 */ 00145 void setPriority(osPriority priority); 00146 00147 /** 00148 * @brief Sets the size of the Task 00149 * @param stackSize the stack size in Bytes 00150 */ 00151 void setStackSize(uint32_t stackSize); 00152 00153 /** 00154 * @brief Sets the stack pointer of for the task stack 00155 * @param stackPointer 00156 */ 00157 void setStackPointer(unsigned char* stackPointer); 00158 00159 00160 /** 00161 * @brief Sets the actual state of the Task. 00162 * @param taskState either RUNNING or SLEEPING 00163 */ 00164 void setState(TASK_STATE taskState); 00165 00166 }; 00167 00168 #endif /* TASKDATAHANDLER_H_ */
Generated on Wed Jul 13 2022 09:23:48 by 1.7.2