diff --git a/platformio.ini b/platformio.ini index eafde0a7f..0c15773bd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -96,6 +96,7 @@ board_build.partitions = esp32_partition_16M.csv build_flags = ${common.build_flags} -O2 + -DEMSESP_DEFAULT_BOARD_PROFILE = "S32S3" build_unflags = ${common.unbuild_flags} [env:esp32_4M] @@ -127,7 +128,9 @@ extends = espressi32_base_tasmota board = lolin_c3_mini board_upload.flash_size = 4MB board_build.partitions = esp32_partition_4M.csv -build_flags = ${common.build_flags} +build_flags = + ${common.build_flags} + -DEMSESP_DEFAULT_BOARD_PROFILE = "C3MINI" ; lolin C3 mini v1 needs special wifi init. ; https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi @@ -139,13 +142,16 @@ board_build.partitions = esp32_partition_4M.csv build_flags = ${common.build_flags} -DBOARD_C3_MINI_V1 + -DEMSESP_DEFAULT_BOARD_PROFILE = "C3MINI" [env:lolin_s2_mini] extends = espressi32_base_tasmota board = lolin_s2_mini board_upload.flash_size = 4MB board_build.partitions = esp32_partition_4M.csv -build_flags = ${common.build_flags} +build_flags = + ${common.build_flags} + -DEMSESP_DEFAULT_BOARD_PROFILE = "S2MINI" [env:lolin_s3] extends = espressi32_base @@ -158,6 +164,7 @@ board_upload.wait_for_upload_port = false build_flags = ${common.build_flags} -O2 + -DEMSESP_DEFAULT_BOARD_PROFILE = "S32S3" ; to build and run: pio run -e standalone -t exec [env:standalone] diff --git a/src/web/WebSettingsService.cpp b/src/web/WebSettingsService.cpp index f1ec4d410..da729a3d9 100644 --- a/src/web/WebSettingsService.cpp +++ b/src/web/WebSettingsService.cpp @@ -87,6 +87,11 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) // load default GPIO configuration based on board profile std::vector data; // // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode + settings.board_profile = root["board_profile"] | EMSESP_DEFAULT_BOARD_PROFILE; + if ((String)EMSESP_DEFAULT_BOARD_PROFILE != "default" && EMSESP::nvs_.getString("boot") == "") { + EMSESP::nvs_.putString("boot", EMSESP_DEFAULT_BOARD_PROFILE); + } + /* #if CONFIG_IDF_TARGET_ESP32C3 settings.board_profile = root["board_profile"] | "C3MINI"; #elif CONFIG_IDF_TARGET_ESP32S2 @@ -97,12 +102,12 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) #elif CONFIG_IDF_TARGET_ESP32 settings.board_profile = root["board_profile"] | EMSESP_DEFAULT_BOARD_PROFILE; #endif - +*/ if (!System::load_board_profile(data, settings.board_profile.c_str())) { // unknown, check for NVS or scan for ethernet, use default E32/E32V2/S32 -#if CONFIG_IDF_TARGET_ESP32 && !defined(EMSESP_STANDALONE) settings.board_profile = EMSESP::nvs_.getString("boot"); if (!System::load_board_profile(data, settings.board_profile.c_str())) { +#if CONFIG_IDF_TARGET_ESP32 && !defined(EMSESP_STANDALONE) if (settings.board_profile == "") { // empty: new test if (ETH.begin((eth_phy_type_t)1, 16, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_IN)) { EMSESP::nvs_.putString("boot", "E32"); @@ -119,11 +124,11 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) EMSESP::nvs_.putString("boot", "S32"); } ESP.restart(); - } #else - settings.board_profile = "S32"; - System::load_board_profile(data, settings.board_profile.c_str()); + settings.board_profile = "S32"; + System::load_board_profile(data, settings.board_profile.c_str()); #endif + } EMSESP::logger().info("No board profile found. Re-setting to %s", settings.board_profile.c_str()); } else { EMSESP::logger().info("Loading board profile %s", settings.board_profile.c_str());