mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
board_profile name in NVS after autodetect
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
|
||||
- humidity for ventilation devices
|
||||
- telegrams for RC100H, hc2, etc. (seen on discord, not tested)
|
||||
- names for BC400, GB192i, read temperatures for low loss header and heatblock [#1317](https://github.com/emsesp/EMS-ESP32/discussions/1317)
|
||||
- names for BC400, GB192i.2, read temperatures for low loss header and heatblock [#1317](https://github.com/emsesp/EMS-ESP32/discussions/1317)
|
||||
- option for `forceheatingoff` [#1262](https://github.com/emsesp/EMS-ESP32/issues/1262)
|
||||
- remote thermostat emulation for RC3xx
|
||||
- publish time for shower
|
||||
- autodetect board_profile, store in nvs, add telnet command option, add E32V2
|
||||
|
||||
## Fixed
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(set), F_(board_profile)},
|
||||
string_vector{F_(name_mandatory)},
|
||||
string_vector{F_(name_mandatory), F_(nvs_optional)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
std::vector<int8_t> data; // led, dallas, rx, tx, button, phy_type, eth_power, eth_phy_addr, eth_clock_mode
|
||||
std::string board_profile = Helpers::toUpper(arguments.front());
|
||||
@@ -287,6 +287,9 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
shell.println("Invalid board profile (S32, E32, E32V2, MH-ET, NODEMCU, OLIMEX, OLIMEXPOE, C3MINI, S2MINI, S3MINI, CUSTOM)");
|
||||
return;
|
||||
}
|
||||
if (arguments.size() == 2 && Helpers::toLower(arguments.back()) == "nvs") {
|
||||
to_app(shell).nvs_.putString("boot", board_profile.c_str());
|
||||
}
|
||||
to_app(shell).webSettingsService.update(
|
||||
[&](WebSettings & settings) {
|
||||
settings.board_profile = board_profile.c_str();
|
||||
|
||||
@@ -141,6 +141,7 @@ MAKE_WORD_CUSTOM(n_mandatory, "<n>")
|
||||
MAKE_WORD_CUSTOM(sensorid_optional, "[sensor ID]")
|
||||
MAKE_WORD_CUSTOM(id_optional, "[id|hc]")
|
||||
MAKE_WORD_CUSTOM(data_optional, "[data]")
|
||||
MAKE_WORD_CUSTOM(nvs_optional, "[nvs]")
|
||||
MAKE_WORD_CUSTOM(offset_optional, "[offset]")
|
||||
MAKE_WORD_CUSTOM(length_optional, "[length]")
|
||||
MAKE_WORD_CUSTOM(typeid_mandatory, "<type ID>")
|
||||
|
||||
@@ -99,58 +99,30 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
|
||||
#endif
|
||||
|
||||
if (!System::load_board_profile(data, settings.board_profile.c_str())) {
|
||||
// unknown, check for ethernet, use default E32/S32
|
||||
// data is led, dallas, rx, tx, pbutton, phy, eth_power, eth_addr, eth_clock
|
||||
// unknown, check for NVS or scan for ethernet, use default E32/E32V2/S32
|
||||
#if CONFIG_IDF_TARGET_ESP32 && !defined(EMSESP_STANDALONE)
|
||||
switch (EMSESP::nvs_.getUChar("boot")) {
|
||||
case 0:
|
||||
if (ETH.begin((eth_phy_type_t)1, 16, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_IN)) {
|
||||
EMSESP::nvs_.putUChar("boot", 2); // set to E32
|
||||
ESP.restart();
|
||||
settings.board_profile = EMSESP::nvs_.getString("boot");
|
||||
if (!System::load_board_profile(data, settings.board_profile.c_str())) {
|
||||
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");
|
||||
} else {
|
||||
EMSESP::nvs_.putString("boot", "Test");
|
||||
}
|
||||
} else if (settings.board_profile == "Test") {
|
||||
if (ETH.begin((eth_phy_type_t)0, 15, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_OUT)) {
|
||||
EMSESP::nvs_.putString("boot", "E32V2");
|
||||
} else {
|
||||
EMSESP::nvs_.putString("boot", "S32");
|
||||
}
|
||||
} else {
|
||||
EMSESP::nvs_.putString("boot", "S32");
|
||||
}
|
||||
EMSESP::nvs_.putUChar("boot", 1); // next test for E32V2
|
||||
ESP.restart();
|
||||
case 1:
|
||||
if (ETH.begin((eth_phy_type_t)0, 15, 23, 18, ETH_PHY_LAN8720, ETH_CLOCK_GPIO0_OUT)) {
|
||||
EMSESP::nvs_.putUChar("boot", 3); // set to E32V2
|
||||
ESP.restart();
|
||||
}
|
||||
EMSESP::nvs_.putUChar("boot", 4); // set to S32
|
||||
ESP.restart();
|
||||
case 2:
|
||||
settings.board_profile = "E32";
|
||||
data = {EMSESP_DEFAULT_LED_GPIO, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0};
|
||||
break;
|
||||
case 3:
|
||||
settings.board_profile = "E32V2";
|
||||
data = {EMSESP_DEFAULT_LED_GPIO, 14, 4, 5, 0, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1}; // BBQKees Gateway E32 V2
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
settings.board_profile = "S32";
|
||||
data = {EMSESP_DEFAULT_LED_GPIO,
|
||||
EMSESP_DEFAULT_DALLAS_GPIO,
|
||||
EMSESP_DEFAULT_RX_GPIO,
|
||||
EMSESP_DEFAULT_TX_GPIO,
|
||||
EMSESP_DEFAULT_PBUTTON_GPIO,
|
||||
EMSESP_DEFAULT_PHY_TYPE,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// BBQKees Gateway S32
|
||||
data = {EMSESP_DEFAULT_LED_GPIO,
|
||||
EMSESP_DEFAULT_DALLAS_GPIO,
|
||||
EMSESP_DEFAULT_RX_GPIO,
|
||||
EMSESP_DEFAULT_TX_GPIO,
|
||||
EMSESP_DEFAULT_PBUTTON_GPIO,
|
||||
EMSESP_DEFAULT_PHY_TYPE,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user