firmware: keep temp config lookup outside UART guard
This commit is contained in:
@@ -2025,7 +2025,7 @@ int findRelayConfigIndexForUart(const String& id) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int findTempConfigIndexForUart(const String& id) {
|
||||
int findTempConfigIndexById(const String& id) {
|
||||
for (int i = 0; i < MAX_TEMP_SENSORS; i++) {
|
||||
if (appConfig.tempSensors[i].id == id) {
|
||||
return i;
|
||||
@@ -2110,7 +2110,7 @@ void handleUartMessage(const String& line) {
|
||||
|
||||
if (strcmp(type, "config_temp") == 0) {
|
||||
String id = doc["id"] | "";
|
||||
int index = findTempConfigIndexForUart(id);
|
||||
int index = findTempConfigIndexById(id);
|
||||
|
||||
if (index < 0) {
|
||||
sendError(DashboardSerial, "unknown_temp_sensor");
|
||||
@@ -2286,7 +2286,7 @@ void handleUartMessage(const String& line) {
|
||||
int configIndex = -1;
|
||||
|
||||
if (id.length() > 0) {
|
||||
configIndex = findTempConfigIndexForUart(id);
|
||||
configIndex = findTempConfigIndexById(id);
|
||||
} else if (slot >= 1 && slot <= MAX_TEMP_SENSORS) {
|
||||
configIndex = slot - 1;
|
||||
}
|
||||
@@ -2313,7 +2313,7 @@ void handleUartMessage(const String& line) {
|
||||
int configIndex = -1;
|
||||
|
||||
if (id.length() > 0) {
|
||||
configIndex = findTempConfigIndexForUart(id);
|
||||
configIndex = findTempConfigIndexById(id);
|
||||
} else if (slot >= 1 && slot <= MAX_TEMP_SENSORS) {
|
||||
configIndex = slot - 1;
|
||||
}
|
||||
@@ -3078,7 +3078,7 @@ void handleTempAssign() {
|
||||
int configIndex = -1;
|
||||
|
||||
if (id.length() > 0) {
|
||||
configIndex = findTempConfigIndexForUart(id);
|
||||
configIndex = findTempConfigIndexById(id);
|
||||
} else if (slot >= 1 && slot <= MAX_TEMP_SENSORS) {
|
||||
configIndex = slot - 1;
|
||||
}
|
||||
@@ -3128,7 +3128,7 @@ void handleTempClear() {
|
||||
int configIndex = -1;
|
||||
|
||||
if (id.length() > 0) {
|
||||
configIndex = findTempConfigIndexForUart(id);
|
||||
configIndex = findTempConfigIndexById(id);
|
||||
} else if (slot >= 1 && slot <= MAX_TEMP_SENSORS) {
|
||||
configIndex = slot - 1;
|
||||
}
|
||||
|
||||
@@ -448,3 +448,15 @@ def test_legacy_dashboard_uart_is_disabled_by_default():
|
||||
assert "DASHBOARD_UART_RX_PIN 22" not in config
|
||||
assert "#if DASHBOARD_UART_ENABLED" in source
|
||||
assert "pollDashboardUart();" in source
|
||||
|
||||
|
||||
def test_temp_config_lookup_is_available_to_http_handlers():
|
||||
source = firmware_source()
|
||||
|
||||
assert "int findTempConfigIndexById(" in source
|
||||
assert "configIndex = findTempConfigIndexById(id);" in source
|
||||
assert "findTempConfigIndexForUart" not in source
|
||||
|
||||
helper_pos = source.index("int findTempConfigIndexById(")
|
||||
uart_guard_pos = source.index("#if DASHBOARD_UART_ENABLED")
|
||||
assert helper_pos < uart_guard_pos
|
||||
|
||||
Reference in New Issue
Block a user