Files
OpenDTU/include/WebApi_ws_live.h

28 lines
980 B
C
Raw Normal View History

// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
2022-12-14 22:13:03 +01:00
#include <ArduinoJson.h>
#include <ESPAsyncWebServer.h>
#include <Hoymiles.h>
class WebApiWsLiveClass {
public:
2022-07-20 19:36:07 +02:00
WebApiWsLiveClass();
void init(AsyncWebServer* server);
void loop();
private:
void generateJsonResponse(JsonVariant& root);
void addField(JsonObject& root, uint8_t idx, std::shared_ptr<InverterAbstract> inv, ChannelType_t type, ChannelNum_t channel, FieldId_t fieldId, String topic = "");
void addTotalField(JsonObject& root, String name, float value, String unit, uint8_t digits);
void onLivedataStatus(AsyncWebServerRequest* request);
2022-07-20 19:36:07 +02:00
void onWebsocketEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len);
AsyncWebServer* _server;
AsyncWebSocket _ws;
2022-06-17 13:29:21 +02:00
uint32_t _lastWsPublish = 0;
uint32_t _lastInvUpdateCheck = 0;
uint32_t _lastWsCleanup = 0;
2022-06-17 13:29:21 +02:00
uint32_t _newestInverterTimestamp = 0;
};