Add maxWait to begin functions

This commit is contained in:
Nathan Seidle
2021-12-08 14:00:03 -07:00
parent 7c7c8c24f6
commit ec4a7c4a37
2 changed files with 15 additions and 15 deletions
+12 -12
View File
@@ -406,7 +406,7 @@ void SFE_UBLOX_GNSS::setPacketCfgPayloadSize(size_t payloadSize)
} }
//Initialize the I2C port //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; commType = COMM_TYPE_I2C;
_i2cPort = &wirePort; //Grab which port the user wants us to use _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)
createFileBuffer(); createFileBuffer();
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored // 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) if (!connected)
connected = isConnected(); connected = isConnected(maxWait);
if (!connected) if (!connected)
connected = isConnected(); connected = isConnected(maxWait);
return (connected); return (connected);
} }
//Initialize the Serial port //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; commType = COMM_TYPE_SERIAL;
_serialPort = &serialPort; //Grab which port the user wants us to use _serialPort = &serialPort; //Grab which port the user wants us to use
@@ -454,19 +454,19 @@ bool SFE_UBLOX_GNSS::begin(Stream &serialPort)
createFileBuffer(); createFileBuffer();
// Call isConnected up to three times - tests on the NEO-M8U show the CFG RATE poll occasionally being ignored // 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) if (!connected)
connected = isConnected(); connected = isConnected(maxWait);
if (!connected) if (!connected)
connected = isConnected(); connected = isConnected(maxWait);
return (connected); return (connected);
} }
// Initialize for SPI // 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; commType = COMM_TYPE_SPI;
_spiPort = &spiPort; _spiPort = &spiPort;
@@ -507,13 +507,13 @@ bool SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpeed)
} }
// Call isConnected up to three times // Call isConnected up to three times
bool connected = isConnected(); bool connected = isConnected(maxWait);
if (!connected) if (!connected)
connected = isConnected(); connected = isConnected(maxWait);
if (!connected) if (!connected)
connected = isConnected(); connected = isConnected(maxWait);
return (connected); return (connected);
} }
+3 -3
View File
@@ -576,11 +576,11 @@ public:
void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize void setPacketCfgPayloadSize(size_t payloadSize); // Set packetCfgPayloadSize
//By default use the default I2C address, and use Wire port //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); //Returns true if module is detected
//serialPort needs to be perviously initialized to correct baud rate //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); //Returns true if module is detected
//SPI - supply instance of SPIClass, chip select pin and SPI speed (in Hz) //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);
void end(void); //Stop all automatic message processing. Free all used RAM void end(void); //Stop all automatic message processing. Free all used RAM