Fix static ip for Ethernet #268 Fix storage for Wifi Fallback #269

This commit is contained in:
Robert Strouse 2024-02-10 10:43:14 -08:00
parent 4e0d89e7db
commit bf8da394d5
7 changed files with 26 additions and 15 deletions

View file

@ -231,18 +231,12 @@ bool Network::connectWired() {
if(!this->ethStarted) {
this->ethStarted = true;
WiFi.mode(WIFI_OFF);
if(!settings.IP.dhcp) {
if(!ETH.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
}
else
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
WiFi.onEvent(this->networkEvent);
if(settings.hostname[0] != '\0') ETH.setHostname(settings.hostname);
Serial.print("Set hostname to:");
Serial.println(ETH.getHostname());
if(!ETH.begin(settings.Ethernet.phyAddress, settings.Ethernet.PWRPin, settings.Ethernet.MDCPin, settings.Ethernet.MDIOPin, settings.Ethernet.phyType, settings.Ethernet.CLKMode)) {
Serial.println("Ethernet Begin failed");
if(settings.connType == conn_types::ethernetpref) {
this->wifiFallback = true;
@ -251,6 +245,14 @@ bool Network::connectWired() {
return false;
}
else {
if(!settings.IP.dhcp) {
if(!ETH.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
Serial.println("Unable to configure static IP address....");
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
}
else
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
uint32_t wait = millis();
while(millis() - wait < 7000) {
if(this->connected()) return true;

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -3,11 +3,11 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="main.css?v=2.4.0" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.4.0" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.4.0" type="text/css" />
<link rel="stylesheet" href="main.css?v=2.4.0a" type="text/css" />
<link rel="stylesheet" href="widgets.css?v=2.4.0a" type="text/css" />
<link rel="stylesheet" href="icons.css?v=2.4.0a" type="text/css" />
<link rel="icon" type="image/png" href="favicon.png" />
<script type="text/javascript" src="index.js?v=2.4.0"></script>
<script type="text/javascript" src="index.js?v=2.4.0a"></script>
</head>
<body>
<div id="divContainer" class="container main" data-auth="false">
@ -158,7 +158,7 @@
<input id="cbHardwired" name="hardwired" data-bind="ethernet.hardwired" type="checkbox" style="display:inline-block;" onclick="wifi.useEthernetClicked();" />
<label for="cbHardwired" style="display:inline-block;cursor:pointer;">Use Ethernet</label>
<div id="divFallbackWireless" style="display:inline-block;padding-left:7px;">
<input id="cbFallbackWireless" name="fallbackwireless" data-bind="wirelessFallback" type="checkbox" style="display:inline-block;" />
<input id="cbFallbackWireless" name="fallbackwireless" data-bind="ethernet.wirelessFallback" type="checkbox" style="display:inline-block;" />
<label for="cbFallbackWireless" style="display:inline-block;cursor:pointer;">Fallback to Wireless</label>
</div>
</div>
@ -295,7 +295,7 @@
</div>
</div>
<div id="divSomfySettings" style="display:none;">
<div class="subtab-container"><span class="selected" data-grpid="divSomfyRooms">Rooms</span><span class="" data-grpid="divSomfyMotors">Shades</span><span data-grpid="divSomfyGroups">Groups</span><span data-grpid="divRepeater">Repeater</span><span data-grpid="divVirtualRemote">Virtual Remote</span></div>
<div class="subtab-container"><span class="selected" data-grpid="divSomfyRooms">Rooms</span><span class="" data-grpid="divSomfyMotors">Shades</span><span data-grpid="divSomfyGroups">Groups</span><span data-grpid="divRepeater">Repeater</span><span class="tabname-virtual-remote" data-grpid="divVirtualRemote"></span></div>
<div id="divSomfyRooms" class="subtab-content" style="padding-top:10px;">
<div id="divRoomListContainer">
<div style="font-size:.8em;">Drag each item to set the order in which they appear in the list.</div>

View file

@ -1807,7 +1807,7 @@ class Wifi {
saveNetwork() {
let pnl = document.getElementById('divNetAdapter');
let obj = ui.fromElement(pnl);
obj.connType = obj.ethernet.hardwired ? obj.ethernet.wirelessFallback ? 3 : 2 : 1;
obj.connType = obj.ethernet.hardwired ? (obj.ethernet.wirelessFallback ? 3 : 2) : 1;
console.log(obj);
if (obj.connType >= 2) {
let boardType = this.ethBoardTypes.find(elem => obj.ethernet.boardType === elem.val);
@ -3782,7 +3782,9 @@ class Somfy {
let div = document.createElement('div');
let html = `<div id="divLinkRepeater" class="instructions" data-type="link-repeatremote" style="border-radius:27px;">`;
html += '<div>Press any button on the remote to repeat its signals.</div>';
html += '<div class="sub-message">When assigned, ESPSomfy RTS will act as a repeater and repeat any frames for the identified remotes. Only repeat remotes when ESPSomfy RTS reliably hears the remote but the motor does not. Repeating unnecessary radio signals will degrade radio performance.</div>'
html += '<div class="sub-message">When assigned, ESPSomfy RTS will act as a repeater and repeat any frames for the identified remotes.</div>'
html += '<div class="sub-message" style="font-size:14px;">Only assign a repeater when ESPSomfy RTS reliably hears a physical remote but the motor does not. Repeating unnecessary radio signals will degrade radio performance and never assign the same repeater to more than one ESPSomfy RTS device. You will have created an insidious echo chamber.</div>'
html += '<div class="sub-message">Once a signal is detected from the remote this window will close and the remote signals will be repeated.</div>'
html += '<hr></hr>';
html += `<div><div class="button-container"><button id="btnStopLinking" type="button" style="padding-left:20px;padding-right:20px;" onclick="document.getElementById('divLinkRepeater').remove();">Cancel</button></div>`;

View file

@ -315,6 +315,10 @@
.room-selector-list .room-row:hover {
color: var(--shade-color, gray);
}
span.tabname-virtual-remote:after {
content: "Virtual Remote";
}
@media only screen and (max-device-width: 480px) {
body {
margin-top: 0px;
@ -324,4 +328,7 @@
padding-left: 10px;
padding-right: 10px;
}
span.tabname-virtual-remote:after {
content: "Remote";
}
}