Skip to content

Commit 7395c25

Browse files
committedFeb 6, 2022
Update AssistNow Autonomous examples to use callback pointers
1 parent fae14c1 commit 7395c25

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
 

‎examples/AssistNow/AssistNow_Autonomous/Example1_AssistNowAutonomous/Example1_AssistNowAutonomous.ino

+15-15
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ SFE_UBLOX_GNSS myGNSS;
4242
// | / _____ You can use any name you like for the struct
4343
// | | /
4444
// | | |
45-
void printSATdata(UBX_NAV_SAT_data_t ubxDataStruct)
45+
void printSATdata(UBX_NAV_SAT_data_t *ubxDataStruct)
4646
{
4747
//Serial.println();
4848

4949
Serial.print(F("UBX-NAV-SAT contains data for "));
50-
Serial.print(ubxDataStruct.header.numSvs);
51-
if (ubxDataStruct.header.numSvs == 1)
50+
Serial.print(ubxDataStruct->header.numSvs);
51+
if (ubxDataStruct->header.numSvs == 1)
5252
Serial.println(F(" SV"));
5353
else
5454
Serial.println(F(" SVs"));
5555

5656
uint16_t numAopAvail = 0; // Count how many SVs have AssistNow Autonomous data available
5757

58-
for (uint16_t block = 0; block < ubxDataStruct.header.numSvs; block++) // For each SV
58+
for (uint16_t block = 0; block < ubxDataStruct->header.numSvs; block++) // For each SV
5959
{
60-
if (ubxDataStruct.blocks[block].flags.bits.aopAvail == 1) // If the aopAvail bit is set
60+
if (ubxDataStruct->blocks[block].flags.bits.aopAvail == 1) // If the aopAvail bit is set
6161
numAopAvail++; // Increment the number of SVs
6262
}
6363

@@ -78,12 +78,12 @@ void printSATdata(UBX_NAV_SAT_data_t ubxDataStruct)
7878
// | / _____ You can use any name you like for the struct
7979
// | | /
8080
// | | |
81-
void printAOPstatus(UBX_NAV_AOPSTATUS_data_t ubxDataStruct)
81+
void printAOPstatus(UBX_NAV_AOPSTATUS_data_t *ubxDataStruct)
8282
{
8383
//Serial.println();
8484

8585
Serial.print(F("AOPSTATUS status is "));
86-
Serial.println(ubxDataStruct.status);
86+
Serial.println(ubxDataStruct->status);
8787
}
8888

8989
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -95,27 +95,27 @@ void printAOPstatus(UBX_NAV_AOPSTATUS_data_t ubxDataStruct)
9595
// | / _____ You can use any name you like for the struct
9696
// | | /
9797
// | | |
98-
void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct)
98+
void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct)
9999
{
100100
// Print the UBX-NAV-PVT data so we can see how quickly the fixType goes to 3D
101101

102102
Serial.println();
103103

104-
long latitude = ubxDataStruct.lat; // Print the latitude
104+
long latitude = ubxDataStruct->lat; // Print the latitude
105105
Serial.print(F("Lat: "));
106106
Serial.print(latitude);
107107

108-
long longitude = ubxDataStruct.lon; // Print the longitude
108+
long longitude = ubxDataStruct->lon; // Print the longitude
109109
Serial.print(F(" Long: "));
110110
Serial.print(longitude);
111111
Serial.print(F(" (degrees * 10^-7)"));
112112

113-
long altitude = ubxDataStruct.hMSL; // Print the height above mean sea level
113+
long altitude = ubxDataStruct->hMSL; // Print the height above mean sea level
114114
Serial.print(F(" Alt: "));
115115
Serial.print(altitude);
116116
Serial.print(F(" (mm)"));
117117

118-
byte fixType = ubxDataStruct.fixType; // Print the fix type
118+
byte fixType = ubxDataStruct->fixType; // Print the fix type
119119
Serial.print(F(" Fix: "));
120120
if(fixType == 0) Serial.print(F("No fix"));
121121
else if(fixType == 1) Serial.print(F("Dead reckoning"));
@@ -171,9 +171,9 @@ void setup()
171171

172172
myGNSS.setNavigationFrequency(1); //Produce one solution per second
173173

174-
myGNSS.setAutoNAVSATcallback(&printSATdata); // Enable automatic NAV SAT messages with callback to printSATdata
175-
myGNSS.setAutoAOPSTATUScallback(&printAOPstatus); // Enable automatic NAV AOPSTATUS messages with callback to printAOPstatus
176-
myGNSS.setAutoPVTcallback(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata
174+
myGNSS.setAutoNAVSATcallbackPtr(&printSATdata); // Enable automatic NAV SAT messages with callback to printSATdata
175+
myGNSS.setAutoAOPSTATUScallbackPtr(&printAOPstatus); // Enable automatic NAV AOPSTATUS messages with callback to printAOPstatus
176+
myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata
177177
}
178178

179179
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

‎examples/AssistNow/AssistNow_Autonomous/Example2_AssistNowAutonomous_DatabaseRead/Example2_AssistNowAutonomous_DatabaseRead.ino

+9-9
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ SFE_UBLOX_GNSS myGNSS;
3535
// | / _____ You can use any name you like for the struct
3636
// | | /
3737
// | | |
38-
void printSATdata(UBX_NAV_SAT_data_t ubxDataStruct)
38+
void printSATdata(UBX_NAV_SAT_data_t *ubxDataStruct)
3939
{
4040
Serial.println();
4141

4242
Serial.print(F("UBX-NAV-SAT contains data for "));
43-
Serial.print(ubxDataStruct.header.numSvs);
44-
if (ubxDataStruct.header.numSvs == 1)
43+
Serial.print(ubxDataStruct->header.numSvs);
44+
if (ubxDataStruct->header.numSvs == 1)
4545
Serial.println(F(" SV"));
4646
else
4747
Serial.println(F(" SVs"));
4848

4949
uint16_t numAopAvail = 0; // Count how many SVs have AssistNow Autonomous data available
5050

51-
for (uint16_t block = 0; block < ubxDataStruct.header.numSvs; block++) // For each SV
51+
for (uint16_t block = 0; block < ubxDataStruct->header.numSvs; block++) // For each SV
5252
{
53-
if (ubxDataStruct.blocks[block].flags.bits.aopAvail == 1) // If the aopAvail bit is set
53+
if (ubxDataStruct->blocks[block].flags.bits.aopAvail == 1) // If the aopAvail bit is set
5454
numAopAvail++; // Increment the number of SVs
5555
}
5656

@@ -71,12 +71,12 @@ void printSATdata(UBX_NAV_SAT_data_t ubxDataStruct)
7171
// | / _____ You can use any name you like for the struct
7272
// | | /
7373
// | | |
74-
void printAOPstatus(UBX_NAV_AOPSTATUS_data_t ubxDataStruct)
74+
void printAOPstatus(UBX_NAV_AOPSTATUS_data_t *ubxDataStruct)
7575
{
7676
//Serial.println();
7777

7878
Serial.print(F("AOPSTATUS status is "));
79-
Serial.println(ubxDataStruct.status);
79+
Serial.println(ubxDataStruct->status);
8080
}
8181

8282
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -126,8 +126,8 @@ void setup()
126126

127127
myGNSS.setNavigationFrequency(1); //Produce one solution per second
128128

129-
myGNSS.setAutoNAVSATcallback(&printSATdata); // Enable automatic NAV SAT messages with callback to printSATdata
130-
myGNSS.setAutoAOPSTATUScallback(&printAOPstatus); // Enable automatic NAV AOPSTATUS messages with callback to printAOPstatus
129+
myGNSS.setAutoNAVSATcallbackPtr(&printSATdata); // Enable automatic NAV SAT messages with callback to printSATdata
130+
myGNSS.setAutoAOPSTATUScallbackPtr(&printAOPstatus); // Enable automatic NAV AOPSTATUS messages with callback to printAOPstatus
131131

132132
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
133133
// Keep displaying NAV SAT and AOPSTATUS until the user presses a key

0 commit comments

Comments
 (0)