Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 38c9edc

Browse files
authored
Merge branch 'master' into sendCommand_return_corrections
2 parents bd00cde + 4218e01 commit 38c9edc

File tree

4 files changed

+63
-41
lines changed

4 files changed

+63
-41
lines changed

examples/Example17_Geofence/Example17_Geofence.ino

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void setup()
5050
Serial.println();
5151

5252
delay(1000); // Let the GPS power up
53-
53+
5454
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
5555
{
5656
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
@@ -64,7 +64,7 @@ void setup()
6464

6565
byte fixType = 0;
6666

67-
while (fixType != 3)
67+
while (fixType < 3)
6868
{
6969
fixType = myGPS.getFixType(); // Get the fix type
7070
Serial.print(F("Fix: ")); // Print it
@@ -74,6 +74,7 @@ void setup()
7474
else if(fixType == 2) Serial.print(F(" = 2D"));
7575
else if(fixType == 3) Serial.print(F(" = 3D"));
7676
else if(fixType == 4) Serial.print(F(" = GNSS + Dead reckoning"));
77+
else if(fixType == 5) Serial.print(F(" = Time only"));
7778
Serial.println();
7879
delay(1000);
7980
}
@@ -89,7 +90,7 @@ void setup()
8990
Serial.println(longitude);
9091

9192
uint32_t radius = 500; // Set the radius to 5m (radius is in m * 10^-2 i.e. cm)
92-
93+
9394
byte confidence = 2; // Set the confidence level: 0=none, 1=68%, 2=95%, 3=99.7%, 4=99.99%
9495

9596
// Call clearGeofences() to clear all existing geofences.
@@ -99,18 +100,18 @@ void setup()
99100
// It is possible to define up to four geofences.
100101
// Call addGeofence up to four times to define them.
101102
Serial.println(F("Setting the geofences:"));
102-
103+
103104
Serial.print(F("addGeofence for geofence 1 returned: "));
104105
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
105-
106+
106107
radius = 1000; // 10m
107108
Serial.print(F("addGeofence for geofence 2 returned: "));
108109
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
109-
110+
110111
radius = 1500; // 15m
111112
Serial.print(F("addGeofence for geofence 3 returned: "));
112113
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
113-
114+
114115
radius = 2000; // 20m
115116
Serial.print(F("addGeofence for geofence 4 returned: "));
116117
Serial.println(myGPS.addGeofence(latitude, longitude, radius, confidence));
@@ -130,16 +131,16 @@ void loop()
130131
Serial.println(F(".")); // Tidy up
131132
return; // and go round the loop again
132133
}
133-
134+
134135
Serial.print(F(". status is: ")); // Print the status
135136
Serial.print(currentGeofenceState.status);
136-
137+
137138
Serial.print(F(". numFences is: ")); // Print the numFences
138139
Serial.print(currentGeofenceState.numFences);
139-
140+
140141
Serial.print(F(". combState is: ")); // Print the combined state
141142
Serial.print(currentGeofenceState.combState);
142-
143+
143144
if (currentGeofenceState.combState == 0)
144145
{
145146
Serial.print(F(" = Unknown"));
@@ -163,6 +164,6 @@ void loop()
163164
Serial.print(currentGeofenceState.states[i]);
164165
}
165166
Serial.println();
166-
167+
167168
delay(1000);
168169
}

examples/ZED-F9P/Example2_ValConfigurationMethod/Example2_ValConfigurationMethod.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ void setup()
4646
}
4747

4848
byte response;
49-
response = myGPS.getVal(VAL_GROUP_I2C, VAL_ID_I2C_ADDRESS, VAL_GROUP_I2C_SIZE, VAL_LAYER_RAM);
49+
response = myGPS.getVal8(VAL_GROUP_I2C, VAL_ID_I2C_ADDRESS, VAL_GROUP_I2C_SIZE, VAL_LAYER_RAM);
5050
Serial.print(F("I2C Address: 0x"));
5151
Serial.println(response >> 1, HEX); //We have to shift by 1 to get the common '7-bit' I2C address format
5252

