ESPSomfy-RTS/src/WResp.h
cjkas dd47c04905 feat: log timings for slow work, socket clients and boot crashes
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>
2026-10-11 20:35:43 +02:00

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