lora sensnode

Dependencies:   libmDot mbed-rtos mbed

Fork of mDot_LoRa_Sensornode by Adrian Mitevski

Committer:
socie123
Date:
Wed Aug 10 12:54:10 2016 +0000
Revision:
1:e67174cc4953
Parent:
0:f2815503561f
lora sensnode

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mitea1 0:f2815503561f 1 /**
mitea1 0:f2815503561f 2 * @file TaskGPS.h
mitea1 0:f2815503561f 3 *
mitea1 0:f2815503561f 4 * @author Adrian
mitea1 0:f2815503561f 5 * @date 30.05.2016
mitea1 0:f2815503561f 6 *
mitea1 0:f2815503561f 7 */
mitea1 0:f2815503561f 8 #include "uBlox.h"
mitea1 0:f2815503561f 9 #include "UBloxGPSMessage.h"
mitea1 0:f2815503561f 10 #include "main.h"
mitea1 0:f2815503561f 11
mitea1 0:f2815503561f 12 #ifndef TASKGPS_H_
mitea1 0:f2815503561f 13 #define TASKGPS_H_
mitea1 0:f2815503561f 14
mitea1 0:f2815503561f 15 /**
mitea1 0:f2815503561f 16 * @class TaskGPS
mitea1 0:f2815503561f 17 * @brief This TaskGPS Class handles the GPS measurement using the uBlox.
mitea1 0:f2815503561f 18 * Starting the task using the start() starts the measurement.
mitea1 0:f2815503561f 19 * It can be used alongside with other measurement Tasks inside the mbed::rtos
mitea1 0:f2815503561f 20 * environment. The Task Class basically wraps mbeds Thread functionality.
mitea1 0:f2815503561f 21 */
mitea1 0:f2815503561f 22 class TaskGPS {
mitea1 0:f2815503561f 23 public:
mitea1 0:f2815503561f 24 TaskGPS(uBlox*,Mutex*, Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>*);
mitea1 0:f2815503561f 25 TaskGPS(uBlox*,Mutex*,Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>*,
mitea1 0:f2815503561f 26 osPriority, uint32_t, unsigned char*);
mitea1 0:f2815503561f 27 virtual ~TaskGPS();
mitea1 0:f2815503561f 28
mitea1 0:f2815503561f 29
mitea1 0:f2815503561f 30 /**
mitea1 0:f2815503561f 31 * Starts the task by building and its measurement
mitea1 0:f2815503561f 32 * @return
mitea1 0:f2815503561f 33 */
mitea1 0:f2815503561f 34 osStatus start();
mitea1 0:f2815503561f 35
mitea1 0:f2815503561f 36 /**
mitea1 0:f2815503561f 37 * Stops the task. Should only be used after start() was used
mitea1 0:f2815503561f 38 * @return
mitea1 0:f2815503561f 39 */
mitea1 0:f2815503561f 40 osStatus stop();
mitea1 0:f2815503561f 41
mitea1 0:f2815503561f 42
mitea1 0:f2815503561f 43 /**
mitea1 0:f2815503561f 44 * Gets the actual state of the Task either RUNNING or SLEEPING
mitea1 0:f2815503561f 45 * @return
mitea1 0:f2815503561f 46 */
mitea1 0:f2815503561f 47 TASK_STATE getState();
mitea1 0:f2815503561f 48
mitea1 0:f2815503561f 49 private:
mitea1 0:f2815503561f 50 rtos::Thread* thread;
mitea1 0:f2815503561f 51 rtos::Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queue;
mitea1 0:f2815503561f 52 rtos::Mutex* mutexUART ;
mitea1 0:f2815503561f 53 osPriority priority ;
mitea1 0:f2815503561f 54 uint32_t stack_size;
mitea1 0:f2815503561f 55 unsigned char *stack_pointer;
mitea1 0:f2815503561f 56
mitea1 0:f2815503561f 57 TASK_STATE state;
mitea1 0:f2815503561f 58
mitea1 0:f2815503561f 59 uBlox* mUBlox;
mitea1 0:f2815503561f 60 uBLOX_MODE uBloxMode;
mitea1 0:f2815503561f 61
mitea1 0:f2815503561f 62
mitea1 0:f2815503561f 63 /**
mitea1 0:f2815503561f 64 * @brief A Callback function thats called by the mbed::Thread of this TaskClass
mitea1 0:f2815503561f 65 * @param
mitea1 0:f2815503561f 66 */
mitea1 0:f2815503561f 67 static void callBack(void const *);
mitea1 0:f2815503561f 68
mitea1 0:f2815503561f 69 /**
mitea1 0:f2815503561f 70 * @brief A thread safe method that acquires GPS values. After acquiring GPS Data
mitea1 0:f2815503561f 71 * it stores the data inside a uBLoxGPSMessage
mitea1 0:f2815503561f 72 */
mitea1 0:f2815503561f 73 void measureGps();
mitea1 0:f2815503561f 74
mitea1 0:f2815503561f 75
mitea1 0:f2815503561f 76 /**
mitea1 0:f2815503561f 77 * @brief Sets the message Queue of the Task where the acquired data will be stored
mitea1 0:f2815503561f 78 * after the acquisition
mitea1 0:f2815503561f 79 * @param queueGps the queue where the MPU9250AccelerationMessage will be stored
mitea1 0:f2815503561f 80 */
mitea1 0:f2815503561f 81 void setQueue(Queue<UBloxGPSMessage,GPS_QUEUE_LENGHT>* queueGps);
mitea1 0:f2815503561f 82
mitea1 0:f2815503561f 83 /**
mitea1 0:f2815503561f 84 * @brief Sets the mutex thats used for a thread safe acquisition
mitea1 0:f2815503561f 85 * @param mutexI2C the I2C mutex
mitea1 0:f2815503561f 86 */
mitea1 0:f2815503561f 87 void setMutex(Mutex* mutexI2C);
mitea1 0:f2815503561f 88
mitea1 0:f2815503561f 89 /**
mitea1 0:f2815503561f 90 * @brief Sets the priority of the Task
mitea1 0:f2815503561f 91 * @param priority priority of the Task
mitea1 0:f2815503561f 92 */
mitea1 0:f2815503561f 93 void setPriority(osPriority priority);
mitea1 0:f2815503561f 94
mitea1 0:f2815503561f 95 /**
mitea1 0:f2815503561f 96 * @brief Sets the size of the Task
mitea1 0:f2815503561f 97 * @param stackSize the stack size in Bytes
mitea1 0:f2815503561f 98 */
mitea1 0:f2815503561f 99 void setStackSize(uint32_t stackSize);
mitea1 0:f2815503561f 100
mitea1 0:f2815503561f 101 /**
mitea1 0:f2815503561f 102 * @brief Sets the stack pointer of for the task stack
mitea1 0:f2815503561f 103 * @param stackPointer
mitea1 0:f2815503561f 104 */
mitea1 0:f2815503561f 105 void setStackPointer(unsigned char* stackPointer);
mitea1 0:f2815503561f 106
mitea1 0:f2815503561f 107
mitea1 0:f2815503561f 108 /**
mitea1 0:f2815503561f 109 * @brief Sets the actual state of the Task
mitea1 0:f2815503561f 110 * @param taskState either RUNNING or SLEEPING
mitea1 0:f2815503561f 111 */
mitea1 0:f2815503561f 112 void setState(TASK_STATE taskState);
mitea1 0:f2815503561f 113 };
mitea1 0:f2815503561f 114
mitea1 0:f2815503561f 115 #endif /* TASKGPS_H_ */