Skip to content

Commit

Permalink
Fix scoping issue when setting the IP address rstrouse#100
Browse files Browse the repository at this point in the history
  • Loading branch information
rstrouse committed Jul 16, 2023
1 parent 9fdf589 commit f62dcef
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ bool Network::connectWired() {
if(!this->ethStarted) {
this->ethStarted = true;
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))
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);
Expand Down Expand Up @@ -271,9 +272,10 @@ bool Network::connectWiFi() {
this->connectStart = millis();
Serial.print("Set hostname to:");
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))
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
}
else
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
WiFi.setSleep(false);
Expand Down
11 changes: 10 additions & 1 deletion Somfy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,11 +1466,19 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
this->emitState();
}
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:
this->flags &= ~(static_cast<uint8_t>(somfy_flags_t::SunFlag));
somfy.isDirty = true;
this->emitState();
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
break;
case somfy_commands::SunFlag:
{
Expand All @@ -1486,6 +1494,7 @@ void SomfyShade::processFrame(somfy_frame_t &frame, bool internal) {
}
somfy.isDirty = true;
this->emitState();
this->emitCommand(cmd, internal ? "internal" : "remote", frame.remoteAddress);
}
break;
case somfy_commands::Up:
Expand Down
7 changes: 6 additions & 1 deletion SomfyController.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ void setup() {

void loop() {
// 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();
somfy.loop();
if(net.connected()) {
Expand Down
Binary file modified SomfyController.ino.esp32.bin
Binary file not shown.
2 changes: 2 additions & 0 deletions Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,7 @@ void Web::begin() {
});
server.on("/updateFirmware", HTTP_POST, []() {
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 (Update.hasError())
server.send(500, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Error updating firmware: \"}");
Expand Down Expand Up @@ -1740,6 +1741,7 @@ void Web::begin() {
});
server.on("/updateApplication", HTTP_POST, []() {
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; }
server.sendHeader("Connection", "close");
server.send(200, _encoding_json, "{\"status\":\"ERROR\",\"desc\":\"Updating Application: \"}");
Expand Down

0 comments on commit f62dcef

Please sign in to comment.