OpenDTU/include/WebApi_ws_live.h
Thomas Basler 69b675bc64 BREAKING CHANGE: Structure WebAPI /api/livedata/status changed
The different inverter data are now in a subobject called "inverters".
This is required to extend the API by other data then the inverter values
2022-11-01 15:04:05 +01:00

27 lines
856 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "ArduinoJson.h"
#include <ESPAsyncWebServer.h>
#include <Hoymiles.h>
class WebApiWsLiveClass {
public:
WebApiWsLiveClass();
void init(AsyncWebServer* server);
void loop();
private:
void generateJsonResponse(JsonVariant& root);
void addField(JsonObject& root, uint8_t idx, std::shared_ptr<InverterAbstract> inv, uint8_t channel, uint8_t fieldId, String topic = "");
void onLivedataStatus(AsyncWebServerRequest* request);
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
AsyncWebServer* _server;
AsyncWebSocket _ws;
uint32_t _lastWsPublish = 0;
uint32_t _lastInvUpdateCheck = 0;
uint32_t _lastWsCleanup = 0;
uint32_t _newestInverterTimestamp = 0;
};