move sleep wake timeout to PhoneAPI

This commit is contained in:
m1nl 2025-04-24 16:52:24 +02:00
parent 5745c4ecf2
commit 802c2fa7ae
2 changed files with 5 additions and 7 deletions

View File

@ -20,6 +20,7 @@
#define SPECIAL_NONCE_ONLY_CONFIG 69420
#define SPECIAL_NONCE_ONLY_NODES 69421 // ( ͡° ͜ʖ ͡°)
#define WAKE_SESSION_TIMEOUT_MS 10000
/**
* Provides our protobuf based API which phone/PC clients can use to talk to our device
@ -173,8 +174,8 @@ class PhoneAPI
/// If the mesh service tells us fromNum has changed, tell the phone
virtual int onNotify(uint32_t newValue) override;
int preflightSleepCb(void *unused = NULL) { return available(); }
int preflightSleepCb(void *unused = NULL) { return available() && (millis() - lastContactMsec) < WAKE_SESSION_TIMEOUT_MS; }
CallbackObserver<PhoneAPI, void *> preflightSleepObserver =
CallbackObserver<PhoneAPI, void *>(this, &PhoneAPI::preflightSleepCb);
};
};

View File

@ -1,7 +1,4 @@
#pragma once
#define HTTP_API_SESSION_TIMEOUT_MS 5000
void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer);
// Declare some handler functions for the various URLs on the server
@ -36,5 +33,5 @@ class HttpAPI : public PhoneAPI
protected:
/// Check the current underlying physical link to see if the client is currently connected
virtual bool checkIsConnected() override { return millis() - lastContactMsec < HTTP_API_SESSION_TIMEOUT_MS; }
};
virtual bool checkIsConnected() override { return true; } // FIXME, be smarter about this
};