Skip to content

Commit

Permalink
fix(modem): Update CMUX example with SIM7070_gnss cleaned-up
Browse files Browse the repository at this point in the history
Merges #246
  • Loading branch information
krone-trailer-franzhoepfinger authored and david-cermak committed Mar 18, 2024
1 parent 9ff32c3 commit faccafe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ std::unique_ptr<DCE_gnss> 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__ );
Expand Down Expand Up @@ -293,7 +293,7 @@ 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 {
Expand Down Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
};

/**
Expand All @@ -47,7 +47,7 @@ class DCE_gnss : public esp_modem::DCE_T<SIM7070_gnss> {

#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);

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ extern "C" {
#define GPS_MAX_SATELLITES_IN_VIEW (16)



/**
* @brief GPS fix type
*
Expand Down Expand Up @@ -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;

/**
Expand All @@ -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 {
float latitude; /*!< Latitude (degrees) */
float longitude; /*!< Longitude (degrees) */
float altitude; /*!< Altitude (meters) */
struct sim70xx_gps {
gps_run_t run; /*!< run status */
gps_fix_t fix; /*!< Fix status */
uint8_t sats_in_use; /*!< Number of satellites in use */
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) */
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
}
Expand Down

0 comments on commit faccafe

Please sign in to comment.