Skip to content

Commit 67fe9db

Browse files
authored
Merge pull request #89 from sparkfun/maxWaitBegin
Add maxWait to begin functions
2 parents 78df56c + d47d02a commit 67fe9db

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
@@ -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)
442442
{
443443
commType = COMM_TYPE_I2C;
444444
_i2cPort = &wirePort; //Grab which port the user wants us to use
@@ -461,19 +461,19 @@ 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+
connected = isConnected(maxWait);
468468

469469
if (!connected)
470-
connected = isConnected();
470+
connected = isConnected(maxWait);
471471

472472
return (connected);
473473
}
474474

475475
//Initialize the Serial port
476-
bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
476+
bool SFE_UBLOX_GNSS::begin(Stream &serialPort, uint16_t maxWait)
477477
{
478478
commType = COMM_TYPE_SERIAL;
479479
_serialPort = &serialPort; //Grab which port the user wants us to use
@@ -486,19 +486,19 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
486486
createFileBuffer();
487487

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

491491
if (!connected)
492-
connected = isConnected();
492+
connected = isConnected(maxWait);
493493

494494
if (!connected)
495-
connected = isConnected();
495+
connected = isConnected(maxWait);
496496

497497
return (connected);
498498
}
499499

500500
// Initialize for SPI
501-
bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
501+
bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait)
502502
{
503503
commType = COMM_TYPE_SPI;
504504
_spiPort = &spiPort;
@@ -539,13 +539,13 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
539539
}
540540

541541
// Call isConnected up to three times
542-
bool connected = isConnected();
542+
bool connected = isConnected(maxWait);
543543

544544
if (!connected)
545-
connected = isConnected();
545+
connected = isConnected(maxWait);
546546

547547
if (!connected)
548-
connected = isConnected();
548+
connected = isConnected(maxWait);
549549

550550
return (connected);
551551
}

src/SparkFun_u-blox_GNSS_Arduino_Library.h

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

601601
//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
602+
bool begin(TwoWire &wirePort = Wire, uint8_t deviceAddress = 0x42, uint16_t maxWait = 1100); //Returns true if module is detected
603603
//serialPort needs to be perviously initialized to correct baud rate
604-
bool begin(Stream &serialPort); //Returns true if module is detected
604+
bool begin(Stream &serialPort, uint16_t maxWait = 1100); //Returns true if module is detected
605605
//SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz)
606-
bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed);
606+
bool begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed, uint16_t maxWait = 1100);
607607

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

0 commit comments

Comments
 (0)