🎐 Makes analytics a part of system service
This commit is contained in:
@@ -4,6 +4,9 @@ namespace system_service {
|
||||
|
||||
static const char *TAG = "SystemService";
|
||||
|
||||
static JsonDocument analyticsDoc;
|
||||
static char analyticsMessage[MAX_ESP_ANALYTICS_SIZE];
|
||||
|
||||
esp_err_t handleReset(PsychicRequest *request) {
|
||||
reset();
|
||||
return request->reply(200);
|
||||
@@ -132,6 +135,15 @@ void metrics(JsonObject &root) {
|
||||
}
|
||||
}
|
||||
|
||||
void emitMetrics() {
|
||||
if (!socket.hasSubscribers(EVENT_ANALYTICS)) return;
|
||||
analyticsDoc.clear();
|
||||
JsonObject root = analyticsDoc.to<JsonObject>();
|
||||
system_service::metrics(root);
|
||||
serializeJson(analyticsDoc, analyticsMessage);
|
||||
socket.emit(EVENT_ANALYTICS, analyticsMessage);
|
||||
}
|
||||
|
||||
const char *resetReason(int reason) {
|
||||
switch (reason) {
|
||||
case 1: return "Vbat power on reset";
|
||||
|
||||
Reference in New Issue
Block a user