mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-29 07:36:46 +00:00
Merge branch 'multi-message-Storage' of https://github.com/meshtastic/firmware into multi-message-Storage
This commit is contained in:
commit
9f62007d94
@ -148,6 +148,8 @@ void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer)
|
|||||||
|
|
||||||
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
|
void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
|
if (webServerThread)
|
||||||
|
webServerThread->markActivity();
|
||||||
|
|
||||||
LOG_DEBUG("webAPI handleAPIv1FromRadio");
|
LOG_DEBUG("webAPI handleAPIv1FromRadio");
|
||||||
|
|
||||||
@ -391,6 +393,9 @@ void handleFsDeleteStatic(HTTPRequest *req, HTTPResponse *res)
|
|||||||
|
|
||||||
void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
void handleStatic(HTTPRequest *req, HTTPResponse *res)
|
||||||
{
|
{
|
||||||
|
if (webServerThread)
|
||||||
|
webServerThread->markActivity();
|
||||||
|
|
||||||
// Get access to the parameters
|
// Get access to the parameters
|
||||||
ResourceParameters *params = req->getParams();
|
ResourceParameters *params = req->getParams();
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,12 @@ Preferences prefs;
|
|||||||
using namespace httpsserver;
|
using namespace httpsserver;
|
||||||
#include "mesh/http/ContentHandler.h"
|
#include "mesh/http/ContentHandler.h"
|
||||||
|
|
||||||
|
static const uint32_t ACTIVE_THRESHOLD_MS = 5000;
|
||||||
|
static const uint32_t MEDIUM_THRESHOLD_MS = 30000;
|
||||||
|
static const int32_t ACTIVE_INTERVAL_MS = 50;
|
||||||
|
static const int32_t MEDIUM_INTERVAL_MS = 200;
|
||||||
|
static const int32_t IDLE_INTERVAL_MS = 1000;
|
||||||
|
|
||||||
static SSLCert *cert;
|
static SSLCert *cert;
|
||||||
static HTTPSServer *secureServer;
|
static HTTPSServer *secureServer;
|
||||||
static HTTPServer *insecureServer;
|
static HTTPServer *insecureServer;
|
||||||
@ -175,6 +181,32 @@ WebServerThread::WebServerThread() : concurrency::OSThread("WebServer")
|
|||||||
if (!config.network.wifi_enabled && !config.network.eth_enabled) {
|
if (!config.network.wifi_enabled && !config.network.eth_enabled) {
|
||||||
disable();
|
disable();
|
||||||
}
|
}
|
||||||
|
lastActivityTime = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebServerThread::markActivity()
|
||||||
|
{
|
||||||
|
lastActivityTime = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t WebServerThread::getAdaptiveInterval()
|
||||||
|
{
|
||||||
|
uint32_t currentTime = millis();
|
||||||
|
uint32_t timeSinceActivity;
|
||||||
|
|
||||||
|
if (currentTime >= lastActivityTime) {
|
||||||
|
timeSinceActivity = currentTime - lastActivityTime;
|
||||||
|
} else {
|
||||||
|
timeSinceActivity = (UINT32_MAX - lastActivityTime) + currentTime + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeSinceActivity < ACTIVE_THRESHOLD_MS) {
|
||||||
|
return ACTIVE_INTERVAL_MS;
|
||||||
|
} else if (timeSinceActivity < MEDIUM_THRESHOLD_MS) {
|
||||||
|
return MEDIUM_INTERVAL_MS;
|
||||||
|
} else {
|
||||||
|
return IDLE_INTERVAL_MS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t WebServerThread::runOnce()
|
int32_t WebServerThread::runOnce()
|
||||||
@ -189,8 +221,7 @@ int32_t WebServerThread::runOnce()
|
|||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop every 5ms.
|
return getAdaptiveInterval();
|
||||||
return (5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initWebServer()
|
void initWebServer()
|
||||||
|
|||||||
@ -10,13 +10,17 @@ void createSSLCert();
|
|||||||
|
|
||||||
class WebServerThread : private concurrency::OSThread
|
class WebServerThread : private concurrency::OSThread
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
uint32_t lastActivityTime = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WebServerThread();
|
WebServerThread();
|
||||||
uint32_t requestRestart = 0;
|
uint32_t requestRestart = 0;
|
||||||
|
void markActivity();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
int32_t getAdaptiveInterval();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WebServerThread *webServerThread;
|
extern WebServerThread *webServerThread;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user