Skip to content

Commit a5e581a

Browse files
authored
Merge pull request #90 from sparkfun/release_candidate
v2.1.3
2 parents 78df56c + 0ecec8b commit a5e581a

4 files changed

+121
-25
lines changed

Diff for: keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ setNMEAOutputPort KEYWORD2
121121

122122
factoryReset KEYWORD2
123123
hardReset KEYWORD2
124+
softwareResetGNSSOnly KEYWORD2
124125
factoryDefault KEYWORD2
125126

126127
saveConfiguration KEYWORD2

Diff for: library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS Arduino Library
2-
version=2.1.2
2+
version=2.1.3
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C and Serial Communication with u-blox GNSS modules<br/><br/>

Diff for: src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+108-15
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize)
438438
}
439439

440440
//Initialize the I2C port
441-
bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress)
441+
bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait, bool assumeSuccess)
442442
{
443443
commType = COMM_TYPE_I2C;
444444
_i2cPort = &wirePort; //Grab which port the user wants us to use
@@ -461,19 +461,46 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress)
461461
createFileBuffer();
462462

463463
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
464-
bool connected = isConnected();
464+
bool connected = isConnected(maxWait);
465465

466466
if (!connected)
467-
connected = isConnected();
467+
{
468+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
469+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
470+
{
471+
_debugSerial->println(F("begin: isConnected - second attempt"));
472+
}
473+
#endif
474+
connected = isConnected(maxWait);
475+
}
468476

469477
if (!connected)
470-
connected = isConnected();
478+
{
479+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
480+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
481+
{
482+
_debugSerial->println(F("begin: isConnected - third attempt"));
483+
}
484+
#endif
485+
connected = isConnected(maxWait);
486+
}
487+
488+
if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate.
489+
{
490+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
491+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
492+
{
493+
_debugSerial->println(F("begin: third attempt failed. Assuming success..."));
494+
}
495+
#endif
496+
return (true);
497+
}
471498

472499
return (connected);
473500
}
474501

475502
//Initialize the Serial port
476-
bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
503+
bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool assumeSuccess)
477504
{
478505
commType = COMM_TYPE_SERIAL;
479506
_serialPort = &serialPort; //Grab which port the user wants us to use
@@ -486,19 +513,46 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
486513
createFileBuffer();
487514

488515
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
489-
bool connected = isConnected();
516+
bool connected = isConnected(maxWait);
490517

491518
if (!connected)
492-
connected = isConnected();
519+
{
520+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
521+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
522+
{
523+
_debugSerial->println(F("begin: isConnected - second attempt"));
524+
}
525+
#endif
526+
connected = isConnected(maxWait);
527+
}
493528

494529
if (!connected)
495-
connected = isConnected();
530+
{
531+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
532+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
533+
{
534+
_debugSerial->println(F("begin: isConnected - third attempt"));
535+
}
536+
#endif
537+
connected = isConnected(maxWait);
538+
}
539+
540+
if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate.
541+
{
542+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
543+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
544+
{
545+
_debugSerial->println(F("begin: third attempt failed. Assuming success..."));
546+
}
547+
#endif
548+
return (true);
549+
}
496550

497551
return (connected);
498552
}
499553

500554
// Initialize for SPI
501-
bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
555+
bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait, bool assumeSuccess)
502556
{
503557
commType = COMM_TYPE_SPI;
504558
_spiPort = &spiPort;
@@ -538,14 +592,41 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
538592
}
539593
}
540594

541-
// Call isConnected up to three times
542-
bool connected = isConnected();
595+
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored
596+
bool connected = isConnected(maxWait);
543597

544598
if (!connected)
545-
connected = isConnected();
599+
{
600+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
601+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
602+
{
603+
_debugSerial->println(F("begin: isConnected - second attempt"));
604+
}
605+
#endif
606+
connected = isConnected(maxWait);
607+
}
546608

547609
if (!connected)
548-
connected = isConnected();
610+
{
611+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
612+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
613+
{
614+
_debugSerial->println(F("begin: isConnected - third attempt"));
615+
}
616+
#endif
617+
connected = isConnected(maxWait);
618+
}
619+
620+
if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate.
621+
{
622+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
623+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
624+
{
625+
_debugSerial->println(F("begin: third attempt failed. Assuming success..."));
626+
}
627+
#endif
628+
return (true);
629+
}
549630

550631
return (connected);
551632
}
@@ -5413,6 +5494,20 @@ void SFE_UBLOX_GNSS::hardReset()
54135494
sendCommand(&packetCfg, 0); // don't expect ACK
54145495
}
54155496

