diff --git a/platformio_core_defs.ini b/platformio_core_defs.ini index f84afbb06..a4b1ee7ff 100644 --- a/platformio_core_defs.ini +++ b/platformio_core_defs.ini @@ -217,7 +217,7 @@ lib_ignore = ;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1847/framework-arduinoespressif32-release_v5.1-29db12e.zip platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.12.10/platform-espressif32.zip ;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1894/framework-arduinoespressif32-release_v5.1-8f01299.zip -platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1916/framework-arduinoespressif32-release_v5.1-d4d5f8a.zip +platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1917/framework-arduinoespressif32-release_v5.1-d4d5f8a.zip build_flags = -DESP32_STAGE -DESP_IDF_VERSION_MAJOR=5 -DLIBRARIES_NO_LOG=1 diff --git a/platformio_esp32_envs.ini b/platformio_esp32_envs.ini index eacb09199..cb558c0f0 100644 --- a/platformio_esp32_envs.ini +++ b/platformio_esp32_envs.ini @@ -62,7 +62,7 @@ build_flags = ${core_esp32_IDF5_1__3_0_0.build_flags} -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE - -DLWIP_IPV6 + -DLWIP_IPV6=1 monitor_filters = esp32_exception_decoder lib_ignore = ${core_esp32_IDF5_1__3_0_0.lib_ignore} diff --git a/platformio_esp32_solo1.ini b/platformio_esp32_solo1.ini index 659546136..2b22fa358 100644 --- a/platformio_esp32_solo1.ini +++ b/platformio_esp32_solo1.ini @@ -18,7 +18,7 @@ build_unflags = ${esp32_base.build_unflags} ; IDF 5.1.2 [esp32_solo1_common_LittleFS] extends = esp32_base_idf5 -platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1915/framework-arduinoespressif32-solo1-release_v5.1-d4d5f8a.zip +platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1918/framework-arduinoespressif32-solo1-release_v5.1-d4d5f8a.zip build_flags = ${esp32_base_idf5.build_flags} -DFEATURE_ARDUINO_OTA=1 -DUSE_LITTLEFS diff --git a/platformio_esp32s3_envs.ini b/platformio_esp32s3_envs.ini index 6ff40a7f2..6267c2ab8 100644 --- a/platformio_esp32s3_envs.ini +++ b/platformio_esp32s3_envs.ini @@ -145,7 +145,7 @@ build_flags = ${esp32s3_common_LittleFS.build_flags} -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_CUSTOM -DFEATURE_SD=1 -extra_scripts = ${esp32s3_common.extra_scripts} +extra_scripts = ${esp32s3_common_LittleFS.extra_scripts} pre:tools/pio/pre_custom_esp32.py [env:custom_ESP32s3_8M1M_LittleFS_OPI_PSRAM_CDC] @@ -160,7 +160,7 @@ build_flags = ${esp32s3_common_LittleFS.build_flags} -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_MAX_ESP32 -DPLUGIN_BUILD_IR_EXTENDED -extra_scripts = ${esp32_common.extra_scripts} +extra_scripts = ${esp32s3_common_LittleFS.extra_scripts} [env:max_ESP32s3_8M1M_LittleFS_OPI_PSRAM_CDC] @@ -176,7 +176,7 @@ build_flags = ${esp32s3_common_LittleFS.build_flags} -DPLUGIN_BUILD_CUSTOM -DPLUGIN_BUILD_IR_EXTENDED -DFEATURE_SD=1 -extra_scripts = ${esp32s3_common.extra_scripts} +extra_scripts = ${esp32s3_common_LittleFS.extra_scripts} pre:tools/pio/pre_custom_esp32.py [env:custom_ESP32s3_16M8M_LittleFS_OPI_PSRAM_CDC] @@ -192,7 +192,7 @@ build_flags = ${esp32s3_common_LittleFS.build_flags} -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_MAX_ESP32 -DPLUGIN_BUILD_IR_EXTENDED -extra_scripts = ${esp32_common.extra_scripts} +extra_scripts = ${esp32s3_common_LittleFS.extra_scripts} [env:max_ESP32s3_16M8M_LittleFS_OPI_PSRAM_CDC] @@ -203,6 +203,6 @@ build_flags = ${esp32s3_common_LittleFS.build_flags} -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_MAX_ESP32 -DPLUGIN_BUILD_IR_EXTENDED -extra_scripts = ${esp32_common.extra_scripts} +extra_scripts = ${esp32s3_common_LittleFS.extra_scripts} diff --git a/src/src/Commands/Diagnostic.cpp b/src/src/Commands/Diagnostic.cpp index 8ead051dc..98caceacf 100644 --- a/src/src/Commands/Diagnostic.cpp +++ b/src/src/Commands/Diagnostic.cpp @@ -179,26 +179,17 @@ const __FlashStringHelper * Command_JSONPortStatus(struct EventStruct *event, co void createLogPortStatus(std::map::iterator it) { if (loglevelActiveFor(LOG_LEVEL_INFO)) { - String log; - log += F("PortStatus detail: Port="); - log += getPortFromKey(it->first); - log += F(" State="); - log += it->second.getValue(); - log += F(" Output="); - log += it->second.output; - log += F(" Mode="); - log += it->second.mode; - log += F(" Task="); - log += it->second.task; - log += F(" Monitor="); - log += it->second.monitor; - log += F(" Command="); - log += it->second.command; - log += F(" Init="); - log += it->second.init; - log += F(" PreviousTask="); - log += it->second.previousTask; - addLogMove(LOG_LEVEL_INFO, log); + addLogMove(LOG_LEVEL_INFO, strformat( + F("PortStatus detail: Port=%u State=%d Output=%d Mode=%u Task=%u Monitor=%u Command=%d Init=%d PreviousTask=%d"), + getPortFromKey(it->first), + it->second.getValue(), + it->second.output, + it->second.mode, + it->second.task, + it->second.monitor, + it->second.command, + it->second.init, + it->second.previousTask)); } } diff --git a/src/src/Commands/InternalCommands.cpp b/src/src/Commands/InternalCommands.cpp index 2c56a5bda..396ed467b 100644 --- a/src/src/Commands/InternalCommands.cpp +++ b/src/src/Commands/InternalCommands.cpp @@ -309,6 +309,9 @@ bool InternalCommands::executeInternalCommand() case ESPEasy_cmd_e::i2cscanner: COMMAND_CASE_R(Command_i2c_Scanner, -1); // i2c.h case ESPEasy_cmd_e::inc: COMMAND_CASE_A(Command_Rules_Inc, -1); // Rules.h case ESPEasy_cmd_e::ip: COMMAND_CASE_R(Command_IP, 1); // Network Command +#if FEATURE_USE_IPV6 + case ESPEasy_cmd_e::ip6: COMMAND_CASE_R(Command_show_all_IP6, 0); // Network Command +#endif #ifndef BUILD_NO_DIAGNOSTIC_COMMANDS case ESPEasy_cmd_e::jsonportstatus: COMMAND_CASE_A(Command_JSONPortStatus, -1); // Diagnostic.h #endif // ifndef BUILD_NO_DIAGNOSTIC_COMMANDS diff --git a/src/src/Commands/InternalCommands_decoder.cpp b/src/src/Commands/InternalCommands_decoder.cpp index daf935aaa..b3bdb9e26 100644 --- a/src/src/Commands/InternalCommands_decoder.cpp +++ b/src/src/Commands/InternalCommands_decoder.cpp @@ -87,6 +87,9 @@ const char Internal_commands_ghij[] PROGMEM = "i2cscanner|" "inc|" "ip|" +#if FEATURE_USE_IPV6 + "ip6|" +#endif #ifndef BUILD_NO_DIAGNOSTIC_COMMANDS "jsonportstatus|" #endif // ifndef BUILD_NO_DIAGNOSTIC_COMMANDS diff --git a/src/src/Commands/InternalCommands_decoder.h b/src/src/Commands/InternalCommands_decoder.h index 40504720d..b052fd029 100644 --- a/src/src/Commands/InternalCommands_decoder.h +++ b/src/src/Commands/InternalCommands_decoder.h @@ -67,6 +67,9 @@ enum class ESPEasy_cmd_e : uint8_t { i2cscanner, inc, ip, +#if FEATURE_USE_IPV6 + ip6, +#endif #ifndef BUILD_NO_DIAGNOSTIC_COMMANDS jsonportstatus, #endif // ifndef BUILD_NO_DIAGNOSTIC_COMMANDS diff --git a/src/src/Commands/Networks.cpp b/src/src/Commands/Networks.cpp index c5aa1db21..46c7a8d7e 100644 --- a/src/src/Commands/Networks.cpp +++ b/src/src/Commands/Networks.cpp @@ -40,6 +40,29 @@ String Command_IP (struct EventStruct *event, const char* Line) return Command_GetORSetIP(event, F("IP:"), Line, Settings.IP, NetworkLocalIP(),1); } +#if FEATURE_USE_IPV6 +String Command_show_all_IP6 (struct EventStruct *event, const char* Line) +{ + // Only get all IPv6 addresses + IP6Addresses_t addresses = NetworkAllIPv6(); + String res; + res += '['; + bool first = true; + for (auto it = addresses.begin(); it != addresses.end(); ++it) + { + if (first) { + first = false; + } else { + res += ','; + } + res += wrap_String(it->toString(true), '"'); + } + res += ']'; + return res; +} +#endif + + String Command_Subnet (struct EventStruct *event, const char* Line) { return Command_GetORSetIP(event, F("Subnet:"), Line, Settings.Subnet, NetworkSubnetMask(), 1); diff --git a/src/src/Commands/Networks.h b/src/src/Commands/Networks.h index f33f04566..3ef0e8302 100644 --- a/src/src/Commands/Networks.h +++ b/src/src/Commands/Networks.h @@ -9,7 +9,11 @@ String Command_AccessInfo_Clear (struct EventStruct *event, const char* Line); String Command_DNS (struct EventStruct *event, const char* Line); String Command_Gateway (struct EventStruct *event, const char* Line); String Command_IP (struct EventStruct *event, const char* Line); +#if FEATURE_USE_IPV6 +String Command_show_all_IP6 (struct EventStruct *event, const char* Line); +#endif String Command_Subnet (struct EventStruct *event, const char* Line); +#if FEATURE_ETHERNET String Command_ETH_Phy_Addr (struct EventStruct *event, const char* Line); String Command_ETH_Pin_mdc (struct EventStruct *event, const char* Line); String Command_ETH_Pin_mdio (struct EventStruct *event, const char* Line); @@ -22,5 +26,6 @@ String Command_ETH_Subnet (struct EventStruct *event, const char* Line); String Command_ETH_DNS (struct EventStruct *event, const char* Line); String Command_ETH_Wifi_Mode (struct EventStruct *event, const char* Line); String Command_ETH_Disconnect (struct EventStruct *event, const char* Line); +#endif #endif // COMMAND_NETWORKS_H diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 26d04c5fc..d5029dd62 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1088,6 +1088,9 @@ To create/register a plugin, you have to : #define PLUGIN_SET_MAX #define CONTROLLER_SET_ALL #define NOTIFIER_SET_ALL + #ifndef TESTING_FEATURE_USE_IPV6 + #define TESTING_FEATURE_USE_IPV6 + #endif #ifndef PLUGIN_ENERGY_COLLECTION #define PLUGIN_ENERGY_COLLECTION #endif diff --git a/src/src/Helpers/StringConverter.cpp b/src/src/Helpers/StringConverter.cpp index e34c52b4f..e01c58c93 100644 --- a/src/src/Helpers/StringConverter.cpp +++ b/src/src/Helpers/StringConverter.cpp @@ -218,7 +218,11 @@ String formatIP(const IPAddress& ip, bool includeZone) { } #endif */ +#if FEATURE_USE_IPV6 return ip.toString(includeZone); +#else + return ip.toString(); +#endif #endif } @@ -666,6 +670,18 @@ String to_json_value(const String& value, bool wrapInQuotes) { // Empty string return F("\"\""); } + if (value.length() > 2) { + // Check for JSON objects or arrays + const char firstchar = value[0]; + const char lastchar = value[value.length() - 1]; + if ((firstchar == '[' && lastchar == ']') || + (firstchar == '{' && lastchar == '}')) + { + return value; + } + } + + if (wrapInQuotes || mustConsiderAsJSONString(value)) { // Is not a numerical value, or BIN/HEX notation, thus wrap with quotes diff --git a/src/src/Helpers/WebServer_commandHelper.cpp b/src/src/Helpers/WebServer_commandHelper.cpp index 2afdd63b0..abf7cd2e8 100644 --- a/src/src/Helpers/WebServer_commandHelper.cpp +++ b/src/src/Helpers/WebServer_commandHelper.cpp @@ -43,27 +43,41 @@ HandledWebCommand_result handle_command_from_web(EventValueSource::Enum source, eventQueue.addMove(parseStringToEndKeepCase(webrequest, 2)); handledCmd = true; sendOK = true; - } else if (command_e == ESPEasy_cmd_e::taskrun || - command_e == ESPEasy_cmd_e::taskrunat || - command_e == ESPEasy_cmd_e::scheduletaskrun || - command_e == ESPEasy_cmd_e::taskvalueset || - command_e == ESPEasy_cmd_e::taskvaluesetandrun || - command_e == ESPEasy_cmd_e::taskvaluetoggle || - command_e == ESPEasy_cmd_e::let || + } else { + switch (command_e) { + case ESPEasy_cmd_e::taskrun: + case ESPEasy_cmd_e::taskrunat: + case ESPEasy_cmd_e::scheduletaskrun: + case ESPEasy_cmd_e::taskvalueset: + case ESPEasy_cmd_e::taskvaluesetandrun: + case ESPEasy_cmd_e::taskvaluetoggle: + case ESPEasy_cmd_e::let: #ifndef BUILD_NO_DIAGNOSTIC_COMMANDS - command_e == ESPEasy_cmd_e::logportstatus || + case ESPEasy_cmd_e::logportstatus: #endif - command_e == ESPEasy_cmd_e::logentry || + case ESPEasy_cmd_e::logentry: + case ESPEasy_cmd_e::rules: + sendOK = true; + break; #ifndef BUILD_NO_DIAGNOSTIC_COMMANDS - command_e == ESPEasy_cmd_e::jsonportstatus || + case ESPEasy_cmd_e::jsonportstatus: + sendOK = true; + printToWebJSON = true; + break; #endif - command_e == ESPEasy_cmd_e::rules) { - sendOK = true; +#if FEATURE_USE_IPV6 + case ESPEasy_cmd_e::ip6: + sendOK = true; + printToWebJSON = true; + break; +#endif + default: + sendOK = false; + break; + } // handledCmd = true; - } else { - sendOK = false; - } + } if (!handledCmd) { printToWeb = true; handledCmd = ExecuteCommand_internal(source, webrequest.c_str()); @@ -73,11 +87,11 @@ HandledWebCommand_result handle_command_from_web(EventValueSource::Enum source, if (handledCmd) { if (sendOK) { String reply = printWebString.isEmpty() ? F("OK") : printWebString; - removeChar(reply, '\n'); // Don't use newline in JSON. if (printToWebJSON) { + removeChar(reply, '\n'); // Don't use newline in JSON. // Format return string of command to JSON format printWebString = strformat( - F("{\"return\": \"%s\",\"command\": \"%s\"}"), + F("{\"return\": %s,\"command\": %s}"), to_json_value(reply).c_str(), to_json_value(webrequest).c_str()); } else {