diff --git a/examples/OneOpenAir/LocalServer.cpp b/examples/OneOpenAir/LocalServer.cpp index e0b5c98..3f6c463 100644 --- a/examples/OneOpenAir/LocalServer.cpp +++ b/examples/OneOpenAir/LocalServer.cpp @@ -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; } diff --git a/examples/OneOpenAir/LocalServer.h b/examples/OneOpenAir/LocalServer.h index 74c0d61..949f588 100644 --- a/examples/OneOpenAir/LocalServer.h +++ b/examples/OneOpenAir/LocalServer.h @@ -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_ */