mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-12-04 20:23:06 +05:00
* feat: add LAN8720 support (#310)
* feat: add LAN8720 support and extend ESP32 Ethernet profiles * fix: fit BLE and Ethernet in classic ESP32 OTA slots
This commit is contained in:
1 parent
cea8231015
commit
f6ff8cfe31
16 files changed
+441
-132
No files matched your search
+97
-15
@@ -101,37 +101,84 @@
|
||||
<div>
|
||||
<p class="unsupported hidden" data-i18n>network.ethernet.unavailable</p>
|
||||
<fieldset class="supported">
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.controller</span>
|
||||
<select name="ethernet[type]">
|
||||
<option value="0">NONE</option>
|
||||
</select>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="ethernet-w5500">
|
||||
<legend><b>W5500</b></legend>
|
||||
<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">
|
||||
<input type="number" inputmode="numeric" name="ethernet[w5500][clk]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.mosi</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[gpio][mosi]" min="0" max="254" step="1">
|
||||
<input type="number" inputmode="numeric" name="ethernet[w5500][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">
|
||||
<input type="number" inputmode="numeric" name="ethernet[w5500][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">
|
||||
<input type="number" inputmode="numeric" name="ethernet[w5500][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">
|
||||
<input type="number" inputmode="numeric" name="ethernet[w5500][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">
|
||||
<input type="number" inputmode="numeric" name="ethernet[w5500][rst]" min="0" max="254" step="1">
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="ethernet-lan8720">
|
||||
<legend><b>LAN8720</b></legend>
|
||||
<div class="grid">
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.phyAddr</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[lan8720][phy_addr]" min="0" max="31" step="1" required>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.clockMode</span>
|
||||
<select name="ethernet[lan8720][clock_mode]">
|
||||
<option value="0">GPIO0 IN</option>
|
||||
<option value="1">GPIO0 OUT</option>
|
||||
<option value="2">GPIO16 OUT</option>
|
||||
<option value="3">GPIO17 OUT</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.mdc</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[lan8720][mdc]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.mdio</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[lan8720][mdio]" min="0" max="254" step="1">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<span data-i18n>network.ethernet.power</span>
|
||||
<input type="number" inputmode="numeric" name="ethernet[lan8720][power]" min="0" max="254" step="1">
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -418,18 +465,35 @@
|
||||
const lang = new Lang(document.getElementById('lang'));
|
||||
await lang.build();
|
||||
|
||||
const ethernetType = document.querySelector("[name='ethernet[type]']");
|
||||
|
||||
const fillNetworkSettings = (settings) => {
|
||||
setSelectValue("[name='type']", settings.type);
|
||||
setSelectValue("[name='type']", ethernetType.disabled ? 2 : settings.type);
|
||||
setInputValue("[name='hostname']", settings.hostname);
|
||||
setCheckboxValue("[name='use_dhcp']", settings.use_dhcp);
|
||||
for (const field of ['ip', 'gateway', 'subnet', 'dns']) {
|
||||
setInputValue(`[name='static_config[${field}]']`, settings.static_config[field]);
|
||||
}
|
||||
|
||||
if (settings.ethernet?.gpio) {
|
||||
for (const pin of ['clk', 'mosi', 'miso', 'cs', 'irq', 'rst']) {
|
||||
const value = settings.ethernet.gpio[pin];
|
||||
setInputValue(`[name='ethernet[gpio][${pin}]']`, value < 255 ? value : '');
|
||||
const ethernet = settings.ethernet;
|
||||
if (ethernet) {
|
||||
ethernetType.value = ethernet.type;
|
||||
|
||||
if (ethernet.w5500) {
|
||||
for (const gpio of ['clk', 'mosi', 'miso', 'cs', 'irq', 'rst']) {
|
||||
const value = ethernet.w5500[gpio];
|
||||
setInputValue(`[name='ethernet[w5500][${gpio}]']`, value < 255 ? value : '');
|
||||
}
|
||||
}
|
||||
|
||||
if (ethernet.lan8720) {
|
||||
for (const gpio of ['mdc', 'mdio', 'power']) {
|
||||
const value = ethernet.lan8720[gpio];
|
||||
setInputValue(`[name='ethernet[lan8720][${gpio}]']`, value < 255 ? value : '');
|
||||
}
|
||||
|
||||
setInputValue("[name='ethernet[lan8720][phy_addr]']", ethernet.lan8720.phy_addr);
|
||||
setSelectValue("[name='ethernet[lan8720][clock_mode]']", ethernet.lan8720.clock_mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,11 +518,29 @@
|
||||
}
|
||||
|
||||
const settings = await response.json();
|
||||
if (!settings.ethernet) {
|
||||
const ethernet = settings.ethernet;
|
||||
if (ethernet?.w5500) {
|
||||
ethernetType.add(new Option('W5500', '1'));
|
||||
|
||||
} else {
|
||||
document.getElementById('ethernet-w5500').remove();
|
||||
}
|
||||
|
||||
if (ethernet?.lan8720) {
|
||||
ethernetType.add(new Option('LAN8720', '2'));
|
||||
|
||||
} else {
|
||||
document.getElementById('ethernet-lan8720').remove();
|
||||
}
|
||||
|
||||
// The API includes settings only for Ethernet drivers built into this firmware.
|
||||
if (!ethernet?.w5500 && !ethernet?.lan8720) {
|
||||
show('.ethernet .unsupported');
|
||||
const gpioFields = document.querySelector('.ethernet .supported');
|
||||
gpioFields.classList.add('hidden');
|
||||
gpioFields.disabled = true;
|
||||
hide('.ethernet .supported');
|
||||
ethernetType.disabled = true;
|
||||
|
||||
// Value 3 in the network mode selector is Ethernet (NetworkMode::ETH).
|
||||
document.querySelector("[name='type'] [value='3']").disabled = true;
|
||||
}
|
||||
|
||||
fillNetworkSettings(settings);
|
||||
|
||||
Reference in new issue
Block a user