5497+
void SFE_UBLOX_GNSS::softwareResetGNSSOnly()
5498+
{
5499+
// Issue controlled software reset (GNSS only)
5500+
packetCfg.cls = UBX_CLASS_CFG;
5501+
packetCfg.id = UBX_CFG_RST;
5502+
packetCfg.len = 4;
5503+
packetCfg.startingSpot = 0;
5504+
payloadCfg[0] = 0; // hot start
5505+
payloadCfg[1] = 0; // hot start
5506+
payloadCfg[2] = 0x02; // 0x02 = Controlled software reset (GNSS only)
5507+
payloadCfg[3] = 0; // reserved
5508+
sendCommand(&packetCfg, 0); // don't expect ACK
5509+
}
5510+
54165511
//Reset module to factory defaults
54175512
//This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods
54185513
bool SFE_UBLOX_GNSS::factoryDefault(uint16_t maxWait)
@@ -9628,9 +9723,7 @@ bool SFE_UBLOX_GNSS::getNavigationFrequencyInternal(uint16_t maxWait)
96289723
return (true);
96299724

96309725
if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
9631-
{
96329726
return (true);
9633-
}
96349727

96359728
return (false);
96369729
}

Diff for: src/SparkFun_u-blox_GNSS_Arduino_Library.h

+11-9
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,13 @@ class SFE_UBLOX_GNSS
598598
//New in v2.0: allow the payload size for packetCfg to be changed
599599
void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize
600600

601+
//Begin communication with the GNSS. Advanced users can assume success if required. Useful if the port is already outputting messages at high navigation rate.
601602
//By default use the default I2C address, and use Wire port
602-
bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42); //Returns true if module is detected
603+
bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); //Returns true if module is detected
603604
//serialPort needs to be perviously initialized to correct baud rate
604-
bool begin(Stream &serialPort); //Returns true if module is detected
605+
bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); //Returns true if module is detected
605606
//SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz)
606-
bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed);
607+
bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false);
607608

608609
void end(void); //Stop all automatic message processing. Free all used RAM
609610

@@ -633,7 +634,7 @@ class SFE_UBLOX_GNSS
633634
int8_t getMaxNMEAByteCount(void);
634635

635636
//Returns true if device answers on _gpsI2Caddress address or via Serial
636-
bool isConnected(uint16_t maxWait = 1100);
637+
bool isConnected(uint16_t maxWait = defaultMaxWait);
637638

638639
// Enable debug messages using the chosen Serial port (Stream)
639640
// Boards like the RedBoard Turbo use SerialUSB (not Serial).
@@ -780,7 +781,8 @@ class SFE_UBLOX_GNSS
780781

781782
void factoryReset(); //Send factory reset sequence (i.e. load "default" configuration and perform hardReset)
782783
void hardReset(); //Perform a reset leading to a cold start (zero info start-up)
783-
bool factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults
784+
void softwareResetGNSSOnly(); //Controlled Software Reset (GNSS only) only restarts the GNSS tasks, without reinitializing the full system or reloading any stored configuration.
785+
bool factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults
784786

785787
//Save configuration to BBR / Flash
786788

@@ -826,7 +828,7 @@ class SFE_UBLOX_GNSS
826828
bool powerSaveMode(bool power_save = true, uint16_t maxWait = defaultMaxWait);
827829
uint8_t getPowerSaveMode(uint16_t maxWait = defaultMaxWait); // Returns 255 if the sendCommand fails
828830
bool powerOff(uint32_t durationInMs, uint16_t maxWait = defaultMaxWait);
829-
bool powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, bool forceWhileUsb = true, uint16_t maxWait = 1100);
831+
bool powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, bool forceWhileUsb = true, uint16_t maxWait = defaultMaxWait);
830832

831833
//Change the dynamic platform model using UBX-CFG-NAV5
832834
bool setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = defaultMaxWait);
@@ -1235,7 +1237,7 @@ class SFE_UBLOX_GNSS
12351237

12361238
// Helper functions for HPPOSECEF
12371239

1238-
uint32_t getPositionAccuracy(uint16_t maxWait = 1100); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P,
1240+
uint32_t getPositionAccuracy(uint16_t maxWait = defaultMaxWait); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P,
12391241

12401242
// Helper functions for HPPOSLLH
12411243

@@ -1291,8 +1293,8 @@ class SFE_UBLOX_GNSS
12911293

12921294
// Helper functions for HNR
12931295

1294-
bool setHNRNavigationRate(uint8_t rate, uint16_t maxWait = 1100); // Returns true if the setHNRNavigationRate is successful
1295-
uint8_t getHNRNavigationRate(uint16_t maxWait = 1100); // Returns 0 if the getHNRNavigationRate fails
1296+
bool setHNRNavigationRate(uint8_t rate, uint16_t maxWait = defaultMaxWait); // Returns true if the setHNRNavigationRate is successful
1297+
uint8_t getHNRNavigationRate(uint16_t maxWait = defaultMaxWait); // Returns 0 if the getHNRNavigationRate fails
12961298
float getHNRroll(uint16_t maxWait = defaultMaxWait); // Returned as degrees
12971299
float getHNRpitch(uint16_t maxWait = defaultMaxWait); // Returned as degrees
12981300
float getHNRheading(uint16_t maxWait = defaultMaxWait); // Returned as degrees

0 commit comments

Comments
 (0)