Skip to content

Commit

Permalink
Use subnet mask to find server if MDNS fails
Browse files Browse the repository at this point in the history
Fixes #58.
  • Loading branch information
newHeiko committed Nov 14, 2023
1 parent 29e7f04 commit cbf06dd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion software/esp-firmware/locoHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,12 @@ void locoConnect(void)
if(n == 0)
{
automaticServerIP = WiFi.localIP();
automaticServerIP[3] = 1;
IPAddress netmask = WiFi.subnetMask();
for(uint32_t i=0; i<=3; i++)
{
automaticServerIP[i] &= netmask[i];
}
automaticServerIP[3] += 1;
automaticServer = strdup(automaticServerIP.toString().c_str());
log_d("No MDNS-announced wiThrottle server found. Trying LNWI/DCCEX at %s.", automaticServer);
}
Expand Down

0 comments on commit cbf06dd

Please sign in to comment.