mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-25 07:43:04 +05:00
feat: merge master Ethernet support into dev
Adapt W5500 to the native network event queue and select STA or ETH from NetworkSettings. Preserve the existing dev network settings and add a separate C6 Ethernet build without BLE to fit the OTA slot. Validate with S3 and C6 Ethernet firmware builds, the shared LittleFS image, binary layout checks and targeted network transition checks.
This commit is contained in:
commit
4e71915222
21 files changed
+1007
-158
No files matched your search
@@ -144,15 +144,34 @@
|
||||
"network": {
|
||||
"title": "网络 - OpenTherm Gateway",
|
||||
"name": "网络设置",
|
||||
"type": {
|
||||
"title": "连接方式",
|
||||
"wifi": "Wi-Fi",
|
||||
"ethernet": "Ethernet"
|
||||
},
|
||||
"section": {
|
||||
"static": "静态设置",
|
||||
"ethernet": "以太网",
|
||||
"wifi": "Wi-Fi",
|
||||
"availableNetworks": "可用网络",
|
||||
"staSettings": "WiFi 设置",
|
||||
"apSettings": "AP 设置"
|
||||
},
|
||||
"scan": {
|
||||
"pos": "#",
|
||||
"info": "Info"
|
||||
"info": "Info",
|
||||
"unavailable": "仅在 Wi-Fi 模式下可扫描网络。"
|
||||
},
|
||||
|
||||
"ethernet": {
|
||||
"notConfigured": "配置全部六个 GPIO 引脚以使用以太网。",
|
||||
"clk": "SPI 时钟 GPIO",
|
||||
"mosi": "SPI MOSI GPIO",
|
||||
"miso": "SPI MISO GPIO",
|
||||
"cs": "SPI CS GPIO",
|
||||
"irq": "中断 GPIO",
|
||||
"rst": "复位 GPIO",
|
||||
"note": "W5500 SPI 接线"
|
||||
},
|
||||
"wifi": {
|
||||
"ssid": "SSID",
|
||||
@@ -168,7 +187,14 @@
|
||||
"ip": "IP",
|
||||
"subnet": "子网掩码",
|
||||
"gateway": "网关",
|
||||
"dns": "DNS 服务器"
|
||||
"dns": "DNS 服务器",
|
||||
"connection": "连接",
|
||||
"connectionType": {
|
||||
"ethernet": "以太网",
|
||||
"wifi": "WiFi",
|
||||
"wifi-ap": "WiFi 接入点",
|
||||
"none": "无"
|
||||
}
|
||||
},
|
||||
"sta": {
|
||||
"channel": {
|
||||
|
||||
@@ -144,15 +144,34 @@
|
||||
"network": {
|
||||
"title": "Network - OpenTherm Gateway",
|
||||
"name": "Network settings",
|
||||
"type": {
|
||||
"title": "Connection method",
|
||||
"wifi": "Wi-Fi",
|
||||
"ethernet": "Ethernet"
|
||||
},
|
||||
"section": {
|
||||
"static": "Static settings",
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "Wi-Fi",
|
||||
"availableNetworks": "Available networks",
|
||||
"staSettings": "WiFi settings",
|
||||
"apSettings": "AP settings"
|
||||
},
|
||||
"scan": {
|
||||
"pos": "#",
|
||||
"info": "Info"
|
||||
"info": "Info",
|
||||
"unavailable": "Network scanning is available only in Wi-Fi mode."
|
||||
},
|
||||
|
||||
"ethernet": {
|
||||
"notConfigured": "Configure all six GPIOs to use Ethernet.",
|
||||
"clk": "SPI clock GPIO",
|
||||
"mosi": "SPI MOSI GPIO",
|
||||
"miso": "SPI MISO GPIO",
|
||||
"cs": "SPI CS GPIO",
|
||||
"irq": "Interrupt GPIO",
|
||||
"rst": "Reset GPIO",
|
||||
"note": "W5500 SPI wiring"
|
||||
},
|
||||
"wifi": {
|
||||
"ssid": "SSID",
|
||||
@@ -168,7 +187,14 @@
|
||||
"ip": "IP",
|
||||
"subnet": "Subnet",
|
||||
"gateway": "Gateway",
|
||||
"dns": "DNS"
|
||||
"dns": "DNS",
|
||||
"connection": "Connection",
|
||||
"connectionType": {
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "WiFi",
|
||||
"wifi-ap": "WiFi AP",
|
||||
"none": "None"
|
||||
}
|
||||
},
|
||||
"sta": {
|
||||
"channel": {
|
||||
|
||||
@@ -144,15 +144,34 @@
|
||||
"network": {
|
||||
"title": "Rete - OpenTherm Gateway",
|
||||
"name": "Impostazioni rete",
|
||||
"type": {
|
||||
"title": "Metodo di connessione",
|
||||
"wifi": "Wi-Fi",
|
||||
"ethernet": "Ethernet"
|
||||
},
|
||||
"section": {
|
||||
"static": "Impostazioni statico",
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "Wi-Fi",
|
||||
"availableNetworks": "Reti disponibili",
|
||||
"staSettings": "Impostazioni WiFi",
|
||||
"apSettings": "Impostazioni AP"
|
||||
},
|
||||
"scan": {
|
||||
"pos": "#",
|
||||
"info": "Info"
|
||||
"info": "Info",
|
||||
"unavailable": "La ricerca delle reti è disponibile solo in modalità Wi-Fi."
|
||||
},
|
||||
|
||||
"ethernet": {
|
||||
"notConfigured": "Configura tutti e sei i GPIO per utilizzare Ethernet.",
|
||||
"clk": "GPIO clock SPI",
|
||||
"mosi": "GPIO MOSI SPI",
|
||||
"miso": "GPIO MISO SPI",
|
||||
"cs": "GPIO CS SPI",
|
||||
"irq": "GPIO interrupt",
|
||||
"rst": "GPIO reset",
|
||||
"note": "Cablaggio SPI del W5500"
|
||||
},
|
||||
"wifi": {
|
||||
"ssid": "SSID",
|
||||
@@ -168,7 +187,14 @@
|
||||
"ip": "IP",
|
||||
"subnet": "Subnet",
|
||||
"gateway": "Gateway",
|
||||
"dns": "DNS"
|
||||
"dns": "DNS",
|
||||
"connection": "Connessione",
|
||||
"connectionType": {
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "WiFi",
|
||||
"wifi-ap": "WiFi AP",
|
||||
"none": "Nessuno"
|
||||
}
|
||||
},
|
||||
"sta": {
|
||||
"channel": {
|
||||
|
||||
@@ -144,15 +144,34 @@
|
||||
"network": {
|
||||
"title": "Netwerk - OpenTherm Gateway",
|
||||
"name": "Netwerkinstellingen",
|
||||
"type": {
|
||||
"title": "Verbindingsmethode",
|
||||
"wifi": "Wi-Fi",
|
||||
"ethernet": "Ethernet"
|
||||
},
|
||||
"section": {
|
||||
"static": "Statische instellingen",
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "Wi-Fi",
|
||||
"availableNetworks": "Beschikbare netwerken",
|
||||
"staSettings": "WiFi-instellingen",
|
||||
"apSettings": "AP-instellingen"
|
||||
},
|
||||
"scan": {
|
||||
"pos": "#",
|
||||
"info": "Info"
|
||||
"info": "Info",
|
||||
"unavailable": "Netwerken zoeken is alleen beschikbaar in de Wi-Fi-modus."
|
||||
},
|
||||
|
||||
"ethernet": {
|
||||
"notConfigured": "Configureer alle zes GPIO's om Ethernet te gebruiken.",
|
||||
"clk": "SPI-klok GPIO",
|
||||
"mosi": "SPI MOSI GPIO",
|
||||
"miso": "SPI MISO GPIO",
|
||||
"cs": "SPI CS GPIO",
|
||||
"irq": "Interrupt GPIO",
|
||||
"rst": "Reset GPIO",
|
||||
"note": "W5500 SPI-bedrading"
|
||||
},
|
||||
"wifi": {
|
||||
"ssid": "SSID",
|
||||
@@ -168,7 +187,14 @@
|
||||
"ip": "IP",
|
||||
"subnet": "Subnet",
|
||||
"gateway": "Gateway",
|
||||
"dns": "DNS"
|
||||
"dns": "DNS",
|
||||
"connection": "Verbinding",
|
||||
"connectionType": {
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "WiFi",
|
||||
"wifi-ap": "WiFi AP",
|
||||
"none": "Geen"
|
||||
}
|
||||
},
|
||||
"sta": {
|
||||
"channel": {
|
||||
|
||||
@@ -144,15 +144,34 @@
|
||||
"network": {
|
||||
"title": "Сеть - OpenTherm Gateway",
|
||||
"name": "Настройки сети",
|
||||
"type": {
|
||||
"title": "Способ подключения",
|
||||
"wifi": "Wi-Fi",
|
||||
"ethernet": "Ethernet"
|
||||
},
|
||||
"section": {
|
||||
"static": "Статические параметры",
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "Wi-Fi",
|
||||
"availableNetworks": "Доступные сети",
|
||||
"staSettings": "Настройки подключения",
|
||||
"apSettings": "Настройки точки доступа"
|
||||
},
|
||||
"scan": {
|
||||
"pos": "#",
|
||||
"info": "Инфо"
|
||||
"info": "Инфо",
|
||||
"unavailable": "Поиск сетей доступен только в режиме Wi-Fi."
|
||||
},
|
||||
|
||||
"ethernet": {
|
||||
"notConfigured": "Для подключения через Ethernet настройте все шесть GPIO.",
|
||||
"clk": "GPIO тактирования SPI",
|
||||
"mosi": "GPIO MOSI SPI",
|
||||
"miso": "GPIO MISO SPI",
|
||||
"cs": "GPIO CS SPI",
|
||||
"irq": "GPIO прерывания",
|
||||
"rst": "GPIO сброса",
|
||||
"note": "Подключение W5500 по SPI"
|
||||
},
|
||||
"wifi": {
|
||||
"ssid": "Имя сети",
|
||||
@@ -168,7 +187,14 @@
|
||||
"ip": "IP адрес",
|
||||
"subnet": "Адрес подсети",
|
||||
"gateway": "Адрес шлюза",
|
||||
"dns": "DNS адрес"
|
||||
"dns": "DNS адрес",
|
||||
"connection": "Подключение",
|
||||
"connectionType": {
|
||||
"ethernet": "Ethernet",
|
||||
"wifi": "WiFi",
|
||||
"wifi-ap": "WiFi AP",
|
||||
"none": "Нет"
|
||||
}
|
||||
},
|
||||
"sta": {
|
||||
"channel": {
|
||||
|
||||
@@ -50,15 +50,19 @@
|
||||
<th scope="row" data-i18n>network.params.mac</th>
|
||||
<td><b id="network-mac"></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" data-i18n>network.params.connection</th>
|
||||
<td><b id="network-connection"></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" data-i18n>network.wifi.connected</th>
|
||||
<td><i id="network-connected"></i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr id="network-ssid-row">
|
||||
<th scope="row" data-i18n>network.wifi.ssid</th>
|
||||
<td><b id="network-ssid"></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr id="network-signal-row">
|
||||
<th scope="row" data-i18n>network.wifi.signal</th>
|
||||
<td><b id="network-signal"></b> %</td>
|
||||
</tr>
|
||||
@@ -239,6 +243,7 @@
|
||||
|
||||
setTextValue('#network-hostname', result.network.hostname);
|
||||
setTextValue('#network-mac', result.network.mac);
|
||||
setTextValue('#network-connection', i18n(`network.params.connectionType.${result.network.connection_type}`));
|
||||
setStatus(
|
||||
'#network-connected',
|
||||
result.network.connected ? "success" : "error",
|
||||
@@ -246,6 +251,11 @@
|
||||
);
|
||||
setTextValue('#network-ssid', result.network.ssid);
|
||||
setValue('#network-signal', result.network.signal_quality);
|
||||
// SSID and signal strength describe only the Wi-Fi uplink.
|
||||
const wifiUplink = result.network.connection_type === "wifi";
|
||||
document.getElementById("network-ssid-row")?.classList.toggle("hidden", !wifiUplink);
|
||||
document.getElementById("network-signal-row")?.classList.toggle("hidden", !wifiUplink);
|
||||
|
||||
setTextValue('#network-ip', result.network.ip);
|
||||
setTextValue('#network-subnet', result.network.subnet);
|
||||
setTextValue('#network-gateway', result.network.gateway);
|
||||
|
||||
+170
-49
@@ -46,6 +46,14 @@
|
||||
<input type="text" name="hostname" maxlength="24" pattern="[A-Za-z0-9]+[A-Za-z0-9\-]+[A-Za-z0-9]+" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.type.title</span>
|
||||
<select name="type">
|
||||
<option value="2" data-i18n>network.type.wifi</option>
|
||||
<option value="3" hidden disabled data-i18n>network.type.ethernet</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="use_dhcp" value="true">
|
||||
<span data-i18n>network.params.dhcp</span>
|
||||
@@ -56,7 +64,7 @@
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.params.ip</span>
|
||||
<input type="text" name="static_config[ip]" value="true" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required>
|
||||
<input type="text" name="static_config[ip]" maxlength="16" pattern="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
@@ -79,34 +87,43 @@
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
|
||||
<article id="wifi-section">
|
||||
<div>
|
||||
<hgroup>
|
||||
<h2 data-i18n>network.section.wifi</h2>
|
||||
<p></p>
|
||||
</hgroup>
|
||||
|
||||
<hgroup>
|
||||
<h3 data-i18n>network.section.availableNetworks</h3>
|
||||
<p></p>
|
||||
</hgroup>
|
||||
|
||||
<form action="/api/network/scan" id="network-scan">
|
||||
<div style="max-height: 25rem;" class="overflow-auto">
|
||||
<table id="networks" role="grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" data-i18n>network.scan.pos</th>
|
||||
<th scope="col" data-i18n>network.wifi.ssid</th>
|
||||
<th scope="col" data-i18n>network.scan.info</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<fieldset id="wifi-scan-controls" disabled>
|
||||
<div style="max-height: 25rem;" class="overflow-auto">
|
||||
<table id="networks" role="grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" data-i18n>network.scan.pos</th>
|
||||
<th scope="col" data-i18n>network.wifi.ssid</th>
|
||||
<th scope="col" data-i18n>network.scan.info</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button type="submit" data-i18n>button.refresh</button>
|
||||
<p id="scan-unavailable" class="hidden" data-i18n>network.scan.unavailable</p>
|
||||
<button type="submit" data-i18n>button.refresh</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
<div>
|
||||
<hgroup>
|
||||
<h2 data-i18n>network.section.staSettings</h2>
|
||||
<h3 data-i18n>network.section.staSettings</h3>
|
||||
<p></p>
|
||||
</hgroup>
|
||||
|
||||
@@ -114,49 +131,100 @@
|
||||
<form action="/api/network/settings" id="sta-settings" class="hidden">
|
||||
<label>
|
||||
<span data-i18n>network.wifi.ssid</span>
|
||||
<input type="text" name="sta[ssid]" maxlength="32" required>
|
||||
<input type="text" name="wifi[sta][ssid]" maxlength="32" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.wifi.password</span>
|
||||
<input type="password" name="sta[password]" maxlength="64" required>
|
||||
<input type="password" name="wifi[sta][password]" maxlength="64" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.wifi.channel</span>
|
||||
<input type="number" inputmode="numeric" name="sta[channel]" min="0" max="12" step="1" required>
|
||||
<input type="number" inputmode="numeric" name="wifi[sta][channel]" min="0" max="12" step="1" required>
|
||||
<small data-i18n>network.sta.channel.note</small>
|
||||
</label>
|
||||
|
||||
<button type="submit" data-i18n>button.save</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
<div>
|
||||
<hgroup>
|
||||
<h3 data-i18n>network.section.apSettings</h3>
|
||||
<p></p>
|
||||
</hgroup>
|
||||
|
||||
<div id="ap-settings-busy" aria-busy="true"></div>
|
||||
<form action="/api/network/settings" id="ap-settings" class="hidden">
|
||||
<label>
|
||||
<span data-i18n>network.wifi.ssid</span>
|
||||
<input type="text" name="wifi[ap][ssid]" maxlength="32" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.wifi.password</span>
|
||||
<input type="text" name="wifi[ap][password]" maxlength="64" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.wifi.channel</span>
|
||||
<input type="number" inputmode="numeric" name="wifi[ap][channel]" min="1" max="12" step="1" required>
|
||||
</label>
|
||||
|
||||
<button type="submit" data-i18n>button.save</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<article id="ethernet-section" class="hidden">
|
||||
<div>
|
||||
<hgroup>
|
||||
<h2 data-i18n>network.section.apSettings</h2>
|
||||
<h3 data-i18n>network.section.ethernet</h3>
|
||||
<p></p>
|
||||
</hgroup>
|
||||
|
||||
<div id="ap-settings-busy" aria-busy="true"></div>
|
||||
<form action="/api/network/settings" id="ap-settings" class="hidden">
|
||||
<label>
|
||||
<span data-i18n>network.wifi.ssid</span>
|
||||
<input type="text" name="ap[ssid]" maxlength="32" required>
|
||||
</label>
|
||||
<div id="ethernet-settings-busy" aria-busy="true"></div>
|
||||
<form action="/api/network/settings" id="ethernet-settings" class="hidden">
|
||||
<small id="ethernet-not-configured" class="hidden" data-i18n>network.ethernet.notConfigured</small>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.wifi.password</span>
|
||||
<input type="text" name="ap[password]" maxlength="64" required>
|
||||
</label>
|
||||
<div class="grid">
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.clk</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][clk]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.wifi.channel</span>
|
||||
<input type="number" inputmode="numeric" name="ap[channel]" min="1" max="12" step="1" required>
|
||||
</label>
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.mosi</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][mosi]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.miso</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][miso]" min="0" max="254" step="1">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.cs</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][cs]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.irq</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][irq]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.rst</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][rst]" min="0" max="254" step="1">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<small data-i18n>network.ethernet.note</small>
|
||||
|
||||
<button type="submit" data-i18n>button.save</button>
|
||||
</form>
|
||||
@@ -181,7 +249,16 @@
|
||||
const lang = new Lang(document.getElementById('lang'));
|
||||
await lang.build();
|
||||
|
||||
let networkType = 2;
|
||||
|
||||
const fillData = (data) => {
|
||||
networkType = data.type;
|
||||
setSelectValue("[name='type']", networkType);
|
||||
|
||||
const canScan = networkType === 2;
|
||||
document.getElementById('wifi-scan-controls').disabled = !canScan;
|
||||
document.querySelector('#scan-unavailable').classList.toggle('hidden', canScan);
|
||||
|
||||
setInputValue("[name='hostname']", data.hostname);
|
||||
setCheckboxValue("[name='use_dhcp']", data.use_dhcp);
|
||||
setInputValue("[name='static_config[ip]']", data.static_config.ip);
|
||||
@@ -190,34 +267,78 @@
|
||||
setInputValue("[name='static_config[dns]']", data.static_config.dns);
|
||||
setBusy('#network-settings-busy', '#network-settings', false);
|
||||
|
||||
setInputValue("[name='sta[ssid]']", data.sta.ssid);
|
||||
setInputValue("[name='sta[password]']", data.sta.password);
|
||||
setInputValue("[name='sta[channel]']", data.sta.channel);
|
||||
const ethernet = data.ethernet || {};
|
||||
const ethernetConfigured = !!ethernet.configured;
|
||||
const ethernetGpio = ethernet.gpio || {};
|
||||
const gpioValue = (value) => (value ?? 255) < 255 ? value : '';
|
||||
|
||||
setInputValue("[name='ethernet[gpio][clk]']", gpioValue(ethernetGpio.clk));
|
||||
setInputValue("[name='ethernet[gpio][mosi]']", gpioValue(ethernetGpio.mosi));
|
||||
setInputValue("[name='ethernet[gpio][miso]']", gpioValue(ethernetGpio.miso));
|
||||
setInputValue("[name='ethernet[gpio][cs]']", gpioValue(ethernetGpio.cs));
|
||||
setInputValue("[name='ethernet[gpio][irq]']", gpioValue(ethernetGpio.irq));
|
||||
setInputValue("[name='ethernet[gpio][rst]']", gpioValue(ethernetGpio.rst));
|
||||
|
||||
document.getElementById('ethernet-not-configured')?.classList.toggle('hidden', ethernetConfigured);
|
||||
|
||||
setBusy('#ethernet-settings-busy', '#ethernet-settings', false);
|
||||
|
||||
setInputValue("[name='wifi[sta][ssid]']", data.wifi.sta.ssid);
|
||||
setInputValue("[name='wifi[sta][password]']", data.wifi.sta.password);
|
||||
setInputValue("[name='wifi[sta][channel]']", data.wifi.sta.channel);
|
||||
setBusy('#sta-settings-busy', '#sta-settings', false);
|
||||
|
||||
setInputValue("[name='ap[ssid]']", data.ap.ssid);
|
||||
setInputValue("[name='ap[password]']", data.ap.password);
|
||||
setInputValue("[name='ap[channel]']", data.ap.channel);
|
||||
setInputValue("[name='wifi[ap][ssid]']", data.wifi.ap.ssid);
|
||||
setInputValue("[name='wifi[ap][password]']", data.wifi.ap.password);
|
||||
setInputValue("[name='wifi[ap][channel]']", data.wifi.ap.channel);
|
||||
setBusy('#ap-settings-busy', '#ap-settings', false);
|
||||
};
|
||||
|
||||
const applyCapabilities = (info) => {
|
||||
// pages and firmware ship together: the section stays hidden unless the build says it can do ethernet
|
||||
const supported = info?.features?.ethernet === true;
|
||||
|
||||
document.getElementById('ethernet-section')?.classList.toggle('hidden', !supported);
|
||||
const ethernetOption = document.querySelector("[name='type'] option[value='3']");
|
||||
ethernetOption.hidden = !supported;
|
||||
ethernetOption.disabled = !supported;
|
||||
|
||||
return supported;
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/network/settings", {
|
||||
cache: "no-cache",
|
||||
credentials: "include"
|
||||
});
|
||||
|
||||
const [response, infoResponse] = await Promise.all([
|
||||
fetch("/api/network/settings", {
|
||||
cache: "no-cache",
|
||||
credentials: "include"
|
||||
}),
|
||||
fetch("/api/info", {
|
||||
cache: "no-cache",
|
||||
credentials: "include"
|
||||
})
|
||||
]);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Response not valid');
|
||||
}
|
||||
|
||||
const info = infoResponse.ok ? await infoResponse.json() : null;
|
||||
const ethernetSupported = applyCapabilities(info);
|
||||
|
||||
const result = await response.json();
|
||||
fillData(result);
|
||||
|
||||
setupForm('#network-settings', fillData, ['hostname', 'static_config.ip', 'static_config.gateway', 'static_config.subnet', 'static_config.dns']);
|
||||
setupNetworkScanForm('#network-scan', '#networks');
|
||||
setupForm('#sta-settings', fillData, ['sta.ssid', 'sta.password']);
|
||||
setupForm('#ap-settings', fillData, ['ap.ssid', 'ap.password']);
|
||||
|
||||
// Keep scans disabled if an earlier request finishes after the connection method changes.
|
||||
setupNetworkScanForm('#network-scan', '#networks', networkType === 2);
|
||||
|
||||
if (ethernetSupported) {
|
||||
setupForm('#ethernet-settings', fillData);
|
||||
}
|
||||
|
||||
setupForm('#sta-settings', fillData, ['wifi.sta.ssid', 'wifi.sta.password']);
|
||||
setupForm('#ap-settings', fillData, ['wifi.ap.ssid', 'wifi.ap.password']);
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
@@ -97,6 +97,44 @@ const convertLegacyBackup = (data) => {
|
||||
|
||||
const result = convert(data);
|
||||
|
||||
const network = result?.network;
|
||||
if (network !== null && typeof network === 'object' && !Array.isArray(network)) {
|
||||
const hasLegacyAp = Object.prototype.hasOwnProperty.call(network, 'ap');
|
||||
const hasLegacySta = Object.prototype.hasOwnProperty.call(network, 'sta');
|
||||
if (hasLegacyAp || hasLegacySta) {
|
||||
const wifi = network.wifi !== null && typeof network.wifi === 'object' && !Array.isArray(network.wifi)
|
||||
? network.wifi : Object.create(null);
|
||||
|
||||
if (hasLegacyAp && !Object.prototype.hasOwnProperty.call(wifi, 'ap')) {
|
||||
wifi.ap = network.ap;
|
||||
}
|
||||
if (hasLegacySta && !Object.prototype.hasOwnProperty.call(wifi, 'sta')) {
|
||||
wifi.sta = network.sta;
|
||||
}
|
||||
network.wifi = wifi;
|
||||
delete network.ap;
|
||||
delete network.sta;
|
||||
}
|
||||
|
||||
if (!Object.prototype.hasOwnProperty.call(network, 'type')) {
|
||||
if (typeof network.ethernet?.enabled === 'boolean') {
|
||||
network.type = network.ethernet.enabled ? 3 : 2;
|
||||
|
||||
} else if (hasLegacyAp || hasLegacySta) {
|
||||
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;
|
||||
}
|
||||
delete network.ethernet.pins;
|
||||
delete network.ethernet.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
const opentherm = result?.settings?.opentherm;
|
||||
if (opentherm !== null && typeof opentherm === 'object') {
|
||||
delete opentherm.unit_system;
|
||||
|
||||
@@ -92,7 +92,7 @@ const setupForm = (formSelector, onResultCallback = null, noCastItems = []) => {
|
||||
});
|
||||
}
|
||||
|
||||
const setupNetworkScanForm = (formSelector, tableSelector) => {
|
||||
const setupNetworkScanForm = (formSelector, tableSelector, autorun = true) => {
|
||||
const form = document.querySelector(formSelector);
|
||||
if (!form) {
|
||||
console.error("form not found");
|
||||
@@ -261,7 +261,9 @@ const setupNetworkScanForm = (formSelector, tableSelector) => {
|
||||
};
|
||||
|
||||
form.addEventListener('submit', onSubmitFn);
|
||||
onSubmitFn();
|
||||
if (autorun) {
|
||||
onSubmitFn();
|
||||
}
|
||||
}
|
||||
|
||||
const setBusy = (busySelector, contentSelector, value, parent = undefined) => {
|
||||
|
||||
Reference in new issue
Block a user