From 48bc4942b1680669f41d18c09551326c5a4d6d33 Mon Sep 17 00:00:00 2001 From: alf45tar <35426671+alf45tar@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:06:59 +0200 Subject: [PATCH 1/3] Fixed local broadcast address calculation when in AP mode --- src/ArtnetnodeWifi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ArtnetnodeWifi.cpp b/src/ArtnetnodeWifi.cpp index 380db72..674a494 100644 --- a/src/ArtnetnodeWifi.cpp +++ b/src/ArtnetnodeWifi.cpp @@ -55,8 +55,14 @@ uint8_t ArtnetnodeWifi::begin(String hostname) byte mac[6]; Udp.begin(ARTNET_PORT); - localIP = WiFi.localIP(); - localMask = WiFi.subnetMask(); + if (WiFi.getMode() == WIFI_STA || WiFi.getMode() == WIFI_AP_STA) { + localIP = WiFi.localIP(); + localMask = WiFi.subnetMask(); + } + else { + localIP = WiFi.softAPIP(); + localMask = IPAddress(255,255,255,0); + } localBroadcast = IPAddress((uint32_t)localIP | ~(uint32_t)localMask); WiFi.macAddress(mac); From a51f6442ef0f177730ba02464dae64e2d47588de Mon Sep 17 00:00:00 2001 From: alf45tar <35426671+alf45tar@users.noreply.github.com> Date: Wed, 7 Jun 2023 21:40:21 +0200 Subject: [PATCH 2/3] Fixed local broadcast address calculation and MAC address when in AP mode --- src/ArtnetnodeWifi.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ArtnetnodeWifi.cpp b/src/ArtnetnodeWifi.cpp index 674a494..da1557f 100644 --- a/src/ArtnetnodeWifi.cpp +++ b/src/ArtnetnodeWifi.cpp @@ -55,17 +55,18 @@ uint8_t ArtnetnodeWifi::begin(String hostname) byte mac[6]; Udp.begin(ARTNET_PORT); - if (WiFi.getMode() == WIFI_STA || WiFi.getMode() == WIFI_AP_STA) { + if (WiFi.getMode() == WIFI_STA) { localIP = WiFi.localIP(); localMask = WiFi.subnetMask(); + WiFi.macAddress(mac); } else { localIP = WiFi.softAPIP(); localMask = IPAddress(255,255,255,0); + WiFi.softAPmacAddress(mac); } localBroadcast = IPAddress((uint32_t)localIP | ~(uint32_t)localMask); - WiFi.macAddress(mac); PollReplyPacket.setMac(mac); PollReplyPacket.setIP(localIP); PollReplyPacket.canDHCP(true); From 8d6e81b85e9a573f0c2ba2ab1fb09c51bc8a6e3a Mon Sep 17 00:00:00 2001 From: alf45tar <35426671+alf45tar@users.noreply.github.com> Date: Thu, 29 Jun 2023 21:59:47 +0200 Subject: [PATCH 3/3] Hard coded netmask removed in AP mode --- src/ArtnetnodeWifi.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ArtnetnodeWifi.cpp b/src/ArtnetnodeWifi.cpp index da1557f..1d2ced3 100644 --- a/src/ArtnetnodeWifi.cpp +++ b/src/ArtnetnodeWifi.cpp @@ -62,7 +62,12 @@ uint8_t ArtnetnodeWifi::begin(String hostname) } else { localIP = WiFi.softAPIP(); - localMask = IPAddress(255,255,255,0); + struct ip_info info; + if(wifi_get_ip_info(SOFTAP_IF, &info)) { + localMask = info.netmask.addr; + } else { + localMask = IPAddress(255, 255, 255, 0); + } WiFi.softAPmacAddress(mac); } localBroadcast = IPAddress((uint32_t)localIP | ~(uint32_t)localMask);