mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
Fix scoping issue when setting the IP address #100
This commit is contained in:
parent
9fdf5896d1
commit
f62dcef161
5 changed files with 22 additions and 4 deletions
|
|
@ -216,9 +216,10 @@ bool Network::connectWired() {
|
||||||
if(!this->ethStarted) {
|
if(!this->ethStarted) {
|
||||||
this->ethStarted = true;
|
this->ethStarted = true;
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
if(!settings.IP.dhcp)
|
if(!settings.IP.dhcp) {
|
||||||
if(!ETH.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
|
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);
|
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
ETH.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||||
WiFi.onEvent(this->networkEvent);
|
WiFi.onEvent(this->networkEvent);
|
||||||
|
|
@ -271,9 +272,10 @@ bool Network::connectWiFi() {
|
||||||
this->connectStart = millis();
|
this->connectStart = millis();
|
||||||
Serial.print("Set hostname to:");
|
Serial.print("Set hostname to:");
|
||||||
Serial.println(WiFi.getHostname());
|
Serial.println(WiFi.getHostname());
|
||||||
if(!settings.IP.dhcp)
|
if(!settings.IP.dhcp) {
|
||||||
if(!WiFi.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
|
if(!WiFi.config(settings.IP.ip, settings.IP.gateway, settings.IP.subnet, settings.IP.dns1, settings.IP.dns2))
|
||||||
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
|
||||||
WiFi.setSleep(false);
|
WiFi.setSleep(false);
|
||||||
|
|
|
||||||
11
Somfy.cpp
11
Somfy.cpp
|
|
@ -1466,11 +1466,19 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
|
||||||
this->emitState();
|
this->emitState();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case somfy_commands::Prog:
|
||||||
|
case somfy_commands::MyUp:
|
||||||
|
case somfy_commands::MyDown:
|
||||||
|
case somfy_commands::MyUpDown:
|
||||||
|
case somfy_commands::UpDown:
|
||||||
|
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
|
||||||
|
break;
|
||||||
|
|
||||||
case somfy_commands::Flag:
|
case somfy_commands::Flag:
|
||||||
this->flags &= ~(static_cast<uint8_t>(somfy_flags_t::SunFlag));
|
this->flags &= ~(static_cast<uint8_t>(somfy_flags_t::SunFlag));
|
||||||
somfy.isDirty = true;
|
somfy.isDirty = true;
|
||||||
this->emitState();
|
this->emitState();
|
||||||
|
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
|
||||||
break;
|
break;
|
||||||
case somfy_commands::SunFlag:
|
case somfy_commands::SunFlag:
|
||||||
{
|
{
|
||||||
|
|
@ -1486,6 +1494,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
|
||||||
}
|
}
|
||||||
somfy.isDirty = true;
|
somfy.isDirty = true;
|
||||||
this->emitState();
|
this->emitState();
|
||||||
|
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case somfy_commands::Up:
|
case somfy_commands::Up:
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,12 @@ void setup() {
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// put your main code here, to run repeatedly:
|
// put your main code here, to run repeatedly:
|
||||||
if(rebootDelay.reboot && millis() > rebootDelay.rebootTime) ESP.restart();
|
if(rebootDelay.reboot && millis() > rebootDelay.rebootTime) {
|
||||||
|
Serial.print("Rebooting after ");
|
||||||
|
Serial.print(rebootDelay.rebootTime);
|
||||||
|
Serial.println("ms");
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
net.loop();
|
net.loop();
|
||||||
somfy.loop();
|
somfy.loop();
|
||||||
if(net.connected()) {
|
if(net.connected()) {
|
||||||
|
|
|
||||||
Binary file not shown.
2
Web.cpp
2
Web.cpp
|
|
@ -1684,6 +1684,7 @@ void Web::begin() {
|
||||||
});
|
});
|
||||||
server.on("/updateFirmware", HTTP_POST, []() {
|
server.on("/updateFirmware", HTTP_POST, []() {
|
||||||
webServer.sendCORSHeaders();
|
webServer.sendCORSHeaders();
|
||||||
|
somfy.transceiver.end(); // Shut down the radio so we do not get any interrupts during this process.
|
||||||
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
||||||
if (Update.hasError())
|
if (Update.hasError())
|
||||||
server.send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Error updating firmware: \"}");
|
server.send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Error updating firmware: \"}");
|
||||||
|
|
@ -1740,6 +1741,7 @@ void Web::begin() {
|
||||||
});
|
});
|
||||||
server.on("/updateApplication", HTTP_POST, []() {
|
server.on("/updateApplication", HTTP_POST, []() {
|
||||||
webServer.sendCORSHeaders();
|
webServer.sendCORSHeaders();
|
||||||
|
somfy.transceiver.end(); // Shut down the radio so we do not get any interrupts during this process.
|
||||||
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
||||||
server.sendHeader("Connection", "close");
|
server.sendHeader("Connection", "close");
|
||||||
server.send(200, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Updating Application: \"}");
|
server.send(200, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Updating Application: \"}");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue