gnss
Diff: gnss.h
- Revision:
- 8:720841961804
- Parent:
- 6:56eda66d585b
- Child:
- 9:cff83b9f5093
--- a/gnss.h Wed Jun 14 20:44:42 2017 +0100 +++ b/gnss.h Wed May 16 10:58:16 2018 +0500 @@ -39,6 +39,56 @@ # define GNSSBAUD GPSBAUD #endif +#define UBX_FRAME_SIZE 8 +#define RETRY 5 +#define SYNC_CHAR_INDEX_1 0 +#define SYNC_CHAR_INDEX_2 1 +#define MSG_CLASS_INDEX 2 +#define MSG_ID_INDEX 3 +#define UBX_LENGTH_INDEX 4 +#define UBX_PAYLOAD_INDEX 6 + +enum eUBX_MSG_CLASS {NAV = 0x01, ACK = 0x05, LOG = 0x21}; + +enum eUBX_MESSAGE {UBX_LOG_BATCH, UBX_ACK_ACK, UBX_ACK_NAK, UBX_NAV_ODO, UBX_NAV_PVT, UNKNOWN_UBX}; + +typedef struct UBX_CFG_ACK { + uint8_t msg_class; + uint8_t msg_id; + +}tUBX_CFG_ACK; + +typedef struct UBX_NAV_ODO { + uint8_t version; + uint8_t reserved[3]; + uint32_t itow; + uint32_t distance; + uint32_t totalDistance; + uint32_t distanceSTD; +}tUBX_NAV_ODO; + +typedef struct UBX_NAV_PVT { + uint32_t itow; + uint16_t year; + uint8_t month; + uint8_t day; + int32_t lon; // scaling 1e-7 + int32_t lat; // scaling 1e-7 + int32_t height; + +}tUBX_NAV_PVT; + +typedef struct UBX_LOG_BATCH { + uint32_t itow; + int32_t lon; // scaling 1e-7 + int32_t lat; // scaling 1e-7 + int32_t height; + uint32_t distance; + uint32_t totalDistance; + uint32_t distanceSTD; + +}tUBX_LOG_BATCH; + /** Basic GNSS parser class. */ class GnssParser @@ -153,7 +203,43 @@ * @return true if successful, false otherwise. */ static bool getNmeaAngle(int ix, char* buf, int len, double& val); + + /** Enable UBX messages. + * @param none + * @return 0 if successful, false otherwise. + */ + int enable_ubx(); + /** GET Message type of receiver UBX message + * @param buff the UXB message + * @return eUBX_MESSAGE + */ + eUBX_MESSAGE get_ubx_message(char *); + + /** Method to parse contents of UBX CFG-ACK/NAK and return messageid amd class for which ACK is received + * @param buff the UXB message + * @return tUBX_CFG_ACK + */ + tUBX_CFG_ACK decode_ubx_cfg_ack_nak_msg(char *); + + /** Method to parse contents of UBX_NAV_ODO and return decoded msg + * @param buff the UXB message + * @return tUBX_NAV_ODO + */ + tUBX_NAV_ODO decode_ubx_nav_odo_msg(char *); + + /** Method to parse contents of UBX_NAV_PVT and return decoded msg + * @param buff the UXB message + * @return tUBX_NAV_PVT + */ + tUBX_NAV_PVT decode_ubx_nav_pvt_msg(char *); + + /** Method to parse contents of UBX_LOG_BATCH and return decoded msg + * @param buff the UXB message + * @return tUBX_LOG_BATCH + */ + tUBX_LOG_BATCH decode_ubx_log_batch_msg(char *); + protected: /** Power on the GNSS module. */