mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-28 17:49:08 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev
This commit is contained in:
@@ -144,6 +144,8 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
|
||||
return;
|
||||
}
|
||||
|
||||
api_count_++;
|
||||
|
||||
// send the json that came back from the command call
|
||||
// sequence matches CommandRet in command.h (FAIL, OK, NOT_FOUND, ERROR, NOT_ALLOWED, INVALID, NO_VALUE)
|
||||
// 400 (bad request)
|
||||
@@ -153,16 +155,23 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
|
||||
// 400 (invalid)
|
||||
int ret_codes[7] = {400, 200, 404, 400, 401, 400, 404};
|
||||
|
||||
response->setCode(ret_codes[return_code]);
|
||||
response->setLength();
|
||||
response->setContentType("application/json; charset=utf-8");
|
||||
request->send(response);
|
||||
api_count_++;
|
||||
// serialize JSON to string to ensure correct content-length and avoid HTTP parsing errors (issue #2752)
|
||||
std::string output_str;
|
||||
serializeJson(output, output_str);
|
||||
request->send(ret_codes[return_code], "application/json; charset=utf-8", output_str.c_str());
|
||||
// std::string output_str;
|
||||
// serializeJson(output, output_str);
|
||||
// request->send(ret_codes[return_code], "application/json; charset=utf-8", output_str.c_str());
|
||||
|
||||
#if defined(EMSESP_UNITY)
|
||||
// store the result so we can test with Unity later
|
||||
storeResponse(output);
|
||||
#endif
|
||||
#if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
|
||||
std::string output_str;
|
||||
serializeJson(output, output_str);
|
||||
Serial.printf("%sweb output: %s[%s] %s(%d)%s %s%s",
|
||||
COLOR_WHITE,
|
||||
COLOR_BRIGHT_CYAN,
|
||||
@@ -175,9 +184,6 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
|
||||
Serial.println();
|
||||
EMSESP::logger().debug("web output: %s %s", request->url().c_str(), output_str.c_str());
|
||||
#endif
|
||||
|
||||
api_count_++;
|
||||
delete response;
|
||||
}
|
||||
|
||||
#if defined(EMSESP_UNITY)
|
||||
|
||||
@@ -429,7 +429,7 @@ void WebSettings::set_board_profile(WebSettings & settings) {
|
||||
|
||||
// load the board profile into the data vector
|
||||
// 0=led, 1=dallas, 2=rx, 3=tx, 4=button, 5=phy_type, 6=eth_power, 7=eth_phy_addr, 8=eth_clock_mode, 9=led_type
|
||||
std::vector<int8_t> data(10, 0); // initialize with 0 for all values
|
||||
std::vector<int8_t> data(10, 99); // initialize with 99 for all values, just as a safe guard to catch bad gpios
|
||||
if (settings.board_profile != "default") {
|
||||
if (!System::load_board_profile(data, settings.board_profile.c_str())) {
|
||||
#if defined(EMSESP_DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user