mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-29 16:37:17 +02:00
Local server to get local storage measurements
This commit is contained in:
@ -13,6 +13,10 @@ bool LocalServer::begin(void) {
|
||||
server.on(openMetrics.getApi(), HTTP_GET, [this]() { _GET_metrics(); });
|
||||
server.on("/config", HTTP_GET, [this]() { _GET_config(); });
|
||||
server.on("/config", HTTP_PUT, [this]() { _PUT_config(); });
|
||||
server.on("/storage", HTTP_GET, [this]() {
|
||||
Serial.println(server.arg("time"));
|
||||
_GET_storage();
|
||||
});
|
||||
server.begin();
|
||||
|
||||
if (xTaskCreate(
|
||||
@ -68,4 +72,15 @@ void LocalServer::_GET_measure(void) {
|
||||
server.send(200, "application/json", toSend);
|
||||
}
|
||||
|
||||
void LocalServer::_GET_storage(void) {
|
||||
char *data = measure.getLocalStorage();
|
||||
if (data != nullptr) {
|
||||
server.sendHeader("Content-Disposition", "attachment; filename=\"measurements.csv\"");
|
||||
server.send(200, "text/plain", data);
|
||||
free(data);
|
||||
} else {
|
||||
server.send(200, "text/plain", "No data");
|
||||
}
|
||||
}
|
||||
|
||||
void LocalServer::setFwMode(AgFirmwareMode fwMode) { this->fwMode = fwMode; }
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void _PUT_config(void);
|
||||
void _GET_metrics(void);
|
||||
void _GET_measure(void);
|
||||
void _GET_storage(void);
|
||||
};
|
||||
|
||||
#endif /** _LOCAL_SERVER_H_ */
|
||||
|
Reference in New Issue
Block a user