Browse Source

0.7.13

* add date, time and version to export json #1024
pull/1048/head
lumapu 2 years ago
parent
commit
308dc064fe
  1. 1
      src/CHANGES.md
  2. 2
      src/app.cpp
  3. 2
      src/platformio.ini
  4. 9
      src/utils/helper.cpp
  5. 1
      src/utils/helper.h
  6. 5
      src/web/RestApi.h

1
src/CHANGES.md

@ -2,6 +2,7 @@
## 0.7.13 - 2023-07-19
* merged display PR #1027
* add date, time and version to export json #1024
## 0.7.12 - 2023-07-09
* added inverter status - state-machine #1016

2
src/app.cpp

@ -330,7 +330,7 @@ void app::tickMinute(void) {
// only triggered if 'reset values on no avail is enabled'
zeroIvValues(true);
}
}
//-----------------------------------------------------------------------------
void app::tickMidnight(void) {

2
src/platformio.ini

@ -26,7 +26,7 @@ lib_deps =
https://github.com/yubox-node-org/ESPAsyncWebServer
nrf24/RF24 @ 1.4.5
paulstoffregen/Time @ ^1.6.1
https://github.com/bertmelis/espMqttClient#v1.4.4
https://github.com/bertmelis/espMqttClient#v1.4.2
bblanchon/ArduinoJson @ ^6.21.2
https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.34.17

9
src/utils/helper.cpp

@ -41,6 +41,15 @@ namespace ah {
return String(str);
}
String getDateTimeStrFile(time_t t) {
char str[20];
if(0 == t)
sprintf(str, "na");
else
sprintf(str, "%04d-%02d-%02d_%02d-%02d-%02d", year(t), month(t), day(t), hour(t), minute(t), second(t));
return String(str);
}
String getTimeStr(time_t t) {
char str[9];
if(0 == t)

1
src/utils/helper.h

@ -41,6 +41,7 @@ namespace ah {
void ip2Char(uint8_t ip[], char *str);
double round3(double value);
String getDateTimeStr(time_t t);
String getDateTimeStrFile(time_t t);
String getTimeStr(time_t t);
uint64_t Serial2u64(const char *val);
void dumpBuf(uint8_t buf[], uint8_t len);

5
src/web/RestApi.h

@ -184,9 +184,12 @@ class RestApi {
response = request->beginResponse(200, F("application/json; charset=utf-8"), tmp);
}
String filename = ah::getDateTimeStrFile(mApp->getTimezoneOffset());
filename += "_v" + String(mApp->getVersion());
response->addHeader("Content-Type", "application/octet-stream");
response->addHeader("Content-Description", "File Transfer");
response->addHeader("Content-Disposition", "attachment; filename=ahoy_setup.json");
response->addHeader("Content-Disposition", "attachment; filename=" + filename + "_ahoy_setup.json");
request->send(response);
fp.close();
}

Loading…
Cancel
Save