mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-19 09:12:45 +00:00
fix millisecond unsigned rollover errors found via portduino
This commit is contained in:
@@ -15,7 +15,10 @@
|
||||
#error ToRadio is too big
|
||||
#endif
|
||||
|
||||
PhoneAPI::PhoneAPI() {}
|
||||
PhoneAPI::PhoneAPI()
|
||||
{
|
||||
lastContactMsec = millis();
|
||||
}
|
||||
|
||||
PhoneAPI::~PhoneAPI()
|
||||
{
|
||||
@@ -53,9 +56,12 @@ void PhoneAPI::close()
|
||||
void PhoneAPI::checkConnectionTimeout()
|
||||
{
|
||||
if (isConnected()) {
|
||||
bool newConnected = (millis() - lastContactMsec < getPref_phone_timeout_secs() * 1000L);
|
||||
if (!newConnected)
|
||||
uint32_t now = millis();
|
||||
bool newContact = (now - lastContactMsec) < getPref_phone_timeout_secs() * 1000UL;
|
||||
if (!newContact) {
|
||||
DEBUG_MSG("Timed out on phone contact, dropping phone connection\n");
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user