53-
response = myGPS.getVal(VAL_GROUP_I2COUTPROT, VAL_ID_I2COUTPROT_NMEA, VAL_GROUP_I2COUTPROT_SIZE, VAL_LAYER_RAM);
53+
response = myGPS.getVal8(VAL_GROUP_I2COUTPROT, VAL_ID_I2COUTPROT_NMEA, VAL_GROUP_I2COUTPROT_SIZE, VAL_LAYER_RAM);
5454
Serial.print(F("Output NMEA over I2C port: 0x"));
5555
Serial.print(response, HEX);
5656
}

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ void SFE_UBLOX_GPS::sendSerialCommand(ubxPacket outgoingUBX)
965965
}
966966

967967
//Returns true if I2C device ack's
968-
boolean SFE_UBLOX_GPS::isConnected()
968+
boolean SFE_UBLOX_GPS::isConnected(uint16_t maxWait)
969969
{
970970
if (commType == COMM_TYPE_I2C)
971971
{
@@ -980,7 +980,7 @@ boolean SFE_UBLOX_GPS::isConnected()
980980
packetCfg.len = 0;
981981
packetCfg.startingSpot = 0;
982982

983-
return (sendCommand(packetCfg) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are polling the RATE so we expect data and an ACK
983+
return (sendCommand(packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are polling the RATE so we expect data and an ACK
984984
}
985985
return false;
986986
}
@@ -1343,8 +1343,19 @@ uint8_t SFE_UBLOX_GPS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
13431343
for (uint8_t x = 0; x < packetCfg.len; x++)
13441344
packetCfg.payload[x] = 0;
13451345

1346+
//VALGET uses different memory layer definitions to VALSET
1347+
//because it can only return the value for one layer.
1348+
//So we need to fiddle the layer here.
1349+
//And just to complicate things further, the ZED-F9P only responds
1350+
//correctly to layer 0 (RAM) and layer 7 (Default)!
1351+
uint8_t getLayer = 7; // 7 is the "Default Layer"
1352+
if ((layer & VAL_LAYER_RAM) == VAL_LAYER_RAM) // Did the user request the RAM layer?
1353+
{
1354+
getLayer = 0; // Layer 0 is RAM
1355+
}
1356+
13461357
payloadCfg[0] = 0; //Message Version - set to 0
1347-
payloadCfg[1] = layer; //By default we ask for the BBR layer
1358+
payloadCfg[1] = getLayer; //Layer
13481359

13491360
//Load key into outgoing payload
13501361
payloadCfg[4] = key >> 8 * 0; //Key LSB

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,19 @@ class SFE_UBLOX_GPS
426426
public:
427427
SFE_UBLOX_GPS(void);
428428

429+
// A default of 250ms for maxWait seems fine for I2C but is not enough for SerialUSB.
430+
// If you know you are only going to be using I2C / Qwiic communication, you can
431+
// safely reduce defaultMaxWait to 250.
432+
#define defaultMaxWait 1100
433+
429434
//By default use the default I2C address, and use Wire port
430435
boolean begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42); //Returns true if module is detected
431436
//serialPort needs to be perviously initialized to correct baud rate
432437
boolean begin(Stream &serialPort); //Returns true if module is detected
433438

434-
boolean isConnected(); //Returns turn if device answers on _gpsI2Caddress address
439+
//Returns true if device answers on _gpsI2Caddress address or via Serial
440+
//maxWait is only used for Serial
441+
boolean isConnected(uint16_t maxWait = 1100);
435442

436443
boolean checkUblox(); //Checks module with user selected commType
437444
boolean checkUbloxI2C(); //Method for I2C polling of data, passing any new bytes to process()
@@ -446,7 +453,7 @@ class SFE_UBLOX_GPS
446453
void processNMEA(char incoming) __attribute__((weak)); //Given a NMEA character, do something with it. User can overwrite if desired to use something like tinyGPS or MicroNMEA libraries
447454

448455
void calcChecksum(ubxPacket *msg); //Sets the checksumA and checksumB of a given messages
449-
sfe_ublox_status_e sendCommand(ubxPacket outgoingUBX, uint16_t maxWait = 250); //Given a packet and payload, send everything including CRC bytes, return true if we got a response
456+
sfe_ublox_status_e sendCommand(ubxPacket outgoingUBX, uint16_t maxWait = defaultMaxWait); //Given a packet and payload, send everything including CRC bytes, return true if we got a response
450457
sfe_ublox_status_e sendI2cCommand(ubxPacket outgoingUBX, uint16_t maxWait = 250);
451458
void sendSerialCommand(ubxPacket outgoingUBX);
452459

@@ -456,17 +463,17 @@ class SFE_UBLOX_GPS
456463
void hardReset(); //Perform a reset leading to a cold start (zero info start-up)
457464

458465
boolean setI2CAddress(uint8_t deviceAddress, uint16_t maxTime = 250); //Changes the I2C address of the Ublox module
459-
void setSerialRate(uint32_t baudrate, uint8_t uartPort = COM_PORT_UART1, uint16_t maxTime = 250); //Changes the serial baud rate of the Ublox module, uartPort should be COM_PORT_UART1/2
466+
void setSerialRate(uint32_t baudrate, uint8_t uartPort = COM_PORT_UART1, uint16_t maxTime = defaultMaxWait); //Changes the serial baud rate of the Ublox module, uartPort should be COM_PORT_UART1/2
460467
void setNMEAOutputPort(Stream &nmeaOutputPort); //Sets the internal variable for the port to direct NMEA characters to
461468

462-
boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = 250); //Set the number of nav solutions sent per second
463-
uint8_t getNavigationFrequency(uint16_t maxWait = 250); //Get the number of nav solutions sent per second currently being output by module
464-
boolean saveConfiguration(uint16_t maxWait = 250); //Save current configuration to flash and BBR (battery backed RAM)
465-
boolean factoryDefault(uint16_t maxWait = 250); //Reset module to factory defaults
466-
boolean saveConfigSelective(uint32_t configMask, uint16_t maxWait = 250); //Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
469+
boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second
470+
uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module
471+
boolean saveConfiguration(uint16_t maxWait = defaultMaxWait); //Save current configuration to flash and BBR (battery backed RAM)
472+
boolean factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults
473+
boolean saveConfigSelective(uint32_t configMask, uint16_t maxWait = defaultMaxWait); //Save the selected configuration sub-sections to flash and BBR (battery backed RAM)
467474

468-
sfe_ublox_status_e waitForACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until a config packet and an ACK is received
469-
sfe_ublox_status_e waitForNoACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until a config packet is received
475+
sfe_ublox_status_e waitForACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = defaultMaxWait); //Poll the module until a config packet and an ACK is received
476+
sfe_ublox_status_e waitForNoACKResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = defaultMaxWait); //Poll the module until a config packet is received
470477

