Skip to content

Commit ec4a7c4

Browse files
committed
Add maxWait to begin functions
1 parent 7c7c8c2 commit ec4a7c4

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize)
406406
}
407407

408408
//Initialize the I2C port
409-
bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress)
409+
bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress, uint16_t maxWait)
410410
{
411411
commType = COMM_TYPE_I2C;
412412
_i2cPort = &wirePort; //Grab which port the user wants us to use
@@ -429,19 +429,19 @@ bool SFE_UBLOX_GNSS::begin(TwoWire &wirePort, uint8_t deviceAddress)
429429
createFileBuffer();
430430

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

434434
if (!connected)
435-
connected = isConnected();
435+
connected = isConnected(maxWait);
436436

437437
if (!connected)
438-
connected = isConnected();
438+
connected = isConnected(maxWait);
439439

440440
return (connected);
441441
}
442442

443443
//Initialize the Serial port
444-
bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
444+
bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait)
445445
{
446446
commType = COMM_TYPE_SERIAL;
447447
_serialPort = &serialPort; //Grab which port the user wants us to use
@@ -454,19 +454,19 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
454454
createFileBuffer();
455455

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

459459
if (!connected)
460-
connected = isConnected();
460+
connected = isConnected(maxWait);
461461

462462
if (!connected)
463-
connected = isConnected();
463+
connected = isConnected(maxWait);
464464

465465
return (connected);
466466
}
467467

468468
// Initialize for SPI
469-
bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
469+
bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait)
470470
{
471471
commType = COMM_TYPE_SPI;
472472
_spiPort = &spiPort;
@@ -507,13 +507,13 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
507507
}
508508

509509
// Call isConnected up to three times
510-
bool connected = isConnected();
510+
bool connected = isConnected(maxWait);
511511

512512
if (!connected)
513-
connected = isConnected();
513+
connected = isConnected(maxWait);
514514

515515
if (!connected)
516-
connected = isConnected();
516+
connected = isConnected(maxWait);
517517

518518
return (connected);
519519
}

src/SparkFun_u-blox_GNSS_Arduino_Library.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,11 @@ class SFE_UBLOX_GNSS
576576
void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize
577577

578578
//By default use the default I2C address, and use Wire port
579-
bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42); //Returns true if module is detected
579+
bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait); //Returns true if module is detected
580580
//serialPort needs to be perviously initialized to correct baud rate
581-
bool begin(Stream &serialPort); //Returns true if module is detected
581+
bool begin(Stream &serialPort, uint16_t maxWait); //Returns true if module is detected
582582
//SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz)
583-
bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed);
583+
bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait);
584584

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

0 commit comments

Comments
 (0)