ahoy/tools/esp8266/webApi.h
lumapu 6a6d522d3b added login / logout
prepared static IP storage and disable inverter
IMPORTANT: new memory layout, your inverter settings will be lost
2022-11-02 22:41:31 +01:00

76 lines
2.1 KiB
C++

#ifndef __WEB_API_H__
#define __WEB_API_H__
#include "dbg.h"
#ifdef ESP32
#include "AsyncTCP.h"
#else
#include "ESPAsyncTCP.h"
#endif
#include "ESPAsyncWebServer.h"
#include "AsyncJson.h"
#include "app.h"
class app;
class webApi {
public:
webApi(AsyncWebServer *srv, app *app, sysConfig_t *sysCfg, config_t *config, statistics_t *stat, char version[]);
void setup(void);
void loop(void);
uint32_t getTimezoneOffset() {
return mTimezoneOffset;
}
private:
void onApi(AsyncWebServerRequest *request);
void onApiPost(AsyncWebServerRequest *request);
void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total);
void getNotFound(JsonObject obj, String url);
void onDwnldSetup(AsyncWebServerRequest *request);
void getSysInfo(JsonObject obj);
void getSystem(JsonObject obj);
void getLogout(JsonObject obj);
void getSave(JsonObject obj);
void getReboot(JsonObject obj);
void getStatistics(JsonObject obj);
void getInverterList(JsonObject obj);
void getMqtt(JsonObject obj);
void getNtp(JsonObject obj);
void getSun(JsonObject obj);
void getPinout(JsonObject obj);
void getRadio(JsonObject obj);
void getSerial(JsonObject obj);
void getMenu(JsonObject obj);
void getIndex(JsonObject obj);
void getSetup(JsonObject obj);
void getNetworks(JsonObject obj);
void getLive(JsonObject obj);
void getRecord(JsonObject obj, record_t<> *rec);
bool setCtrl(JsonObject jsonIn, JsonObject jsonOut);
bool setSetup(JsonObject jsonIn, JsonObject jsonOut);
Inverter<> *getInverter(JsonObject jsonIn, JsonObject jsonOut);
double round3(double value) {
return (int)(value * 1000 + 0.5) / 1000.0;
}
AsyncWebServer *mSrv;
app *mApp;
config_t *mConfig;
sysConfig_t *mSysCfg;
statistics_t *mStat;
char *mVersion;
uint32_t mTimezoneOffset;
};
#endif /*__WEB_API_H__*/