Merge pull request #2904 from MichaelDvP/dev

GPIOs depends on board profile, #2901
This commit is contained in:
Proddy
2026-01-08 17:42:34 +01:00
committed by GitHub
10 changed files with 41 additions and 22 deletions

View File

@@ -7,6 +7,7 @@ For more details go to [emsesp.org](https://emsesp.org/).
## Added ## Added
- update time saved in nvs - update time saved in nvs
- heatpump entities [#2883](https://github.com/emsesp/EMS-ESP32/issues/2883)
## Fixed ## Fixed
@@ -22,3 +23,5 @@ For more details go to [emsesp.org](https://emsesp.org/).
- snapshot gpios stored in temporary ram - snapshot gpios stored in temporary ram
- GPIOs stored along with the name and reported in log if conflicting - GPIOs stored along with the name and reported in log if conflicting
- free GPIOs depend on board profile [#2901](https://github.com/emsesp/EMS-ESP32/issues/2901)
- prefer PSram for mqtt queue [#2889](https://github.com/emsesp/EMS-ESP32/issues/2889)

View File

@@ -489,17 +489,25 @@ const ApplicationSettings = () => {
name="board_profile" name="board_profile"
label={LL.BOARD_PROFILE()} label={LL.BOARD_PROFILE()}
value={data.board_profile} value={data.board_profile}
disabled={processingBoard || hardwareData.model.startsWith('BBQKees')} disabled={processingBoard}
variant="outlined" variant="outlined"
onChange={changeBoardProfile} onChange={changeBoardProfile}
margin="normal" margin="normal"
select select
> >
{boardProfileItems} {hardwareData.model.startsWith('BBQKees') ? (
<MenuItem key={hardwareData.board} value={hardwareData.board}>
{BOARD_PROFILES[hardwareData.board as BoardProfileKey]}
</MenuItem>
) : (
boardProfileItems
)}
<Divider /> <Divider />
<MenuItem key={'CUSTOM'} value={'CUSTOM'}> {(data.board_profile === 'CUSTOM' || data.developer_mode) && (
{LL.CUSTOM()}&hellip; <MenuItem key={'CUSTOM'} value={'CUSTOM'}>
</MenuItem> {LL.CUSTOM()}&hellip;
</MenuItem>
)}
</TextField> </TextField>
{data.board_profile === 'CUSTOM' && ( {data.board_profile === 'CUSTOM' && (
<> <>

View File

@@ -50,6 +50,7 @@ export interface SystemStatus {
free_psram?: number; free_psram?: number;
free_caps: number; free_caps: number;
model: string; model: string;
board: string;
has_loader: boolean; has_loader: boolean;
has_partition: boolean; has_partition: boolean;
partitions: { partitions: {

View File

@@ -56,8 +56,7 @@ void IRAM_ATTR AnalogSensor::freqIrq2() {
#endif #endif
void AnalogSensor::start(const bool factory_settings) { void AnalogSensor::start(const bool factory_settings) {
// if (factory_settings && EMSESP::nvs_.getString("boot").equals("E32V2_2")) { if (factory_settings && EMSESP::system_.board_profile() == "E32V2_2") {
if (factory_settings && analogReadMilliVolts(39) > 700) { // core voltage > 2.6V
EMSESP::webCustomizationService.update([&](WebCustomization & settings) { EMSESP::webCustomizationService.update([&](WebCustomization & settings) {
auto newSensor = AnalogCustomization(); auto newSensor = AnalogCustomization();
strcpy(newSensor.name, "core_voltage"); strcpy(newSensor.name, "core_voltage");
@@ -75,6 +74,13 @@ void AnalogSensor::start(const bool factory_settings) {
newSensor.is_system = true; newSensor.is_system = true;
settings.analogCustomizations.push_back(newSensor); settings.analogCustomizations.push_back(newSensor);
strcpy(newSensor.name, "led");
newSensor.gpio = 2;
newSensor.type = AnalogType::DIGITAL_OUT;
newSensor.uom = DeviceValueUOM::NONE; // unchanged after restart
newSensor.factor = 1; // active high
settings.analogCustomizations.push_back(newSensor);
return StateUpdateResult::CHANGED; // persist the change return StateUpdateResult::CHANGED; // persist the change
}); });
} }

View File

@@ -2400,12 +2400,16 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
return false; // unknown, return false return false; // unknown, return false
} else if (board_profile == "S32") { } else if (board_profile == "S32") {
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S32 data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S32
valid_system_gpios_ = {0, 2, 5, 18, 23};
} else if (board_profile == "E32") { } else if (board_profile == "E32") {
data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32 data = {2, 4, 5, 17, 33, PHY_type::PHY_TYPE_LAN8720, 16, 1, 0, 0}; // BBQKees Gateway E32
valid_system_gpios_ = {0, 2, 4, 5, 16, 17, 33};
} else if (board_profile == "E32V2") { } else if (board_profile == "E32V2") {
data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2 data = {2, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 0}; // BBQKees Gateway E32 V2
valid_system_gpios_ = {0, 2, 4, 5, 14, 15, 34};
} else if (board_profile == "E32V2_2") { } else if (board_profile == "E32V2_2") {
data = {32, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 1}; // BBQKees Gateway E32 V2.2, rgb led data = {32, 14, 4, 5, 34, PHY_type::PHY_TYPE_LAN8720, 15, 0, 1, 1}; // BBQKees Gateway E32 V2.2, rgb led
valid_system_gpios_ = {0, 2, 4, 5, 14, 15, 32, 34, 36, 39}; // system analogs 36, 39, led 2
} else if (board_profile == "MH-ET") { } else if (board_profile == "MH-ET") {
data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini data = {2, 18, 23, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // MH-ET Live D1 Mini
} else if (board_profile == "NODEMCU") { } else if (board_profile == "NODEMCU") {
@@ -2428,6 +2432,7 @@ bool System::load_board_profile(std::vector<int8_t> & data, const std::string &
data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Liligo S3 data = {17, 18, 8, 5, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // Liligo S3
} else if (board_profile == "S32S3") { } else if (board_profile == "S32S3") {
data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S3 data = {2, 18, 5, 17, 0, PHY_type::PHY_TYPE_NONE, 0, 0, 0, 0}; // BBQKees Gateway S3
valid_system_gpios_ = {0, 2, 5, 17, 18};
} else { } else {
return false; // unknown, return false return false; // unknown, return false
} }
@@ -2956,6 +2961,7 @@ void System::set_valid_system_gpios() {
#elif defined(EMSESP_STANDALONE) #elif defined(EMSESP_STANDALONE)
valid_system_gpios_ = string_range_to_vector("0-39"); valid_system_gpios_ = string_range_to_vector("0-39");
#endif #endif
valid_system_gpios_.shrink_to_fit();
} }
// check if a pin is valid ESP32 pin and if not already used, add to the used gpio list // check if a pin is valid ESP32 pin and if not already used, add to the used gpio list

View File

@@ -33,8 +33,7 @@ uuid::log::Logger TemperatureSensor::logger_{F_(temperaturesensor), uuid::log::F
// start the 1-wire // start the 1-wire
void TemperatureSensor::start(const bool factory_settings) { void TemperatureSensor::start(const bool factory_settings) {
// set_internal_ = factory_settings && EMSESP::nvs_.getString("boot").equals("E32V2_2") && EMSESP::nvs_.getString("hwrevision").equals("3.0"); set_internal_ = factory_settings && EMSESP::system_.board_profile() == "E32V2_2";
set_internal_ = factory_settings && analogReadMilliVolts(39) > 700; // core voltage > 2.6V
reload(); reload();
if (!dallas_gpio_) { if (!dallas_gpio_) {

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.8.1-dev.4" #define EMSESP_APP_VERSION "3.8.1-dev.5"

View File

@@ -422,7 +422,7 @@ void WebSettings::set_board_profile(WebSettings & settings) {
// Note 2: The board profile is dynamically changed for the session, but the value in the settings file on the FS remains untouched // Note 2: The board profile is dynamically changed for the session, but the value in the settings file on the FS remains untouched
if (EMSESP::system_.getBBQKeesGatewayDetails(FUSE_VALUE::MFG).startsWith("BBQKees")) { if (EMSESP::system_.getBBQKeesGatewayDetails(FUSE_VALUE::MFG).startsWith("BBQKees")) {
String bbq_board = EMSESP::system_.getBBQKeesGatewayDetails(FUSE_VALUE::BOARD); String bbq_board = EMSESP::system_.getBBQKeesGatewayDetails(FUSE_VALUE::BOARD);
if (!bbq_board.isEmpty()) { if (!bbq_board.isEmpty() && settings.board_profile != "CUSTOM") {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
EMSESP::logger().info("Overriding board profile with fuse value %s", bbq_board.c_str()); EMSESP::logger().info("Overriding board profile with fuse value %s", bbq_board.c_str());
#endif #endif

View File

@@ -49,8 +49,6 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
auto * response = new AsyncJsonResponse(false); auto * response = new AsyncJsonResponse(false);
JsonObject root = response->getRoot(); JsonObject root = response->getRoot();
root["emsesp_version"] = EMSESP_APP_VERSION;
// //
// System Status // System Status
// //
@@ -130,6 +128,7 @@ void WebStatusService::systemStatus(AsyncWebServerRequest * request) {
root["free_psram"] = ESP.getFreePsram() / 1024; root["free_psram"] = ESP.getFreePsram() / 1024;
} }
root["model"] = EMSESP::system_.getBBQKeesGatewayDetails(); root["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
root["board"] = EMSESP::system_.getBBQKeesGatewayDetails(FUSE_VALUE::BOARD);
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 #if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2
root["temperature"] = (int)Helpers::transformNumFloat(EMSESP::system_.temperature(), 0, EMSESP::system_.fahrenheit() ? 2 : 0); // only 2 decimal places root["temperature"] = (int)Helpers::transformNumFloat(EMSESP::system_.temperature(), 0, EMSESP::system_.fahrenheit() ? 2 : 0); // only 2 decimal places
#endif #endif

View File

@@ -217,9 +217,8 @@ void test_22() {
void test_23() { void test_23() {
auto expected_response = auto expected_response =
"[{\"system\":{\"version\":\"dev\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " "[{\"system\":{\"version\":\"dev\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / "
"Unknown\",\"txpause\":false,\"gpios_in_use\":\"23, 5, 2, 18, 0\",\"gpios_available\":\"1, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, " "Unknown\",\"txpause\":false,\"gpios_in_use\":\"23, 5, 2, 18, 0\",\"gpios_available\":\"\"},"
"21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, " "\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false,"
"39\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false,"
"\"disableSleep\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{\"NTPstatus\":\"disconnected\",\"enabled\":true,\"server\":\"pool.ntp.org\"," "\"disableSleep\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{\"NTPstatus\":\"disconnected\",\"enabled\":true,\"server\":\"pool.ntp.org\","
"\"tzLabel\":\"Europe/" "\"tzLabel\":\"Europe/"
"London\",\"NTPStatus\":\"disconnected\"},\"ap\":{\"provisionMode\":\"always\",\"ssid\":\"ems-esp\"},\"mqtt\":{\"MQTTStatus\":\"disconnected\"," "London\",\"NTPStatus\":\"disconnected\"},\"ap\":{\"provisionMode\":\"always\",\"ssid\":\"ems-esp\"},\"mqtt\":{\"MQTTStatus\":\"disconnected\","
@@ -248,9 +247,8 @@ void test_23() {
void test_24() { void test_24() {
auto expected_response = auto expected_response =
"[{\"system\":{\"version\":\"dev\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " "[{\"system\":{\"version\":\"dev\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / "
"Unknown\",\"txpause\":false,\"gpios_in_use\":\"23, 5, 2, 18, 0\",\"gpios_available\":\"1, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, " "Unknown\",\"txpause\":false,\"gpios_in_use\":\"23, 5, 2, 18, 0\",\"gpios_available\":\"\"},"
"21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, " "\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false,"
"39\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false,"
"\"disableSleep\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{\"NTPstatus\":\"disconnected\",\"enabled\":true,\"server\":\"pool.ntp.org\"," "\"disableSleep\":true,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{\"NTPstatus\":\"disconnected\",\"enabled\":true,\"server\":\"pool.ntp.org\","
"\"tzLabel\":\"Europe/" "\"tzLabel\":\"Europe/"
"London\",\"NTPStatus\":\"disconnected\"},\"ap\":{\"provisionMode\":\"always\",\"ssid\":\"ems-esp\"},\"mqtt\":{\"MQTTStatus\":\"disconnected\"," "London\",\"NTPStatus\":\"disconnected\"},\"ap\":{\"provisionMode\":\"always\",\"ssid\":\"ems-esp\"},\"mqtt\":{\"MQTTStatus\":\"disconnected\","
@@ -280,9 +278,8 @@ void test_25() {
auto expected_response = auto expected_response =
"[{\"api_data\":\"# HELP emsesp_system_uptimesec uptimeSec\\n# TYPE emsesp_system_uptimesec gauge\\nemsesp_system_uptimesec 0\\n# HELP " "[{\"api_data\":\"# HELP emsesp_system_uptimesec uptimeSec\\n# TYPE emsesp_system_uptimesec gauge\\nemsesp_system_uptimesec 0\\n# HELP "
"emsesp_system_txpause txpause\\n# TYPE emsesp_system_txpause gauge\\nemsesp_system_txpause 0\\n# HELP emsesp_system_info info\\n# TYPE " "emsesp_system_txpause txpause\\n# TYPE emsesp_system_txpause gauge\\nemsesp_system_txpause 0\\n# HELP emsesp_system_info info\\n# TYPE "
"emsesp_system_info gauge\\nemsesp_system_info{version=\\\"dev\\\", resetreason=\\\"Unknown / Unknown\\\", gpios_in_use=\\\"23, 5, 2, 18, 0\\\", " "emsesp_system_info gauge\\nemsesp_system_info{version=\\\"dev\\\", resetreason=\\\"Unknown / Unknown\\\", gpios_in_use=\\\"23, 5, 2, 18, 0"
"gpios_available=\\\"1, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, " "\\\"} 1\\n# HELP emsesp_network_rssi RSSI\\n# TYPE emsesp_network_rssi gauge\\nemsesp_network_rssi -23\\n# HELP emsesp_network_txpowersetting "
"39\\\"} 1\\n# HELP emsesp_network_rssi RSSI\\n# TYPE emsesp_network_rssi gauge\\nemsesp_network_rssi -23\\n# HELP emsesp_network_txpowersetting "
"TxPowerSetting\\n# TYPE emsesp_network_txpowersetting gauge\\nemsesp_network_txpowersetting 0\\n# HELP emsesp_network_staticip staticIP\\n# TYPE " "TxPowerSetting\\n# TYPE emsesp_network_txpowersetting gauge\\nemsesp_network_txpowersetting 0\\n# HELP emsesp_network_staticip staticIP\\n# TYPE "
"emsesp_network_staticip gauge\\nemsesp_network_staticip 0\\n# HELP emsesp_network_lowbandwidth lowBandwidth\\n# TYPE emsesp_network_lowbandwidth " "emsesp_network_staticip gauge\\nemsesp_network_staticip 0\\n# HELP emsesp_network_lowbandwidth lowBandwidth\\n# TYPE emsesp_network_lowbandwidth "
"gauge\\nemsesp_network_lowbandwidth 0\\n# HELP emsesp_network_disablesleep disableSleep\\n# TYPE emsesp_network_disablesleep " "gauge\\nemsesp_network_lowbandwidth 0\\n# HELP emsesp_network_disablesleep disableSleep\\n# TYPE emsesp_network_disablesleep "