471478
// getPVT will only return data once in each navigation cycle. By default, that is once per second.
472479
// Therefore we should set getPVTmaxWait to slightly longer than that.
@@ -477,9 +484,9 @@ class SFE_UBLOX_GPS
477484
#define getHPPOSLLHmaxWait 1100 // Default maxWait for getHPPOSLLH and all functions which call it
478485

479486
boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
480-
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
487+
boolean setAutoPVT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic PVT reports at the navigation frequency
481488
boolean getPVT(uint16_t maxWait = getPVTmaxWait); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Retruns true if new PVT is available.
482-
boolean setAutoPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
489+
boolean setAutoPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic PVT reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
483490
boolean getHPPOSLLH(uint16_t maxWait = getHPPOSLLHmaxWait); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Retruns true if new PVT is available.
484491
void flushPVT(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
485492

@@ -512,26 +519,28 @@ class SFE_UBLOX_GPS
512519
uint32_t getVerticalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);
513520

514521
//Port configurations
515-
boolean setPortOutput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = 250); //Configure a given port to output UBX, NMEA, RTCM3 or a combination thereof
516-
boolean setPortInput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = 250); //Configure a given port to input UBX, NMEA, RTCM3 or a combination thereof
517-
boolean getPortSettings(uint8_t portID, uint16_t maxWait = 250); //Returns the current protocol bits in the UBX-CFG-PRT command for a given port
522+
boolean setPortOutput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure a given port to output UBX, NMEA, RTCM3 or a combination thereof
523+
boolean setPortInput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure a given port to input UBX, NMEA, RTCM3 or a combination thereof
524+
boolean getPortSettings(uint8_t portID, uint16_t maxWait = defaultMaxWait); //Returns the current protocol bits in the UBX-CFG-PRT command for a given port
518525

