mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-15 23:32:34 +00:00
* feat: add adaptive polling intervals to WebServer Replace fixed 5ms polling with adaptive intervals based on HTTP activity: - 50ms during active periods (first 5 seconds after request) - 200ms during medium activity (5-30 seconds) - 1000ms during idle periods (30+ seconds) Reduces CPU usage significantly during idle periods while maintaining responsiveness when handling HTTP requests. * Fix integer overflow and magic numbers in WebServer - Handle millis() overflow in getAdaptiveInterval() - Replace magic numbers with named constants - Improve code readability and maintainability
27 lines
487 B
C++
27 lines
487 B
C++
#pragma once
|
|
|
|
#include "PhoneAPI.h"
|
|
#include "concurrency/OSThread.h"
|
|
#include <Arduino.h>
|
|
#include <functional>
|
|
|
|
void initWebServer();
|
|
void createSSLCert();
|
|
|
|
class WebServerThread : private concurrency::OSThread
|
|
{
|
|
private:
|
|
uint32_t lastActivityTime = 0;
|
|
|
|
public:
|
|
WebServerThread();
|
|
uint32_t requestRestart = 0;
|
|
void markActivity();
|
|
|
|
protected:
|
|
virtual int32_t runOnce() override;
|
|
int32_t getAdaptiveInterval();
|
|
};
|
|
|
|
extern WebServerThread *webServerThread;
|