|
45 | 45 | #include <SparkFun_u-blox_GNSS_Arduino_Library.h> // Click here to get the library: http://librarymanager/All#SparkFun_u-blox_GNSS
|
46 | 46 | SFE_UBLOX_GNSS myGNSS;
|
47 | 47 |
|
| 48 | +#define OK(ok) (ok ? F(" -> OK") : F(" -> ERROR!")) // Convert uint8_t into OK/ERROR |
| 49 | + |
48 | 50 | //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
49 | 51 |
|
50 | 52 | //Global variables
|
@@ -186,24 +188,29 @@ void setup()
|
186 | 188 |
|
187 | 189 | //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages on Serial
|
188 | 190 |
|
189 |
| - if (myGNSS.begin() == false) //Connect to the Ublox module using Wire port |
| 191 | + while (myGNSS.begin() == false) //Connect to the u-blox module using Wire port |
190 | 192 | {
|
191 |
| - Serial.println(F("u-blox GPS not detected at default I2C address. Please check wiring. Freezing.")); |
192 |
| - while (1); |
| 193 | + Serial.println(F("u-blox GNSS module not detected at default I2C address. Please check wiring.")); |
| 194 | + delay(2000); |
193 | 195 | }
|
194 |
| - |
195 |
| - Serial.println(F("u-blox module connected")); |
196 |
| - myGNSS.setI2COutput(COM_TYPE_UBX); //Turn off NMEA noise |
197 |
| - myGNSS.setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_SPARTN); // Be sure SPARTN input is enabled. |
198 |
| - |
199 |
| - myGNSS.setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); // Set the differential mode - ambiguities are fixed whenever possible |
200 |
| - myGNSS.setNavigationFrequency(1); //Set output in Hz. |
201 |
| - myGNSS.setVal8(UBLOX_CFG_SPARTN_USE_SOURCE, 0); // Use IP source (default). Change this to 1 for L-Band (PMP) |
| 196 | + Serial.println(F("u-blox GNSS module connected")); |
| 197 | + |
| 198 | + uint8_t ok = myGNSS.setI2COutput(COM_TYPE_UBX); //Turn off NMEA noise |
| 199 | + if (ok) ok = myGNSS.setPortInput(COM_PORT_I2C, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_SPARTN); // Be sure SPARTN input is enabled. |
| 200 | + |
| 201 | + if (ok) ok = myGNSS.setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED); // Set the differential mode - ambiguities are fixed whenever possible |
| 202 | + if (ok) ok = myGNSS.setNavigationFrequency(1); //Set output in Hz. |
| 203 | + if (ok) ok = myGNSS.setVal8(UBLOX_CFG_SPARTN_USE_SOURCE, 0); // Use IP source (default). Change this to 1 for L-Band (PMP) |
202 | 204 |
|
203 |
| - myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata so we can watch the carrier solution go to fixed |
| 205 | + if (ok) ok = myGNSS.setAutoPVTcallbackPtr(&printPVTdata); // Enable automatic NAV PVT messages with callback to printPVTdata so we can watch the carrier solution go to fixed |
204 | 206 |
|
205 |
| - myGNSS.setVal8(UBLOX_CFG_MSGOUT_UBX_RXM_COR_I2C, 1); // Enable UBX-RXM-COR messages on I2C |
206 |
| - myGNSS.setRXMCORcallbackPtr(&printRXMCOR); // Print the contents of UBX-RXM-COR messages so we can check if the SPARTN data is being decrypted successfully |
| 207 | + if (ok) ok = myGNSS.setVal8(UBLOX_CFG_MSGOUT_UBX_RXM_COR_I2C, 1); // Enable UBX-RXM-COR messages on I2C |
| 208 | + if (ok) ok = myGNSS.setRXMCORcallbackPtr(&printRXMCOR); // Print the contents of UBX-RXM-COR messages so we can check if the SPARTN data is being decrypted successfully |
| 209 | + |
| 210 | + //if (ok) ok = myGNSS.saveConfiguration(VAL_CFG_SUBSEC_IOPORT | VAL_CFG_SUBSEC_MSGCONF); //Optional: Save the ioPort and message settings to NVM |
| 211 | + |
| 212 | + Serial.print(F("GNSS: configuration ")); |
| 213 | + Serial.println(OK(ok)); |
207 | 214 |
|
208 | 215 | Serial.print(F("Connecting to local WiFi"));
|
209 | 216 | WiFi.begin(ssid, password);
|
|
0 commit comments