519526
boolean setI2COutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure I2C port to output UBX, NMEA, RTCM3 or a combination thereof
520-
boolean setUART1Output(uint8_t comSettings, uint16_t maxWait = 250); //Configure UART1 port to output UBX, NMEA, RTCM3 or a combination thereof
521-
boolean setUART2Output(uint8_t comSettings, uint16_t maxWait = 250); //Configure UART2 port to output UBX, NMEA, RTCM3 or a combination thereof
527+
boolean setUART1Output(uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure UART1 port to output UBX, NMEA, RTCM3 or a combination thereof
528+
boolean setUART2Output(uint8_t comSettings, uint16_t maxWait = defaultMaxWait); //Configure UART2 port to output UBX, NMEA, RTCM3 or a combination thereof
522529
boolean setUSBOutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure USB port to output UBX, NMEA, RTCM3 or a combination thereof
523530
boolean setSPIOutput(uint8_t comSettings, uint16_t maxWait = 250); //Configure SPI port to output UBX, NMEA, RTCM3 or a combination thereof
524531

525532
//Functions to turn on/off message types for a given port ID (see COM_PORT_I2C, etc above)
526-
boolean configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate, uint16_t maxWait = 250);
527-
boolean enableMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate = 1, uint16_t maxWait = 250);
528-
boolean disableMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint16_t maxWait = 250);
529-
boolean enableNMEAMessage(uint8_t msgID, uint8_t portID, uint8_t sendRate = 1, uint16_t maxWait = 250);
530-
boolean disableNMEAMessage(uint8_t msgID, uint8_t portID, uint16_t maxWait = 250);
531-
boolean enableRTCMmessage(uint8_t messageNumber, uint8_t portID, uint8_t sendRate, uint16_t maxWait = 250); //Given a message number turns on a message ID for output over given PortID
532-
boolean disableRTCMmessage(uint8_t messageNumber, uint8_t portID, uint16_t maxWait = 250); //Turn off given RTCM message from a given port
533+
boolean configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate, uint16_t maxWait = defaultMaxWait);
534+
boolean enableMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate = 1, uint16_t maxWait = defaultMaxWait);
535+
boolean disableMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint16_t maxWait = defaultMaxWait);
536+
boolean enableNMEAMessage(uint8_t msgID, uint8_t portID, uint8_t sendRate = 1, uint16_t maxWait = defaultMaxWait);
537+
boolean disableNMEAMessage(uint8_t msgID, uint8_t portID, uint16_t maxWait = defaultMaxWait);
538+
boolean enableRTCMmessage(uint8_t messageNumber, uint8_t portID, uint8_t sendRate, uint16_t maxWait = defaultMaxWait); //Given a message number turns on a message ID for output over given PortID
539+
boolean disableRTCMmessage(uint8_t messageNumber, uint8_t portID, uint16_t maxWait = defaultMaxWait); //Turn off given RTCM message from a given port
533540

534541
//General configuration (used only on protocol v27 and higher - ie, ZED-F9P)
542+
//It is probably safe to assume that users of the ZED-F9P will be using I2C / Qwiic.
543+
//If they are using Serial then the higher baud rate will also help. So let's leave maxWait set to 250ms.
535544
uint8_t getVal8(uint16_t group, uint16_t id, uint8_t size, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
536545
uint8_t getVal8(uint32_t keyID, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Returns the value at a given group/id/size location
537546
uint8_t setVal(uint32_t keyID, uint16_t value, uint8_t layer = VAL_LAYER_BBR, uint16_t maxWait = 250); //Sets the 16-bit value at a given group/id/size location
@@ -549,6 +558,7 @@ class SFE_UBLOX_GPS
549558
uint8_t sendCfgValset32(uint32_t keyID, uint32_t value, uint16_t maxWait = 250); //Add the final KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
550559

551560
//Functions used for RTK and base station setup
561+
//It is probably safe to assume that users of the RTK will be using I2C / Qwiic. So let's leave maxWait set to 250ms.
552562
boolean getSurveyMode(uint16_t maxWait = 250); //Get the current TimeMode3 settings
553563
boolean setSurveyMode(uint8_t mode, uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); //Control survey in mode
554564
boolean enableSurveyMode(uint16_t observationTime, float requiredAccuracy, uint16_t maxWait = 250); //Begin Survey-In for NEO-M8P

0 commit comments

Comments
 (0)