Skip to content

v2.1.3 #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ setNMEAOutputPort KEYWORD2

factoryReset KEYWORD2
hardReset KEYWORD2
softwareResetGNSSOnly KEYWORD2
factoryDefault KEYWORD2

saveConfiguration KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS Arduino Library
version=2.1.2
version=2.1.3
author=SparkFun Electronics <[email protected]>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C and Serial Communication with u-blox GNSS modules<br/><br/>
Expand Down
123 changes: 108 additions & 15 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down
20 changes: 11 additions & 9 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down