diff --git a/keywords.txt b/keywords.txt index 60f06f1..3aad233 100644 --- a/keywords.txt +++ b/keywords.txt @@ -121,6 +121,7 @@ setNMEAOutputPort KEYWORD2 factoryReset KEYWORD2 hardReset KEYWORD2 +softwareResetGNSSOnly KEYWORD2 factoryDefault KEYWORD2 saveConfiguration KEYWORD2 diff --git a/library.properties b/library.properties index c52c9b2..b06dd6b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.1.2 +version=2.1.3 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C and Serial Communication with u-blox GNSS modules

diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 391355e..34419a0 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -438,7 +438,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize) } //Initialize the I2C port -bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress) +bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait, bool assumeSuccess) { commType = COMM_TYPE_I2C; _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) createFileBuffer(); // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored - bool connected = isConnected(); + bool connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - second attempt")); + } +#endif + connected = isConnected(maxWait); + } if (!connected) - connected = isConnected(); + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - third attempt")); + } +#endif + connected = isConnected(maxWait); + } + + if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate. + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: third attempt failed. Assuming success...")); + } +#endif + return (true); + } return (connected); } //Initialize the Serial port -bool SFE_UBLOX_GNSS::begin(Stream &serialPort) +bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait, bool assumeSuccess) { commType = COMM_TYPE_SERIAL; _serialPort = &serialPort; //Grab which port the user wants us to use @@ -486,19 +513,46 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort) createFileBuffer(); // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored - bool connected = isConnected(); + bool connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - second attempt")); + } +#endif + connected = isConnected(maxWait); + } if (!connected) - connected = isConnected(); + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - third attempt")); + } +#endif + connected = isConnected(maxWait); + } + + if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate. + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: third attempt failed. Assuming success...")); + } +#endif + return (true); + } return (connected); } // Initialize for SPI -bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed) +bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait, bool assumeSuccess) { commType = COMM_TYPE_SPI; _spiPort = &spiPort; @@ -538,14 +592,41 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed) } } - // Call isConnected up to three times - bool connected = isConnected(); + // Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored + bool connected = isConnected(maxWait); if (!connected) - connected = isConnected(); + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - second attempt")); + } +#endif + connected = isConnected(maxWait); + } if (!connected) - connected = isConnected(); + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: isConnected - third attempt")); + } +#endif + connected = isConnected(maxWait); + } + + if ((!connected ) && assumeSuccess) // Advanced users can assume success if required. Useful if the port is outputting messages at high navigation rate. + { +#ifndef SFE_UBLOX_REDUCED_PROG_MEM + if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging + { + _debugSerial->println(F("begin: third attempt failed. Assuming success...")); + } +#endif + return (true); + } return (connected); } @@ -5413,6 +5494,20 @@ void SFE_UBLOX_GNSS::hardReset() sendCommand(&packetCfg, 0); // don't expect ACK } +void SFE_UBLOX_GNSS::softwareResetGNSSOnly() +{ + // Issue controlled software reset (GNSS only) + packetCfg.cls = UBX_CLASS_CFG; + packetCfg.id = UBX_CFG_RST; + packetCfg.len = 4; + packetCfg.startingSpot = 0; + payloadCfg[0] = 0; // hot start + payloadCfg[1] = 0; // hot start + payloadCfg[2] = 0x02; // 0x02 = Controlled software reset (GNSS only) + payloadCfg[3] = 0; // reserved + sendCommand(&packetCfg, 0); // don't expect ACK +} + //Reset module to factory defaults //This still works but it is the old way of configuring ublox modules. See getVal and setVal for the new methods bool SFE_UBLOX_GNSS::factoryDefault(uint16_t maxWait) @@ -9628,9 +9723,7 @@ bool SFE_UBLOX_GNSS::getNavigationFrequencyInternal(uint16_t maxWait) return (true); if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) - { return (true); - } return (false); } diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index d66c57e..6f5bc92 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -598,12 +598,13 @@ class SFE_UBLOX_GNSS //New in v2.0: allow the payload size for packetCfg to be changed void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize + //Begin communication with the GNSS. Advanced users can assume success if required. Useful if the port is already outputting messages at high navigation rate. //By default use the default I2C address, and use Wire port - bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42); //Returns true if module is detected + bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); //Returns true if module is detected //serialPort needs to be perviously initialized to correct baud rate - bool begin(Stream &serialPort); //Returns true if module is detected + bool begin(Stream &serialPort, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); //Returns true if module is detected //SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) - bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed); + bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = defaultMaxWait, bool assumeSuccess = false); void end(void); //Stop all automatic message processing. Free all used RAM @@ -633,7 +634,7 @@ class SFE_UBLOX_GNSS int8_t getMaxNMEAByteCount(void); //Returns true if device answers on _gpsI2Caddress address or via Serial - bool isConnected(uint16_t maxWait = 1100); + bool isConnected(uint16_t maxWait = defaultMaxWait); // Enable debug messages using the chosen Serial port (Stream) // Boards like the RedBoard Turbo use SerialUSB (not Serial). @@ -780,7 +781,8 @@ class SFE_UBLOX_GNSS void factoryReset(); //Send factory reset sequence (i.e. load "default" configuration and perform hardReset) void hardReset(); //Perform a reset leading to a cold start (zero info start-up) - bool factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults + void softwareResetGNSSOnly(); //Controlled Software Reset (GNSS only) only restarts the GNSS tasks, without reinitializing the full system or reloading any stored configuration. + bool factoryDefault(uint16_t maxWait = defaultMaxWait); //Reset module to factory defaults //Save configuration to BBR / Flash @@ -826,7 +828,7 @@ class SFE_UBLOX_GNSS bool powerSaveMode(bool power_save = true, uint16_t maxWait = defaultMaxWait); uint8_t getPowerSaveMode(uint16_t maxWait = defaultMaxWait); // Returns 255 if the sendCommand fails bool powerOff(uint32_t durationInMs, uint16_t maxWait = defaultMaxWait); - bool powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, bool forceWhileUsb = true, uint16_t maxWait = 1100); + bool powerOffWithInterrupt(uint32_t durationInMs, uint32_t wakeupSources = VAL_RXM_PMREQ_WAKEUPSOURCE_EXTINT0, bool forceWhileUsb = true, uint16_t maxWait = defaultMaxWait); //Change the dynamic platform model using UBX-CFG-NAV5 bool setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = defaultMaxWait); @@ -1235,7 +1237,7 @@ class SFE_UBLOX_GNSS // Helper functions for HPPOSECEF - 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, + 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, // Helper functions for HPPOSLLH @@ -1291,8 +1293,8 @@ class SFE_UBLOX_GNSS // Helper functions for HNR - bool setHNRNavigationRate(uint8_t rate, uint16_t maxWait = 1100); // Returns true if the setHNRNavigationRate is successful - uint8_t getHNRNavigationRate(uint16_t maxWait = 1100); // Returns 0 if the getHNRNavigationRate fails + bool setHNRNavigationRate(uint8_t rate, uint16_t maxWait = defaultMaxWait); // Returns true if the setHNRNavigationRate is successful + uint8_t getHNRNavigationRate(uint16_t maxWait = defaultMaxWait); // Returns 0 if the getHNRNavigationRate fails float getHNRroll(uint16_t maxWait = defaultMaxWait); // Returned as degrees float getHNRpitch(uint16_t maxWait = defaultMaxWait); // Returned as degrees float getHNRheading(uint16_t maxWait = defaultMaxWait); // Returned as degrees