mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-12 23:51:39 +02:00
parent
1bc3a0f06f
commit
972b03376b
4 changed files with 32 additions and 11 deletions
|
@ -1,5 +1,8 @@
|
||||||
# Development Changes
|
# Development Changes
|
||||||
|
|
||||||
|
## 0.8.8 - 2023-11-16
|
||||||
|
* fix ESP8266 save inverter #1232
|
||||||
|
|
||||||
## 0.8.7 - 2023-11-13
|
## 0.8.7 - 2023-11-13
|
||||||
* fix ESP8266 inverter settings #1226
|
* fix ESP8266 inverter settings #1226
|
||||||
* send radio statistics via MqTT #1227
|
* send radio statistics via MqTT #1227
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 8
|
#define VERSION_MINOR 8
|
||||||
#define VERSION_PATCH 7
|
#define VERSION_PATCH 8
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -124,12 +124,26 @@ class RestApi {
|
||||||
|
|
||||||
void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
|
void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
|
||||||
DPRINTLN(DBG_VERBOSE, "onApiPostBody");
|
DPRINTLN(DBG_VERBOSE, "onApiPostBody");
|
||||||
DynamicJsonDocument json(800);
|
|
||||||
|
if(0 == index) {
|
||||||
|
if(NULL != mTmpBuf)
|
||||||
|
delete[] mTmpBuf;
|
||||||
|
mTmpBuf = new uint8_t[total+1];
|
||||||
|
mTmpSize = total;
|
||||||
|
}
|
||||||
|
if(mTmpSize >= (len + index))
|
||||||
|
memcpy(&mTmpBuf[index], data, len);
|
||||||
|
|
||||||
|
if((len + index) != total)
|
||||||
|
return; // not last frame - nothing to do
|
||||||
|
|
||||||
|
DynamicJsonDocument json(1000);
|
||||||
|
|
||||||
|
DeserializationError err = deserializeJson(json, (const char *)mTmpBuf, mTmpSize);
|
||||||
|
JsonObject obj = json.as<JsonObject>();
|
||||||
|
|
||||||
AsyncJsonResponse* response = new AsyncJsonResponse(false, 200);
|
AsyncJsonResponse* response = new AsyncJsonResponse(false, 200);
|
||||||
JsonObject root = response->getRoot();
|
JsonObject root = response->getRoot();
|
||||||
|
|
||||||
DeserializationError err = deserializeJson(json, (const char *)data, len);
|
|
||||||
JsonObject obj = json.as<JsonObject>();
|
|
||||||
root[F("success")] = (err) ? false : true;
|
root[F("success")] = (err) ? false : true;
|
||||||
if(!err) {
|
if(!err) {
|
||||||
String path = request->url().substring(5);
|
String path = request->url().substring(5);
|
||||||
|
@ -141,10 +155,10 @@ class RestApi {
|
||||||
root[F("success")] = false;
|
root[F("success")] = false;
|
||||||
root[F("error")] = "Path not found: " + path;
|
root[F("error")] = "Path not found: " + path;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
switch (err.code()) {
|
switch (err.code()) {
|
||||||
case DeserializationError::Ok: break;
|
case DeserializationError::Ok: break;
|
||||||
|
case DeserializationError::IncompleteInput: root[F("error")] = F("Incomplete input"); break;
|
||||||
case DeserializationError::InvalidInput: root[F("error")] = F("Invalid input"); break;
|
case DeserializationError::InvalidInput: root[F("error")] = F("Invalid input"); break;
|
||||||
case DeserializationError::NoMemory: root[F("error")] = F("Not enough memory"); break;
|
case DeserializationError::NoMemory: root[F("error")] = F("Not enough memory"); break;
|
||||||
default: root[F("error")] = F("Deserialization failed"); break;
|
default: root[F("error")] = F("Deserialization failed"); break;
|
||||||
|
@ -153,6 +167,8 @@ class RestApi {
|
||||||
|
|
||||||
response->setLength();
|
response->setLength();
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
delete[] mTmpBuf;
|
||||||
|
mTmpBuf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getNotFound(JsonObject obj, String url) {
|
void getNotFound(JsonObject obj, String url) {
|
||||||
|
@ -760,6 +776,8 @@ class RestApi {
|
||||||
uint32_t mTimezoneOffset;
|
uint32_t mTimezoneOffset;
|
||||||
uint32_t mHeapFree, mHeapFreeBlk;
|
uint32_t mHeapFree, mHeapFreeBlk;
|
||||||
uint8_t mHeapFrag;
|
uint8_t mHeapFrag;
|
||||||
|
uint8_t *mTmpBuf = NULL;
|
||||||
|
uint32_t mTmpSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__WEB_API_H__*/
|
#endif /*__WEB_API_H__*/
|
||||||
|
|
|
@ -798,7 +798,7 @@
|
||||||
function cb(obj) {
|
function cb(obj) {
|
||||||
var e = document.getElementById("res");
|
var e = document.getElementById("res");
|
||||||
if(!obj.success)
|
if(!obj.success)
|
||||||
e.innerHTML = "error while saving";
|
e.innerHTML = "error: " + obj.error;
|
||||||
else {
|
else {
|
||||||
modalClose();
|
modalClose();
|
||||||
getAjax("/api/inverter/list", parseIv);
|
getAjax("/api/inverter/list", parseIv);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue