Skip to content

Commit

Permalink
Merge pull request #4932 from TD-er/bugfix/ESP32_factoryDefaults
Browse files Browse the repository at this point in the history
Bugfix/esp32 factory defaults
  • Loading branch information
TD-er authored Jan 18, 2024
2 parents 5e677f7 + 67f0f70 commit e015d1b
Show file tree
Hide file tree
Showing 52 changed files with 1,617 additions and 1,135 deletions.
2 changes: 1 addition & 1 deletion boards/esp32_4M.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"memory_type": "dio_qspi"
},
"core": "esp32",
"extra_flags": "-DARDUINO_ESP32_DEV -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT=0 -DESP32_4M -DESP32_CLASSIC",
"extra_flags": "-DARDUINO_ESP32_DEV -DARDUINO_USB_CDC_ON_BOOT=0 -DESP32_4M -DESP32_CLASSIC",
"f_cpu": "240000000L",
"f_flash": "40000000L",
"flash_mode": "dio",
Expand Down
2 changes: 2 additions & 0 deletions docs/source/ESPEasy/ESPchips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ To support all modes, we simply need to make several versions
- 2 MB (Quad SPI)
- ``qio_qspi``

`Table Source <https://api.riot-os.org/group__cpu__esp32__esp32s3.html>`_


Build versions:

Expand Down
7 changes: 7 additions & 0 deletions docs/source/Plugin/P077_commands.repl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@
","
Will reset the calibration values to the default values, causing auto-calibration.
"
"
``cseclearpulses``

","
(Added: 2024-01-16)
Will reset the CF-pulse counter.
"
4 changes: 4 additions & 0 deletions lib/ESPEasySerial/Port_ESPEasySerial_USB_HWCDC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ Port_ESPEasySerial_USB_HWCDC_t::Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySeri
if (_hwcdc_serial != nullptr) {
_config.rxBuffSize = _hwcdc_serial->setRxBufferSize(_config.rxBuffSize);
_config.txBuffSize = _hwcdc_serial->setRxBufferSize(_config.txBuffSize);

// See: https://github.com/espressif/arduino-esp32/issues/9043
_hwcdc_serial->setTxTimeoutMs(0); // sets no timeout when trying to write to USB HW CDC

_hwcdc_serial->begin();

// _hwcdc_serial->onEvent(hwcdcEventCallback);
Expand Down
12 changes: 3 additions & 9 deletions platformio_core_defs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,9 @@ lib_ignore =

; ESP_IDF 5.1
[core_esp32_IDF5_1__3_0_0]
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.12/platform-espressif32.zip
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1787/framework-arduinoespressif32-release_v5.1-f61c914469.zip
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.11.11/platform-espressif32.zip
;platform_packages =
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1818/framework-arduinoespressif32-release_v5.1-e5ff26581f.zip
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1846/framework-arduinoespressif32-release_v5.1-29db12e.zip
;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/1877/framework-arduinoespressif32-release_v5.1-88d1438.zip
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.01.11/platform-espressif32.zip
platform_packages =
;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
Expand Down
4 changes: 3 additions & 1 deletion platformio_esp32_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ build_flags = ${core_esp32_IDF5_1__3_0_0.build_flags}
-flto=auto
-Wswitch
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE
-DLWIP_IPV6
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
-DLWIP_IPV6=1
monitor_filters = esp32_exception_decoder
lib_ignore =
${core_esp32_IDF5_1__3_0_0.lib_ignore}
Expand Down
2 changes: 1 addition & 1 deletion platformio_esp32_solo1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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/1878/framework-arduinoespressif32-solo1-release_v5.1-88d1438.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
Expand Down
8 changes: 8 additions & 0 deletions platformio_esp32c3_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ extra_scripts = ${esp32c3_common.extra_scripts}
pre:tools/pio/pre_custom_esp32.py
pre:tools/pio/ir_build_check.py

[env:custom_ESP32c3_4M316k_LittleFS_CDC]
extends = esp32c3_common_LittleFS
board = esp32c3cdc
build_flags = ${esp32c3_common_LittleFS.build_flags}
-DPLUGIN_BUILD_CUSTOM
extra_scripts = ${esp32c3_common_LittleFS.extra_scripts}
pre:tools/pio/pre_custom_esp32.py



[env:normal_ESP32c3_4M316k_CDC]
Expand Down
12 changes: 12 additions & 0 deletions platformio_esp32s2_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ board = esp32s2cdc
lib_ignore = ${esp32s2_common.lib_ignore}
${no_ir.lib_ignore}

[env:custom_ESP32s2_4M316k_LittleFS_CDC]
extends = esp32s2_common_LittleFS
board = esp32s2cdc
lib_ignore = ${esp32s2_common_LittleFS.lib_ignore}
${no_ir.lib_ignore}
build_flags = ${esp32s2_common_LittleFS.build_flags}
-DPLUGIN_BUILD_CUSTOM
-DESP_CONSOLE_USB_CDC=y
extra_scripts = ${esp32s2_common_LittleFS.extra_scripts}
pre:tools/pio/pre_custom_esp32.py



[env:normal_ESP32s2_4M316k_LittleFS_CDC]
extends = esp32s2_common_LittleFS
Expand Down
10 changes: 5 additions & 5 deletions platformio_esp32s3_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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}


8 changes: 8 additions & 0 deletions src/Custom-sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@
#define DEFAULT_SYNC_UDP_PORT 8266 // Used for ESPEasy p2p. (IANA registered port: 8266)


// Factory Reset defaults
#define DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME true
#define DEFAULT_FACTORY_RESET_KEEP_WIFI true
#define DEFAULT_FACTORY_RESET_KEEP_NETWORK true
#define DEFAULT_FACTORY_RESET_KEEP_NTP_DST true
#define DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG true


#define BUILD_NO_DEBUG

// Custom built-in url for hosting JavaScript and CSS files.
Expand Down
12 changes: 6 additions & 6 deletions src/_C009.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ bool do_process_c009_delay_queue(int controller_number, const Queue_element_base
// Create nested objects in "ESP":
jsonString += to_json_object_value(F("name"), Settings.getName());
jsonString += ',';
jsonString += to_json_object_value(F("unit"), String(Settings.Unit));
jsonString += to_json_object_value(F("unit"), static_cast<int>(Settings.Unit));
jsonString += ',';
jsonString += to_json_object_value(F("version"), String(Settings.Version));
jsonString += to_json_object_value(F("version"), static_cast<int>(Settings.Version));
jsonString += ',';
jsonString += to_json_object_value(F("build"), String(Settings.Build));
jsonString += to_json_object_value(F("build"), static_cast<int>(Settings.Build));
jsonString += ',';
jsonString += to_json_object_value(F("build_notes"), F(BUILD_NOTES));
jsonString += ',';
jsonString += to_json_object_value(F("build_git"), getValue(LabelType::GIT_BUILD));
jsonString += ',';
jsonString += to_json_object_value(F("node_type_id"), String(NODE_TYPE_ID));
jsonString += to_json_object_value(F("node_type_id"), static_cast<int>(NODE_TYPE_ID));
jsonString += ',';
jsonString += to_json_object_value(F("sleep"), String(Settings.deepSleep_wakeTime));
jsonString += to_json_object_value(F("sleep"), static_cast<int>(Settings.deepSleep_wakeTime));

// embed IP, important if there is NAT/PAT
// char ipStr[20];
Expand Down Expand Up @@ -180,7 +180,7 @@ bool do_process_c009_delay_queue(int controller_number, const Queue_element_base
jsonString += ',';
jsonString += to_json_object_value(F("valueName"), getTaskValueName(element._taskIndex, x));
jsonString += ',';
jsonString += to_json_object_value(F("type"), String(static_cast<int>(element.sensorType)));
jsonString += to_json_object_value(F("type"), static_cast<int>(element.sensorType));
jsonString += ',';
jsonString += to_json_object_value(F("value"), element.txt[x]);
}
Expand Down
31 changes: 11 additions & 20 deletions src/src/Commands/Diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,17 @@ const __FlashStringHelper * Command_JSONPortStatus(struct EventStruct *event, co
void createLogPortStatus(std::map<uint32_t, portStatusStruct>::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));
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/src/Commands/InternalCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_A(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
Expand Down
3 changes: 3 additions & 0 deletions src/src/Commands/InternalCommands_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/src/Commands/InternalCommands_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/src/Commands/Networks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/src/Commands/Networks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
20 changes: 20 additions & 0 deletions src/src/CustomBuild/ESPEasyDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,26 @@
#define DEFAULT_SYNC_UDP_PORT 8266 // Used for ESPEasy p2p. (IANA registered port: 8266)
#endif


// Factory Reset defaults
#ifndef DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME
#define DEFAULT_FACTORY_RESET_KEEP_UNIT_NAME true
#endif
#ifndef DEFAULT_FACTORY_RESET_KEEP_WIFI
#define DEFAULT_FACTORY_RESET_KEEP_WIFI true
#endif
#ifndef DEFAULT_FACTORY_RESET_KEEP_NETWORK
#define DEFAULT_FACTORY_RESET_KEEP_NETWORK true
#endif
#ifndef DEFAULT_FACTORY_RESET_KEEP_NTP_DST
#define DEFAULT_FACTORY_RESET_KEEP_NTP_DST true
#endif
#ifndef DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG
#define DEFAULT_FACTORY_RESET_KEEP_CONSOLE_LOG true
#endif



// --- Defaults to be used for custom automatic provisioning builds ------------------------------------
#if FEATURE_CUSTOM_PROVISIONING
#ifndef DEFAULT_FACTORY_DEFAULT_DEVICE_MODEL
Expand Down
18 changes: 18 additions & 0 deletions src/src/CustomBuild/define_plugin_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -1113,6 +1116,7 @@ To create/register a plugin, you have to :
#ifdef FEATURE_CUSTOM_PROVISIONING
#undef FEATURE_CUSTOM_PROVISIONING
#endif
// FIXME TD-er: Should this be enabled on non-Custom builds???
#define FEATURE_CUSTOM_PROVISIONING 1


Expand Down Expand Up @@ -3288,6 +3292,20 @@ To create/register a plugin, you have to :
#endif


// Enable dependencies for custom provisioning
// FIXME TD-er: What about using this feature on non-Custom builds????
#if FEATURE_CUSTOM_PROVISIONING
#ifdef FEATURE_DOWNLOAD
#undef FEATURE_DOWNLOAD
#endif
#define FEATURE_DOWNLOAD 1
#ifdef FEATURE_SETTINGS_ARCHIVE
#undef FEATURE_SETTINGS_ARCHIVE
#endif
#define FEATURE_SETTINGS_ARCHIVE 1
#endif



// TODO TD-er: Test feature, must remove
/*
Expand Down
2 changes: 1 addition & 1 deletion src/src/DataStructs/EthernetEventData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void EthernetEventData_t::markConnected() {
lastConnectMoment.setNow();
processedConnect = false;
#if FEATURE_USE_IPV6
ETH.enableIpV6();
ETH.enableIPv6(true);
#endif

}
Expand Down
Loading

0 comments on commit e015d1b

Please sign in to comment.