SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
Decoder.h
00001 /** 00002 * @file Decoder.h 00003 * 00004 * @author Adrian 00005 * @date 16.05.2016 00006 */ 00007 00008 #ifndef APP_DECODER_H_ 00009 #define APP_DECODER_H_ 00010 00011 #include <RawSerial.h> 00012 00013 #define HEADER_LENGHT 2 00014 #define ID_LENGHT 2 00015 #define LENGHT_LENGHT 2 00016 #define PAYLOAD_LENGHT 28 00017 #define CRC_LENGHT 2 00018 #define MESSAGE_LENGHT (HEADER_LENGHT+ID_LENGHT+LENGHT_LENGHT+PAYLOAD_LENGHT+CRC_LENGHT) 00019 00020 /** 00021 * States in which the Decoder can be 00022 */ 00023 enum DecoderState{ 00024 INIT = 0,//!< INIT 00025 RECEIVE, //!< RECEIVE 00026 DECODE, //!< DECODE 00027 }; 00028 00029 /** 00030 * Container that can hold GPS Information 00031 */ 00032 typedef struct POSLHH{ 00033 unsigned long iTOW; 00034 long lon; 00035 long lat; 00036 long height; 00037 long hMSL; 00038 unsigned long hAcc; 00039 unsigned long vAcc; 00040 }POSLHH; 00041 00042 /** 00043 * @class Decoder 00044 * @brief This Class is used to decode the byte stream thats sent from the uBlox. At the moment 00045 * it only decodes the NAV-POLLSH byte stream. For correct usage all other messages of the uBlox 00046 * needs to be deactivated or at least the NAV-POLLSH needs to be activated 00047 */ 00048 class Decoder { 00049 public: 00050 Decoder(mbed::RawSerial*); 00051 virtual ~Decoder(); 00052 00053 /** 00054 * @brief Gets the actual State in which the decoder is 00055 * @return 00056 */ 00057 DecoderState getActualState(); 00058 00059 /** 00060 * @brief Gets the receive Buffer in which all received Bytes from the NAV-POLLSH are 00061 * stored 00062 * @return 00063 */ 00064 char* getReceiveBuffer(); 00065 00066 /** 00067 * @brief Gets the last successfully decoded NAV-POLLSH Bytestream 00068 * @return 00069 */ 00070 POSLHH getLastPoslhh(); 00071 00072 private: 00073 DecoderState actualState; 00074 mbed::RawSerial* serial; 00075 char lastReceivedChar; 00076 POSLHH lastPoslhh; 00077 char receiveBuffer[MESSAGE_LENGHT]; 00078 int bufferPosition; 00079 00080 /** 00081 * @brief Sets the actual State of the Decoder 00082 * @param actualState 00083 */ 00084 void setActualState(DecoderState actualState); 00085 00086 /** 00087 * @brief Gets the latest character from the serial internal buffer 00088 */ 00089 void getCharacterFromSerial(); 00090 00091 /** 00092 * @brief Checks if the specific Char was the last received Char 00093 * @param specificChar 00094 * @return 00095 */ 00096 bool hasReceived(char specificChar); 00097 00098 /** 00099 * @brief Buffers the last received Char at the beginning of the buffer 00100 */ 00101 void bufferReceivedCharacterAtBegin(); 00102 00103 /** 00104 * @brief Buffers the last received char at the actual position of the buffer 00105 */ 00106 void bufferReceivedCharacter(); 00107 00108 /** 00109 * @brief Checks if the whole buffer is filled up 00110 * @return 00111 */ 00112 bool isBufferFilled(); 00113 00114 /** 00115 * @brief The Decoding routing thats called when some Data is recieved via the serial 00116 */ 00117 void rxInterrupt(); 00118 00119 /** 00120 * @brief Sets the position where the next Byte should be stored inside the buffer 00121 * @param desiredPosition 00122 */ 00123 void setBufferPosition(uint8_t desiredPosition); 00124 00125 /** 00126 * @brief Increments the position where the next Byte should be stored by 1 00127 */ 00128 void incrementBufferPosition(); 00129 00130 /** 00131 * @brief Clears the whole buffer 00132 */ 00133 void clearReceiveBuffer(); 00134 00135 /** 00136 * @brief Decodes the whole buffer 00137 */ 00138 void decodeReceiveBuffer(); 00139 }; 00140 00141 #endif /* APP_DECODER_H_ */
Generated on Wed Jul 13 2022 09:23:47 by 1.7.2