feat: add LAN8720 support and extend ESP32 Ethernet profiles

This commit is contained in:
Yurii committed 2026-12-04 15:12:16 +03:00
1 parent cea8231015
commit 54caf4fd7f
16 files changed
+441 -123

No files matched your search

+34 -12
View File
@@ -1,4 +1,5 @@
const convertLegacyBackup = (data) => {
// 1.x to 2.0.0: rename legacy settings keys throughout the backup.
const aliases = {
alwaysSendIndoorTemp: 'always_send_indoor_temp',
antiStuckInterval: 'antistuck_interval',
@@ -61,8 +62,8 @@ const convertLegacyBackup = (data) => {
useDhcp: 'use_dhcp',
webSerial: 'web_serial'
};
const logLevels = [0, 1, 1, 2, 3, 3, 4, 5];
// 1.x to 2.0.0: apply the key aliases recursively, including objects inside arrays.
const convert = (value) => {
if (Array.isArray(value)) {
return value.map(convert);
@@ -79,6 +80,8 @@ const convertLegacyBackup = (data) => {
return result;
};
// 1.x to 2.0.0: map TinyLogger levels to ESP-IDF levels before renaming logLevel.
const logLevels = [0, 1, 1, 2, 3, 3, 4, 5];
const legacySystem = data?.settings?.system;
if (legacySystem !== null && typeof legacySystem === 'object'
&& Object.prototype.hasOwnProperty.call(legacySystem, 'logLevel')) {
@@ -98,8 +101,15 @@ const convertLegacyBackup = (data) => {
const result = convert(data);
// 1.x to 2.0.0: settings.system.unit_system became the sole unit setting.
const opentherm = result?.settings?.opentherm;
if (opentherm !== null && typeof opentherm === 'object') {
delete opentherm.unit_system;
}
const network = result?.network;
if (network !== null && typeof network === 'object' && !Array.isArray(network)) {
// 1.x to 2.0.0: move network.ap and network.sta under network.wifi.
const hasLegacyAp = Object.prototype.hasOwnProperty.call(network, 'ap');
const hasLegacySta = Object.prototype.hasOwnProperty.call(network, 'sta');
if (hasLegacyAp || hasLegacySta) {
@@ -117,28 +127,40 @@ const convertLegacyBackup = (data) => {
delete network.sta;
}
// 1.x to 2.0.0: derive network.type from the settings present in the backup.
if (!Object.prototype.hasOwnProperty.call(network, 'type')) {
if (typeof network.ethernet?.enabled === 'boolean') {
// Legacy builds with W5500 after the 1.6.0 tag (#286) stored ethernet.enabled.
network.type = network.ethernet.enabled ? 3 : 2;
} else if (hasLegacyAp || hasLegacySta) {
// Tagged 1.x releases only supported Wi-Fi.
network.type = 2;
}
}
if (network.ethernet !== null && typeof network.ethernet === 'object' && !Array.isArray(network.ethernet)) {
if (Object.prototype.hasOwnProperty.call(network.ethernet, 'pins')
&& !Object.prototype.hasOwnProperty.call(network.ethernet, 'gpio')) {
network.ethernet.gpio = network.ethernet.pins;
const ethernet = network.ethernet;
if (ethernet !== null && typeof ethernet === 'object' && !Array.isArray(ethernet)) {
// Post-1.6.0 legacy (#286) to 2.0.0: rename ethernet.pins to ethernet.gpio.
if (Object.prototype.hasOwnProperty.call(ethernet, 'pins')
&& !Object.prototype.hasOwnProperty.call(ethernet, 'gpio')) {
ethernet.gpio = ethernet.pins;
}
delete network.ethernet.pins;
delete network.ethernet.enabled;
}
}
delete ethernet.pins;
delete ethernet.enabled;
const opentherm = result?.settings?.opentherm;
if (opentherm !== null && typeof opentherm === 'object') {
delete opentherm.unit_system;
// 2.0.0 and 2.0.1 to the per-controller format: ethernet.gpio belonged to W5500.
const gpio = ethernet.gpio;
if (gpio !== null && typeof gpio === 'object' && !Array.isArray(gpio)) {
if (!Object.prototype.hasOwnProperty.call(ethernet, 'w5500')) {
ethernet.w5500 = gpio;
}
if (!Object.prototype.hasOwnProperty.call(ethernet, 'type')) {
ethernet.type = 1; // W5500
}
}
delete ethernet.gpio;
}
}
return result;