Skip to content

Commit 0554837

Browse files
authored
Merge pull request #84 from sparkfun/AssistNow
Add support for AssistNow Online, Offline & Autonomous
2 parents 7c7c8c2 + 0f5f8eb commit 0554837

File tree

22 files changed

+4075
-22
lines changed

22 files changed

+4075
-22
lines changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Migrating to v2.0 is easy. There are two small changes all users will need to ma
5353

5454
If you are using the Dead Reckoning Sensor Fusion or High Dynamic Rate messages, you will need to make more small changes to your code. Please see the [dead reckoning examples](./examples/Dead_Reckoning) for more details. There is more detail available in [Theory.md](./Theory.md#migrating-your-code-to-v20) if you need it.
5555

56+
## AssistNow<sup>TM</sup>
57+
58+
v2.1.0 of the library adds support for u-blox AssistNow<sup>TM</sup> Assisted GNSS (A-GNSS) which can dramatically reduce the time-to-first-fix. You can find further details in the [AssistNow Examples folder](./examples/AssistNow).
59+
5660
## Memory Usage
5761

5862
The u-blox GNSS library has grown considerably over the years and v2.0.8 came very close to completely filling the program memory on platforms like the ATmega328 (Arduino Uno).

Diff for: Theory.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ When the user calls one of the methods the library will poll the u-blox module f
55
* Wait for a minimum of 25 ms between polls (configured dynamically when update rate is set)
66
* Write 0xFD to module
77
* Read two bytes (0xFD and 0xFE) for bytes available
8-
* If 0x7F or 0xFF then no bytes are available
98
* Otherwise, read number of bytes and process into NMEA, UBX, or RTCM frame.
109
* If checksum is valid, flag frame as complete.
1110

@@ -58,6 +57,7 @@ In v2.0, the full list of messages which can be processed and logged automatical
5857
- UBX-NAV-CLOCK (0x01 0x22): Clock solution
5958
- UBX-NAV-SVIN (0x01 0x3B): Survey-in data (**only with High Precision GNSS products**)
6059
- UBX-NAV-RELPOSNED (0x01 0x3C): Relative positioning information in NED frame (**only with High Precision GNSS products**)
60+
- UBX-NAV-AOPSTATUS (0x01 0x60): AssistNow Autonomous status
6161
- UBX-RXM-SFRBX (0x02 0x13): Broadcast navigation data subframe
6262
- UBX-RXM-RAWX (0x02 0x15): Multi-GNSS raw measurement data (**only with ADR or High Precision GNSS or Time Sync products**)
6363
- UBX-TIM-TM2 (0x0D 0x03): Time mark data
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/*
2+
Monitor AssistNow Autonomous data collection
3+
By: SparkFun Electronics / Paul Clark
4+
Date: November 29th, 2021
5+
License: MIT. See license file for more information but you can
6+
basically do whatever you want with this code.
7+
8+
This example shows how to enable and monitor AssistNow Autonomous data collection by the module.
9+
A callback is used to monitor AssistNow Autonomous data availability for each satellite.
10+
A second callback is used to print the AOPSTATUS status.
11+
12+
If your GNSS board has battery-backup for the RAM - and all SparkFun boards do! - then you can:
13+
wait until the module has AssistNow Autonomous data for a few satellites;
14+
power-cycle the board;
15+
watch how fast it gets its first fix!
16+
17+
Note: this example will only work on boards which have plenty of RAM available.
18+
The UBX-NAV-SAT information occupies several kBytes.
19+
20+
Note: this example will not work on the ZED-F9P. "The ZED-F9P supports AssistNow Online only."
21+
22+
Feel like supporting open source hardware?
23+
Buy a board from SparkFun!
24+
SparkFun Thing Plus - ESP32 WROOM: https://www.sparkfun.com/products/15663
25+
SparkFun GPS Breakout - ZOE-M8Q (Qwiic): https://www.sparkfun.com/products/15193
26+
27+
Hardware Connections:
28+
Plug a Qwiic cable into the GNSS and a ESP32 Thing Plus
29+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
30+
Open the serial monitor at 115200 baud to see the output
31+
*/
32+
33+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
34+
SFE_UBLOX_GNSS myGNSS;
35+
36+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
37+
38+
// Callback: printSATdata will be called when new NAV SAT data arrives
39+
// See u-blox_structs.h for the full definition of UBX_NAV_SAT_data_t
40+
// _____ You can use any name you like for the callback. Use the same name when you call setAutoNAVSATcallback
41+
// / _____ This _must_ be UBX_NAV_SAT_data_t
42+
// | / _____ You can use any name you like for the struct
43+
// | | /
44+
// | | |
45+
void printSATdata(UBX_NAV_SAT_data_t ubxDataStruct)
46+
{
47+
//Serial.println();
48+
49+
Serial.print(F("UBX-NAV-SAT contains data for "));
50+
Serial.print(ubxDataStruct.header.numSvs);
51+
if (ubxDataStruct.header.numSvs == 1)
52+
Serial.println(F(" SV"));
53+
else
54+
Serial.println(F(" SVs"));
55+
56+
uint16_t numAopAvail = 0; // Count how many SVs have AssistNow Autonomous data available
57+
58+
for (uint16_t block = 0; block < ubxDataStruct.header.numSvs; block++) // For each SV
59+
{
60+
if (ubxDataStruct.blocks[block].flags.bits.aopAvail == 1) // If the aopAvail bit is set
61+
numAopAvail++; // Increment the number of SVs
62+
}
63+
64+
Serial.print(F("AssistNow Autonomous data is available for "));
65+
Serial.print(numAopAvail);
66+
if (numAopAvail == 1)
67+
Serial.println(F(" SV"));
68+
else
69+
Serial.println(F(" SVs"));
70+
}
71+
72+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
73+
74+
// Callback: printAOPstatus will be called when new NAV AOPSTATUS data arrives
75+
// See u-blox_structs.h for the full definition of UBX_NAV_AOPSTATUS_data_t
76+
// _____ You can use any name you like for the callback. Use the same name when you call setAutoNAVAOPSTATUScallback
77+
// / _____ This _must_ be UBX_NAV_AOPSTATUS_data_t
78+
// | / _____ You can use any name you like for the struct
79+
// | | /
80+
// | | |
81+
void printAOPstatus(UBX_NAV_AOPSTATUS_data_t ubxDataStruct)
82+
{
83+
//Serial.println();
84+
85+
Serial.print(F("AOPSTATUS status is "));
86+
Serial.println(ubxDataStruct.status);
87+
}
88+
89+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
90+
91+
// Callback: printPVTdata will be called when new NAV PVT data arrives
92+
// See u-blox_structs.h for the full definition of UBX_NAV_PVT_data_t
93+
// _____ You can use any name you like for the callback. Use the same name when you call setAutoPVTcallback
94+
// / _____ This _must_ be UBX_NAV_PVT_data_t
95+
// | / _____ You can use any name you like for the struct
96+
// | | /
97+
// | | |
98+
void printPVTdata(UBX_NAV_PVT_data_t ubxDataStruct)
99+
{
100+
// Print the UBX-NAV-PVT data so we can see how quickly the fixType goes to 3D
101+
102+
Serial.println();
103+
104+
long latitude = ubxDataStruct.lat; // Print the latitude
105+
Serial.print(F("Lat: "));
106+
Serial.print(latitude);
107+
108+
long longitude = ubxDataStruct.lon; // Print the longitude
109+
Serial.print(F(" Long: "));
110+
Serial.print(longitude);
111+
Serial.print(F(" (degrees * 10^-7)"));
112+
113+
long altitude = ubxDataStruct.hMSL; // Print the height above mean sea level
114+
Serial.print(F(" Alt: "));
115+
Serial.print(altitude);
116+
Serial.print(F(" (mm)"));
117+
118+
byte fixType = ubxDataStruct.fixType; // Print the fix type
119+
Serial.print(F(" Fix: "));
120+
if(fixType == 0) Serial.print(F("No fix"));
121+
else if(fixType == 1) Serial.print(F("Dead reckoning"));
122+
else if(fixType == 2) Serial.print(F("2D"));
123+
else if(fixType == 3) Serial.print(F("3D"));
124+
else if(fixType == 4) Serial.print(F("GNSS + Dead reckoning"));
125+
else if(fixType == 5) Serial.print(F("Time only"));
126+
127+
Serial.println();
128+
}
129+
130+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
131+
132+
void setup()
133+
{
134+
delay(1000);
135+
136+
Serial.begin(115200);
137+
Serial.println(F("AssistNow Example"));
138+
139+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
140+
// Start I2C. Connect to the GNSS.
141+
142+
Wire.begin(); //Start I2C
143+
144+
//myGNSS.enableDebugging(Serial, true); // Uncomment this line to see the 'major' debug messages on Serial
145+
146+
if (myGNSS.begin() == false) //Connect to the Ublox module using Wire port
147+
{
148+
Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing."));
149+
while (1);
150+
}
151+
Serial.println(F("u-blox module connected"));
152+
153+
myGNSS.setI2COutput(COM_TYPE_UBX); //Turn off NMEA noise
154+
myGNSS.saveConfigSelective(VAL_CFG_SUBSEC_IOPORT); //Save (only) the communications port settings to flash and BBR
155+
156+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
157+
// Enable AssistNow Autonomous data collection.
158+
159+
if (myGNSS.setAopCfg(1) == true)
160+
{
161+
Serial.println(F("aopCfg enabled"));
162+
}
163+
else
164+
{
165+
Serial.println(F("Could not enable aopCfg. Please check wiring. Freezing."));
166+
while (1);
167+
}
168+
169+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
170+
// Enable automatic UBX-NAV-SAT and UBX-NAV-AOPSTATUS messages and set up the callbacks
171+
172+
myGNSS.setNavigationFrequency(1); //Produce one solution per second
173+
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
177+
}
178+
179+
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
180+
181+
void loop()
182+
{
183+
myGNSS.checkUblox(); // Check for the arrival of new data and process it.
184+
myGNSS.checkCallbacks(); // Check if any callbacks are waiting to be processed.
185+
186+
Serial.print(".");
187+
delay(50);
188+
}

0 commit comments

Comments
 (0)