Move SPI buffer new (memory allocation) to before isConnected

This commit is contained in:
PaulZC
2021-06-28 10:59:57 +01:00
parent 1e479b9ad3
commit 2c35e729e7
+10 -9
View File
@@ -469,15 +469,6 @@ boolean SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpee
createFileBuffer();
// Call isConnected up to three times
boolean connected = isConnected();
if (!connected)
connected = isConnected();
if (!connected)
connected = isConnected();
//Create the SPI buffer
if (spiBuffer == NULL) //Memory has not yet been allocated - so use new
{
@@ -489,6 +480,7 @@ boolean SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpee
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
{
_debugSerial->print(F("begin (SPI): memory allocation failed for SPI Buffer!"));
return (false);
}
}
else
@@ -500,6 +492,15 @@ boolean SFE_UBLOX_GNSS::begin(SPIClass &spiPort, uint8_t csPin, uint32_t spiSpee
}
}
// Call isConnected up to three times
boolean connected = isConnected();
if (!connected)
connected = isConnected();
if (!connected)
connected = isConnected();
return (connected);
}