@@ -1048,10 +1048,16 @@ const char *DevUBLOXGNSS::statusString(sfe_ublox_status_e stat)
10481048}
10491049
10501050// Check for the arrival of new I2C/Serial/SPI data
1051-
10521051// Called regularly to check for available bytes on the user' specified port
1052+
1053+ void DevUBLOXGNSS::lockCheckUblox(void) { if (_enableCheckUbloxLock) _checkUbloxLock = true; }
1054+ void DevUBLOXGNSS::unlockCheckUblox(void) { _checkUbloxLock = false; }
1055+
10531056bool DevUBLOXGNSS::checkUblox(uint8_t requestedClass, uint8_t requestedID)
10541057{
1058+ if (_checkUbloxLock)
1059+ return false;
1060+
10551061 return checkUbloxInternal(&packetCfg, requestedClass, requestedID);
10561062}
10571063
@@ -4621,6 +4627,8 @@ void DevUBLOXGNSS::addToChecksum(uint8_t incoming)
46214627// Given a packet and payload, send everything including CRC bytes via I2C port
46224628sfe_ublox_status_e DevUBLOXGNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t maxWait, bool expectACKonly)
46234629{
4630+ lockCheckUblox();
4631+
46244632 if (!lock()) return SFE_UBLOX_STATUS_FAIL;
46254633
46264634 sfe_ublox_status_e retVal = SFE_UBLOX_STATUS_SUCCESS;
@@ -4646,6 +4654,8 @@ sfe_ublox_status_e DevUBLOXGNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t ma
46464654 _debugSerial.println(F("Send I2C Command failed"));
46474655 }
46484656#endif
4657+ unlock();
4658+ unlockCheckUblox();
46494659 return retVal;
46504660 }
46514661 }
@@ -4688,6 +4698,9 @@ sfe_ublox_status_e DevUBLOXGNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t ma
46884698 {
46894699 processSpiBuffer(&packetCfg, 0, 0); // Process any SPI data received during the sendSpiCommand - but only if not checking for a response
46904700 }
4701+
4702+ unlockCheckUblox();
4703+
46914704 return retVal;
46924705}
46934706
0 commit comments