Skip to content

Commit 56fe532

Browse files
fix(modem): Update CMUX example with SIM7070_gnss cleaned-up
Merges #246
1 parent 5baaf54 commit 56fe532

File tree

3 files changed

+17
-44
lines changed

3 files changed

+17
-44
lines changed

components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ std::unique_ptr<DCE_gnss> create_SIM7070_GNSS_dce(const esp_modem::dce_config *c
4949
return gnss_factory::LocalFactory::create(config, std::move(dte), netif);
5050
}
5151

52-
esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::CommandableIf *t, esp_modem_gps_t &gps)
52+
esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::CommandableIf *t, sim70xx_gps_t &gps)
5353
{
5454

5555
ESP_LOGV(TAG, "%s", __func__ );
@@ -293,11 +293,11 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl
293293
{
294294
std::string_view sats_in_view = out.substr(0, pos);
295295
if (sats_in_view.length() > 1) {
296-
if (std::from_chars(out.data(), out.data() + pos, gps.sats_in_view).ec == std::errc::invalid_argument) {
296+
if (std::from_chars(out.data(), out.data() + pos, gps.sat.num).ec == std::errc::invalid_argument) {
297297
return esp_modem::command_result::FAIL;
298298
}
299299
} else {
300-
gps.sats_in_view = 0;
300+
gps.sat.num = 0;
301301
}
302302
} //clean up sats_in_view
303303

@@ -332,12 +332,12 @@ esp_modem::command_result get_gnss_information_sim70xx_lib(esp_modem::Commandabl
332332
return esp_modem::command_result::OK;
333333
}
334334

335-
esp_modem::command_result SIM7070_gnss::get_gnss_information_sim70xx(esp_modem_gps_t &gps)
335+
esp_modem::command_result SIM7070_gnss::get_gnss_information_sim70xx(sim70xx_gps_t &gps)
336336
{
337337
return get_gnss_information_sim70xx_lib(dte.get(), gps);
338338
}
339339

340-
esp_modem::command_result DCE_gnss::get_gnss_information_sim70xx(esp_modem_gps_t &gps)
340+
esp_modem::command_result DCE_gnss::get_gnss_information_sim70xx(sim70xx_gps_t &gps)
341341
{
342342
return device->get_gnss_information_sim70xx(gps);
343343
}

components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/SIM7070_gnss.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "cxx_include/esp_modem_dce_factory.hpp"
1515
#include "cxx_include/esp_modem_dce_module.hpp"
16-
#include "nmea_parser.h"
16+
#include "sim70xx_gps.h"
1717

1818
/**
1919
* @brief Definition of a custom SIM7070 class with GNSS capabilities.
@@ -23,7 +23,7 @@
2323
class SIM7070_gnss: public esp_modem::SIM7070 {
2424
using SIM7070::SIM7070;
2525
public:
26-
esp_modem::command_result get_gnss_information_sim70xx(esp_modem_gps_t &gps);
26+
esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps);
2727
};
2828

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

4848
#undef ESP_MODEM_DECLARE_DCE_COMMAND
4949

50-
esp_modem::command_result get_gnss_information_sim70xx(esp_modem_gps_t &gps);
50+
esp_modem::command_result get_gnss_information_sim70xx(sim70xx_gps_t &gps);
5151

5252
};
5353

components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/nmea_parser.h renamed to components/esp_modem/examples/simple_cmux_client/components/SIM7070_gnss/sim70xx_gps.h

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extern "C" {
1717
#define GPS_MAX_SATELLITES_IN_VIEW (16)
1818

1919

20-
2120
/**
2221
* @brief GPS fix type
2322
*
@@ -53,9 +52,6 @@ typedef enum {
5352
*/
5453
typedef struct {
5554
uint8_t num; /*!< Satellite number */
56-
uint8_t elevation; /*!< Satellite elevation */
57-
uint16_t azimuth; /*!< Satellite azimuth */
58-
uint8_t snr; /*!< Satellite signal noise ratio */
5955
} gps_satellite_t;
6056

6157
/**
@@ -79,54 +75,31 @@ typedef struct {
7975
uint16_t year; /*!< Year (start from 2000) */
8076
} gps_date_t;
8177

82-
/**
83-
* @brief NMEA Statement
84-
*
85-
*/
86-
typedef enum {
87-
STATEMENT_UNKNOWN = 0, /*!< Unknown statement */
88-
STATEMENT_GGA, /*!< GGA */
89-
STATEMENT_GSA, /*!< GSA */
90-
STATEMENT_RMC, /*!< RMC */
91-
STATEMENT_GSV, /*!< GSV */
92-
STATEMENT_GLL, /*!< GLL */
93-
STATEMENT_VTG /*!< VTG */
94-
} nmea_statement_t;
95-
9678
/**
9779
* @brief GPS object
9880
*
9981
*/
100-
struct esp_modem_gps {
101-
float latitude; /*!< Latitude (degrees) */
102-
float longitude; /*!< Longitude (degrees) */
103-
float altitude; /*!< Altitude (meters) */
82+
struct sim70xx_gps {
10483
gps_run_t run; /*!< run status */
10584
gps_fix_t fix; /*!< Fix status */
106-
uint8_t sats_in_use; /*!< Number of satellites in use */
85+
gps_date_t date; /*!< Fix date */
10786
gps_time_t tim; /*!< time in UTC */
87+
float latitude; /*!< Latitude (degrees) */
88+
float longitude; /*!< Longitude (degrees) */
89+
float altitude; /*!< Altitude (meters) */
90+
float speed; /*!< Ground speed, unit: m/s */
91+
float cog; /*!< Course over ground */
10892
gps_fix_mode_t fix_mode; /*!< Fix mode */
10993
float dop_h; /*!< Horizontal dilution of precision */
11094
float dop_p; /*!< Position dilution of precision */
11195
float dop_v; /*!< Vertical dilution of precision */
112-
uint8_t sats_in_view; /*!< Number of satellites in view */
113-
gps_date_t date; /*!< Fix date */
114-
float speed; /*!< Ground speed, unit: m/s */
115-
float cog; /*!< Course over ground */
96+
gps_satellite_t sat; /*!< Number of satellites in view */
11697
float hpa; /*!< Horizontal Position Accuracy */
11798
float vpa; /*!< Vertical Position Accuracy */
11899
};
119100

120-
typedef struct esp_modem_gps esp_modem_gps_t;
101+
typedef struct sim70xx_gps sim70xx_gps_t;
121102

122-
/**
123-
* @brief NMEA Parser Event ID
124-
*
125-
*/
126-
typedef enum {
127-
GPS_UPDATE, /*!< GPS information has been updated */
128-
GPS_UNKNOWN /*!< Unknown statements detected */
129-
} nmea_event_id_t;
130103

131104
#ifdef __cplusplus
132105
}

0 commit comments

Comments
 (0)