From 56fe53279e9ea53f92e04bbfb253888130690dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20H=C3=B6pfinger?= Date: Thu, 9 Mar 2023 16:47:36 +0100 Subject: [PATCH] fix(modem): Update CMUX example with SIM7070_gnss cleaned-up Merges https://github.com/espressif/esp-protocols/pull/246 --- .../components/SIM7070_gnss/SIM7070_gnss.cpp | 10 ++--- .../components/SIM7070_gnss/SIM7070_gnss.hpp | 6 +-- .../{nmea_parser.h => sim70xx_gps.h} | 45 ++++--------------- 3 files changed, 17 insertions(+), 44 deletions(-) rename components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/{nmea_parser.h => sim70xx_gps.h} (76%) diff --git a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.cpp b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.cpp index 962d8d69a..981b3ce44 100644 --- a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.cpp +++ b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.cpp @@ -49,7 +49,7 @@ std::unique_ptr create_SIM7070_GNSS_dce(const esp_modem::dce_config *c return gnss_factory::LocalFactory::create(config, std::move(dte), netif); } -esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::CommandableIf *t, esp_modem_gps_t &gps) +esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::CommandableIf *t, sim70xx_gps_t &gps) { ESP_LOGV(TAG, "%s", __func__ ); @@ -293,11 +293,11 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl { std::string_view sats_in_view = out.substr(0, pos); if (sats_in_view.length() > 1) { - if (std::from_chars(out.data(), out.data() + pos, gps.sats_in_view).ec == std::errc::invalid_argument) { + if (std::from_chars(out.data(), out.data() + pos, gps.sat.num).ec == std::errc::invalid_argument) { return esp_modem::command_result::FAIL; } } else { - gps.sats_in_view = 0; + gps.sat.num = 0; } } //clean up sats_in_view @@ -332,12 +332,12 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl return esp_modem::command_result::OK; } -esp_modem::command_result SIM7070_gnss::get_gnss_information_sim70xx(esp_modem_gps_t &gps) +esp_modem::command_result SIM7070_gnss::get_gnss_information_sim70xx(sim70xx_gps_t &gps) { return get_gnss_information_sim70xx_lib(dte.get(), gps); } -esp_modem::command_result DCE_gnss::get_gnss_information_sim70xx(esp_modem_gps_t &gps) +esp_modem::command_result DCE_gnss::get_gnss_information_sim70xx(sim70xx_gps_t &gps) { return device->get_gnss_information_sim70xx(gps); } diff --git a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.hpp b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.hpp index 8ca99dc0d..345269ba8 100644 --- a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.hpp +++ b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.hpp @@ -13,7 +13,7 @@ #include "cxx_include/esp_modem_dce_factory.hpp" #include "cxx_include/esp_modem_dce_module.hpp" -#include "nmea_parser.h" +#include "sim70xx_gps.h" /** * @brief Definition of a custom SIM7070 class with GNSS capabilities. @@ -23,7 +23,7 @@ class SIM7070_gnss: public esp_modem::SIM7070 { using SIM7070::SIM7070; public: - esp_modem::command_result get_gnss_information_sim70xx(esp_modem_gps_t &gps); + esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps); }; /** @@ -47,7 +47,7 @@ public: #undef ESP_MODEM_DECLARE_DCE_COMMAND - esp_modem::command_result get_gnss_information_sim70xx(esp_modem_gps_t &gps); + esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps); }; diff --git a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/nmea_parser.h b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/sim70xx_gps.h similarity index 76% rename from components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/nmea_parser.h rename to components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/sim70xx_gps.h index a0c59a714..6e905e558 100644 --- a/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/nmea_parser.h +++ b/components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/sim70xx_gps.h @@ -17,7 +17,6 @@ extern "C" { #define GPS_MAX_SATELLITES_IN_VIEW (16) - /** * @brief GPS fix type * @@ -53,9 +52,6 @@ typedef enum { */ typedef struct { uint8_t num; /*!< Satellite number */ - uint8_t elevation; /*!< Satellite elevation */ - uint16_t azimuth; /*!< Satellite azimuth */ - uint8_t snr; /*!< Satellite signal noise ratio */ } gps_satellite_t; /** @@ -79,54 +75,31 @@ typedef struct { uint16_t year; /*!< Year (start from 2000) */ } gps_date_t; -/** - * @brief NMEA Statement - * - */ -typedef enum { - STATEMENT_UNKNOWN = 0, /*!< Unknown statement */ - STATEMENT_GGA, /*!< GGA */ - STATEMENT_GSA, /*!< GSA */ - STATEMENT_RMC, /*!< RMC */ - STATEMENT_GSV, /*!< GSV */ - STATEMENT_GLL, /*!< GLL */ - STATEMENT_VTG /*!< VTG */ -} nmea_statement_t; - /** * @brief GPS object * */ -struct esp_modem_gps { +struct sim70xx_gps { + gps_run_t run; /*!< run status */ + gps_fix_t fix; /*!< Fix status */ + gps_date_t date; /*!< Fix date */ + gps_time_t tim; /*!< time in UTC */ float latitude; /*!< Latitude (degrees) */ float longitude; /*!< Longitude (degrees) */ float altitude; /*!< Altitude (meters) */ - gps_run_t run; /*!< run status */ - gps_fix_t fix; /*!< Fix status */ - uint8_t sats_in_use; /*!< Number of satellites in use */ - gps_time_t tim; /*!< time in UTC */ + float speed; /*!< Ground speed, unit: m/s */ + float cog; /*!< Course over ground */ gps_fix_mode_t fix_mode; /*!< Fix mode */ float dop_h; /*!< Horizontal dilution of precision */ float dop_p; /*!< Position dilution of precision */ float dop_v; /*!< Vertical dilution of precision */ - uint8_t sats_in_view; /*!< Number of satellites in view */ - gps_date_t date; /*!< Fix date */ - float speed; /*!< Ground speed, unit: m/s */ - float cog; /*!< Course over ground */ + gps_satellite_t sat; /*!< Number of satellites in view */ float hpa; /*!< Horizontal Position Accuracy */ float vpa; /*!< Vertical Position Accuracy */ }; -typedef struct esp_modem_gps esp_modem_gps_t; +typedef struct sim70xx_gps sim70xx_gps_t; -/** - * @brief NMEA Parser Event ID - * - */ -typedef enum { - GPS_UPDATE, /*!< GPS information has been updated */ - GPS_UNKNOWN /*!< Unknown statements detected */ -} nmea_event_id_t; #ifdef __cplusplus }