Pico GPS Teseo
Toggle main menu visibility
Loading...
Searching...
No Matches
teseo_reply_response.cpp
Go to the documentation of this file.
1
// https://www.st.com/resource/en/application_note/an5203-teseoliv3f--i2c-positioning-sensor--stmicroelectronics.pdf
2
3
#include <string>
4
// for std::find
5
#include <algorithm>
6
// for debug messages
7
#include <stdio.h>
8
#include "pico/stdlib.h"
9
10
import
teseo
;
11
import
port_pico_reset
;
12
import
port_pico_communicate
;
13
14
teseo::teseo
gps
;
15
std::string
reply
;
16
// for the container that will hold multy-line replies,
17
// you can use an array, vector, C array
18
// based on what your architecture prefers or requires.
19
// vector size is a suggestion. STL will allocate at least NMEA_MAX_REPLIES
20
//std::vector<std::string> replies(NMEA_MAX_REPLIES);
21
std::array<std::string, NMEA_MAX_REPLIES>
replies
;
22
23
void
setCallbacks
() {
24
gps
.writer().set([](
const
std::string& s) ->
void
{
write
(s); });
25
gps
.reader().set([](std::string& s) ->
void
{
read
(s); });
26
gps
.resetter().set([]() ->
void
{
port_pico::reset
(); });
27
}
28
29
int
main
() {
30
initialize
();
31
setCallbacks
();
32
33
/*
34
when the teseo is preset for i2c according to AN5203,
35
init is not required, and you can cut 4s 10ms from the startup sequence
36
https://www.st.com/resource/en/application_note/an5203-teseoliv3f--i2c-positioning-sensor--stmicroelectronics.pdf
37
*/
38
gps
.initialize();
39
40
uint
count
;
// intentionally uninitialised
41
bool
valid
;
// intentionally uninitialised
42
43
while
(
true
) {
44
printf(
"+-- start --+\r\n"
);
45
46
valid
=
gps
.ask_gll(
reply
);
47
printf(
"GLL valid: %s.\r\n"
,
valid
?
"yes"
:
"no"
);
48
printf(
reply
.c_str());
49
50
valid
=
gps
.ask_gsv(
replies
,
count
);
51
printf(
"GSV valid: %s. count: %u.\r\n"
,
valid
?
"yes"
:
"no"
,
count
);
52
std::for_each(
replies
.begin(),
replies
.begin() +
count
, [](
auto
&s) {
53
printf(s.c_str()); });
54
55
valid
=
gps
.ask_gsa(
replies
,
count
);
56
printf(
"GSA valid: %s. count: %u.\r\n"
,
valid
?
"yes"
:
"no"
,
count
);
57
std::for_each(
replies
.begin(),
replies
.begin() +
count
, [](
auto
&s) {
58
printf(s.c_str()); });
59
60
valid
=
gps
.ask_gga(
reply
);
61
printf(
"GGA valid: %s.\r\n"
,
valid
?
"yes"
:
"no"
);
62
printf(
reply
.c_str());
63
64
valid
=
gps
.ask_vtg(
reply
);
65
printf(
"VTG valid: %s.\r\n"
,
valid
?
"yes"
:
"no"
);
66
printf(
reply
.c_str());
67
68
valid
=
gps
.ask_rmc(
reply
);
69
printf(
"RMC valid: %s.\r\n"
,
valid
?
"yes"
:
"no"
);
70
printf(
reply
.c_str());
71
72
/* commented out because this is a slow command. It's here to show
73
how to call a custom multi line command.
74
Uncomment if you want to test this.
75
*/
76
// // example: execute a custom command that returns multiple lines
77
// printf("DUMPALMANAC command will take a while to reply.\r\n");
78
// teseo::nmea_rr almanac("$PSTMDUMPALMANAC\n\r", "$PSTMDUMPALMANAC");
79
// valid = gps.ask_nmea_multiple(almanac, replies, count);
80
// printf("DUMPALMANAC valid: %s. count: %u.\r\n", valid ? "yes" : "no", count);
81
// std::for_each(replies.begin(), replies.begin() + count, [](auto &s) {
82
// printf(s.c_str()); });
83
84
printf(
"+-- end --+\r\n\r\n"
);
85
sleep_ms(1000);
86
}
87
}
teseo::teseo
Driver class for ST Teseo IC.
Definition
teseo_iface.cpp:30
initialize
void initialize()
Definition
i2c/teseo_communicate.cpp:41
read
void read(::std::string &s)
Definition
i2c/teseo_communicate.cpp:59
write
void write(const ::std::string &s)
Definition
i2c/teseo_communicate.cpp:54
port_pico_communicate
port_pico_reset
teseo
port_pico::reset
void reset()
Definition
reset.cpp:17
valid
bool valid
Definition
teseo_nmea_with_data_processing.cpp:24
count
uint count
Definition
teseo_nmea_with_data_processing.cpp:22
gps
teseo::teseo gps
Definition
teseo_nmea_with_data_processing.cpp:15
replies
std::array< std::string, NMEA_MAX_REPLIES > replies
Definition
teseo_nmea_with_data_processing.cpp:21
reply
std::string reply
Definition
teseo_nmea_with_data_processing.cpp:23
setCallbacks
void setCallbacks()
Definition
teseo_reply_response.cpp:23
main
int main()
Definition
teseo_reply_response.cpp:29
Generated by
1.17.0