From 1639fe5414c849ab6025e521dfe039fb76f240c8 Mon Sep 17 00:00:00 2001 From: Maxmillion McLaughlin Date: Sat, 25 Jan 2025 00:38:37 -0800 Subject: [PATCH] drivers: gnss: Add geoid separation to gnss_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently altitude is only provided above MSL. Adding geoid seperation allows for ellipsoidal height to be determined. Signed-off-by: Maxmillion McLaughlin --- drivers/gnss/gnss_nmea0183.c | 10 ++++++++++ include/zephyr/data/navigation.h | 2 +- include/zephyr/drivers/gnss.h | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gnss/gnss_nmea0183.c b/drivers/gnss/gnss_nmea0183.c index 515606fbefe5..bbeb50a5c7de 100644 --- a/drivers/gnss/gnss_nmea0183.c +++ b/drivers/gnss/gnss_nmea0183.c @@ -545,6 +545,16 @@ int gnss_nmea0183_parse_gga(const char **argv, uint16_t argc, struct gnss_data * } data->nav_data.altitude = (int32_t)tmp64; + + /* Parse geoid separation */ + if ((gnss_parse_dec_to_milli(argv[11], &tmp64) < 0) || + (tmp64 > INT32_MAX) || + (tmp64 < INT32_MIN)) { + return -EINVAL; + } + + data->info.geoid_separation = (int32_t)tmp64; + return 0; } diff --git a/include/zephyr/data/navigation.h b/include/zephyr/data/navigation.h index 0759df984ea4..a09152809421 100644 --- a/include/zephyr/data/navigation.h +++ b/include/zephyr/data/navigation.h @@ -31,7 +31,7 @@ struct navigation_data { uint32_t bearing; /** Speed in millimeters per second */ uint32_t speed; - /** Altitude in millimeters */ + /** Altitude above MSL in millimeters */ int32_t altitude; }; diff --git a/include/zephyr/drivers/gnss.h b/include/zephyr/drivers/gnss.h index c5d2b9174cc4..3a0ba8ba1b65 100644 --- a/include/zephyr/drivers/gnss.h +++ b/include/zephyr/drivers/gnss.h @@ -140,6 +140,8 @@ struct gnss_info { uint16_t satellites_cnt; /** Horizontal dilution of precision in 1/1000 */ uint32_t hdop; + /** Geoid separation in millimeters */ + int32_t geoid_separation; /** The fix status */ enum gnss_fix_status fix_status; /** The fix quality */