| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #ifndef GPS_PARSER_H
- #define GPS_PARSER_H
- #include <stdint.h>
- #include <stdbool.h>
- #include <esp_timer.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define GPS_PARSER_MAX_FIELD_SIZE 15
- #define GPS_PARSER_MPH_PER_KNOT 1.15077945
- #define GPS_PARSER_MPS_PER_KNOT 0.51444444
- #define GPS_PARSER_KMPH_PER_KNOT 1.852
- #define GPS_PARSER_MILES_PER_METER 0.00062137112
- #define GPS_PARSER_KM_PER_METER 0.001
- #define GPS_PARSER_FEET_PER_METER 3.2808399
- #define GPS_PARSER_EARTH_MEAN_RADIUS 6371009
- static inline uint32_t gps_parser_millis(void)
- {
- return (uint32_t)(esp_timer_get_time() / 1000ULL);
- }
- typedef struct {
- uint16_t deg;
- uint32_t billionths;
- bool negative;
- } gps_raw_degrees_t;
- typedef struct {
- bool valid;
- bool updated;
- gps_raw_degrees_t rawLatData;
- gps_raw_degrees_t rawLngData;
- gps_raw_degrees_t rawNewLatData;
- gps_raw_degrees_t rawNewLngData;
- char fixQuality;
- char newFixQuality;
- char fixMode;
- char newFixMode;
- uint32_t lastCommitTime;
- } gps_location_t;
- typedef struct {
- bool valid;
- bool updated;
- uint32_t date;
- uint32_t newDate;
- uint32_t lastCommitTime;
- } gps_date_t;
- typedef struct {
- bool valid;
- bool updated;
- uint32_t time;
- uint32_t newTime;
- uint32_t lastCommitTime;
- } gps_time_t;
- typedef struct {
- bool valid;
- bool updated;
- uint32_t lastCommitTime;
- int32_t val;
- int32_t newval;
- } gps_decimal_t;
- typedef struct {
- bool valid;
- bool updated;
- uint32_t lastCommitTime;
- uint32_t val;
- uint32_t newval;
- } gps_integer_t;
- typedef struct {
- uint8_t parity;
- bool isChecksumTerm;
- char term[GPS_PARSER_MAX_FIELD_SIZE + 1];
- uint8_t curSentenceType;
- uint8_t curTermNumber;
- uint8_t curTermOffset;
- bool sentenceHasFix;
- gps_location_t location;
- gps_date_t date;
- gps_time_t time;
- gps_decimal_t speed;
- gps_decimal_t course;
- gps_decimal_t altitude;
- gps_integer_t satellites;
- gps_decimal_t hdop;
- uint32_t encodedCharCount;
- uint32_t sentencesWithFixCount;
- uint32_t failedChecksumCount;
- uint32_t passedChecksumCount;
- } gps_parser_t;
- void gps_parser_init(gps_parser_t *gps);
- bool gps_parser_encode(gps_parser_t *gps, char c);
- bool gps_location_is_valid(const gps_location_t *location);
- bool gps_location_is_updated(const gps_location_t *location);
- uint32_t gps_location_age(const gps_location_t *location);
- double gps_location_lat(const gps_location_t *location);
- double gps_location_lng(const gps_location_t *location);
- char gps_location_fix_quality(const gps_location_t *location);
- char gps_location_fix_mode(const gps_location_t *location);
- bool gps_date_is_valid(const gps_date_t *date);
- uint16_t gps_date_year(const gps_date_t *date);
- uint8_t gps_date_month(const gps_date_t *date);
- uint8_t gps_date_day(const gps_date_t *date);
- bool gps_time_is_valid(const gps_time_t *time);
- uint8_t gps_time_hour(const gps_time_t *time);
- uint8_t gps_time_minute(const gps_time_t *time);
- uint8_t gps_time_second(const gps_time_t *time);
- uint8_t gps_time_centisecond(const gps_time_t *time);
- bool gps_decimal_is_valid(const gps_decimal_t *value);
- int32_t gps_decimal_value(const gps_decimal_t *value);
- gps_integer_t *gps_get_satellites(gps_parser_t *gps);
- uint32_t gps_parser_chars_processed(const gps_parser_t *gps);
- uint32_t gps_parser_sentences_with_fix(const gps_parser_t *gps);
- uint32_t gps_parser_failed_checksum(const gps_parser_t *gps);
- uint32_t gps_parser_passed_checksum(const gps_parser_t *gps);
- #ifdef __cplusplus
- }
- #endif
- #endif // GPS_PARSER_H
|