OpenDTU-old/include/WebApi_database.h
Ralf Bauer 1c07249b2c Added database feature.
The database ist stored persistently on LittleFS.
The AC total energy is written every hour to the database, together with a timestamp.
Each entry to the database requires 8 bytes on the LittleFS partition.
The database can be read with the API call /api/database

Ralf Bauer
2023-05-19 11:07:49 +02:00

28 lines
522 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#define DATABASE_FILENAME "/database.bin"
class WebApiDatabaseClass {
public:
void init(AsyncWebServer* server);
void loop();
bool write(float energy);
struct Data {
uint8_t tm_year;
uint8_t tm_mon;
uint8_t tm_mday;
uint8_t tm_hour;
float energy;
};
private:
void onDatabase(AsyncWebServerRequest* request);
AsyncWebServer* _server;
};