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