mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
Add Timing.h and use it to log what holds up the main loop, how long a new socket client's setup takes, slow socket sends, and how long each web request took and from which client. Socket connects and disconnects are logged with how long the client stayed, and late pings as warnings. Routine sends and pings are not logged, as each line costs several ms on a 115200 baud console. Report a stored crash once with the crashed and running build IDs, then erase it, since it was reported on every boot and its backtrace only decodes against the build that crashed. Mount the file system once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
856 B
C++
28 lines
856 B
C++
#include <ESPAsyncWebServer.h>
|
|
#include "Somfy.h"
|
|
#ifndef wresp_h
|
|
#define wresp_h
|
|
#include "JsonFormatter.h"
|
|
|
|
class AsyncJsonResp : public JsonFormatter {
|
|
protected:
|
|
void _safecat(const char *val, bool escape = false) override;
|
|
AsyncWebServerRequest *_request = nullptr;
|
|
AsyncResponseStream *_stream = nullptr;
|
|
public:
|
|
void beginResponse(AsyncWebServerRequest *request, char *buff, size_t buffSize);
|
|
void endResponse();
|
|
void flush();
|
|
};
|
|
class JsonSockEvent : public JsonFormatter {
|
|
protected:
|
|
bool _closed = false;
|
|
const char *_evt = "";
|
|
void _safecat(const char *val, bool escape = false) override;
|
|
public:
|
|
AsyncWebSocket *server = nullptr;
|
|
void beginEvent(AsyncWebSocket *server, const char *evt, char *buff, size_t buffSize);
|
|
void endEvent(uint32_t clientId = 0);
|
|
void closeEvent();
|
|
};
|
|
#endif
|