From 4f47712d520b44dd6495a80668649b97bd4ecad2 Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 20 Oct 2021 09:21:03 +0200 Subject: [PATCH] minor formatting --- src/system.cpp | 6 ++++-- src/web/WebAPIService.cpp | 8 ++++---- src/web/WebAPIService.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index 2b8f1dfa7..ace9e2720 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -674,14 +674,16 @@ void System::commands_init() { Command::add(EMSdevice::DeviceType::SYSTEM, F_(publish), System::command_publish, F("force a MQTT publish"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, F("refresh all EMS values"), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, F("restarts EMS-ESP"), CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, F("watch incoming telegrams"), CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog_level), System::command_syslog_level, F("set syslog level"), CommandFlag::ADMIN_ONLY); + Command::add_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, F("system status")); Command::add_json(EMSdevice::DeviceType::SYSTEM, F_(settings), System::command_settings, F("list system settings")); Command::add_json(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, F("list system commands")); + #if defined(EMSESP_DEBUG) Command::add(EMSdevice::DeviceType::SYSTEM, F("test"), System::command_test, F("run tests")); #endif - Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, F("watch incoming telegrams"), CommandFlag::ADMIN_ONLY); - Command::add(EMSdevice::DeviceType::SYSTEM, F_(syslog_level), System::command_syslog_level, F("set syslog level"), CommandFlag::ADMIN_ONLY); } // flashes the LED diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index bfd923025..48638b808 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -237,22 +237,22 @@ void WebAPIService::parse(AsyncWebServerRequest * request, std::string & device_ } // send a HTTP error back, with optional JSON body data -void WebAPIService::send_message_response(AsyncWebServerRequest * request, uint16_t error_code, const char * error_message) { - if (error_message == nullptr) { +void WebAPIService::send_message_response(AsyncWebServerRequest * request, uint16_t error_code, const char * message) { + if (message == nullptr) { AsyncWebServerResponse * response = request->beginResponse(error_code); // just send the code request->send(response); } else { // build a return message and send it PrettyAsyncJsonResponse * response = new PrettyAsyncJsonResponse(false, EMSESP_JSON_SIZE_SMALL); JsonObject json = response->getRoot(); - json["message"] = error_message; + json["message"] = message; response->setCode(error_code); response->setLength(); response->setContentType("application/json"); request->send(response); } - EMSESP::logger().debug(F("API return code: %d, message: %s"), error_code, error_message); + EMSESP::logger().debug(F("API return code: %d, message: %s"), error_code, message); } /** diff --git a/src/web/WebAPIService.h b/src/web/WebAPIService.h index 97f03f972..94cf5a32a 100644 --- a/src/web/WebAPIService.h +++ b/src/web/WebAPIService.h @@ -68,7 +68,7 @@ class WebAPIService { AsyncCallbackJsonWebHandler _apiHandler; // for POSTs void parse(AsyncWebServerRequest * request, std::string & device, std::string & cmd, int id, std::string & value); - void send_message_response(AsyncWebServerRequest * request, uint16_t error_code, const char * error_message = nullptr); + void send_message_response(AsyncWebServerRequest * request, uint16_t error_code, const char * message = nullptr); }; } // namespace emsesp