mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-12 18:42:10 +01:00
Fix static IP for ETH connections #268
This commit is contained in:
parent
bf8da394d5
commit
bbefe7fe6d
5 changed files with 19 additions and 17 deletions
2
.github/ISSUE_TEMPLATE/BUG-REPORT.yaml
vendored
2
.github/ISSUE_TEMPLATE/BUG-REPORT.yaml
vendored
|
|
@ -54,7 +54,7 @@ body:
|
|||
- type: textarea
|
||||
id: reprod
|
||||
attributes:
|
||||
label: "How to reproduce it (setp by step)"
|
||||
label: "How to reproduce it (step by step)"
|
||||
description: Please enter an explicit description of your issue
|
||||
value: |
|
||||
1. Go to...
|
||||
|
|
|
|||
12
Network.cpp
12
Network.cpp
|
|
@ -236,7 +236,6 @@ bool Network::connectWired() {
|
|||
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;
|
||||
|
|
@ -246,9 +245,10 @@ bool Network::connectWired() {
|
|||
}
|
||||
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);
|
||||
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);
|
||||
|
|
@ -467,7 +467,9 @@ bool Network::openSoftAP() {
|
|||
|
||||
// If no clients have connected in 3 minutes from starting this server reboot this pig. This will
|
||||
// force a reboot cycle until we have some response. That is unless the SSID has been cleared.
|
||||
if(clients == 0 && strlen(settings.WIFI.ssid) > 0 && millis() - startTime > 3 * 60000) {
|
||||
if(clients == 0 &&
|
||||
(strlen(settings.WIFI.ssid) > 0 || settings.connType == conn_types::ethernet || settings.connType == conn_types::ethernetpref) &&
|
||||
millis() - startTime > 3 * 60000) {
|
||||
Serial.println();
|
||||
Serial.println("Stopping AP Mode");
|
||||
WiFi.softAPdisconnect(true);
|
||||
|
|
|
|||
22
Somfy.cpp
22
Somfy.cpp
|
|
@ -3193,19 +3193,16 @@ void SomfyShadeController::emitState(uint8_t num) {
|
|||
}
|
||||
void SomfyShadeController::publish() {
|
||||
this->updateGroupFlags();
|
||||
StaticJsonDocument<128> docShades;
|
||||
StaticJsonDocument<128> docGroups;
|
||||
JsonArray arrShades = docShades.to<JsonArray>();
|
||||
JsonArray arrGroups = docGroups.to<JsonArray>();
|
||||
char arrIds[128] = "[";
|
||||
for(uint8_t i = 0; i < SOMFY_MAX_SHADES; i++) {
|
||||
SomfyShade *shade = &this->shades[i];
|
||||
if(shade->getShadeId() == 255) {
|
||||
continue;
|
||||
}
|
||||
arrShades.add(shade->getShadeId());
|
||||
if(shade->getShadeId() == 255) continue;
|
||||
if(strlen(arrIds) > 1) strcat(arrIds, ",");
|
||||
itoa(shade->getShadeId(), &arrIds[strlen(arrIds)], 10);
|
||||
shade->publish();
|
||||
}
|
||||
mqtt.publish("shades", arrShades, true);
|
||||
strcat(arrIds, "]");
|
||||
mqtt.publish("shades", arrIds, true);
|
||||
for(uint8_t i = 1; i <= SOMFY_MAX_SHADES; i++) {
|
||||
SomfyShade *shade = this->getShadeById(i);
|
||||
if(shade) continue;
|
||||
|
|
@ -3213,18 +3210,21 @@ void SomfyShadeController::publish() {
|
|||
SomfyShade::unpublish(i);
|
||||
}
|
||||
}
|
||||
strcpy(arrIds, "[");
|
||||
for(uint8_t i = 0; i < SOMFY_MAX_GROUPS; i++) {
|
||||
SomfyGroup *group = &this->groups[i];
|
||||
if(group->getGroupId() == 255) continue;
|
||||
arrGroups.add(group->getGroupId());
|
||||
if(strlen(arrIds) > 1) strcat(arrIds, ",");
|
||||
itoa(group->getGroupId(), &arrIds[strlen(arrIds)], 10);
|
||||
group->publish();
|
||||
}
|
||||
strcat(arrIds, "]");
|
||||
mqtt.publish("groups", arrIds, true);
|
||||
for(uint8_t i = 1; i <= SOMFY_MAX_GROUPS; i++) {
|
||||
SomfyGroup *group = this->getGroupById(i);
|
||||
if(group) continue;
|
||||
else SomfyGroup::unpublish(i);
|
||||
}
|
||||
mqtt.publish("groups", arrGroups, true);
|
||||
}
|
||||
uint8_t SomfyShadeController::getNextShadeId() {
|
||||
// There is no shortcut for this since the deletion of
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue