Skip to content

Add maxWait to begin functions #89

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 2 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
24 changes: 12 additions & 12 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,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)
{
commType = COMM_TYPE_I2C;
_i2cPort = &wirePort; //Grab which port the user wants us to use
Expand All @@ -429,19 +429,19 @@ 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();
connected = isConnected(maxWait);

if (!connected)
connected = isConnected();
connected = isConnected(maxWait);

return (connected);
}

//Initialize the Serial port
bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait)
{
commType = COMM_TYPE_SERIAL;
_serialPort = &serialPort; //Grab which port the user wants us to use
Expand All @@ -454,19 +454,19 @@ 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();
connected = isConnected(maxWait);

if (!connected)
connected = isConnected();
connected = isConnected(maxWait);

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)
{
commType = COMM_TYPE_SPI;
_spiPort = &spiPort;
Expand Down Expand Up @@ -507,13 +507,13 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
}

// Call isConnected up to three times
bool connected = isConnected();
bool connected = isConnected(maxWait);

if (!connected)
connected = isConnected();
connected = isConnected(maxWait);

if (!connected)
connected = isConnected();
connected = isConnected(maxWait);

return (connected);
}
Expand Down
6 changes: 3 additions & 3 deletions src/SparkFun_u-blox_GNSS_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,11 @@ class SFE_UBLOX_GNSS
void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize

//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 = 1100); //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 = 1100); //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 = 1100);

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

Expand Down