Skip to content

Commit 229d693

Browse files
committed
fix: ON_STA_FILTER & ON_AP_FILTER
1 parent 51bdde4 commit 229d693

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

libraries/WebServer/src/WebServer.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
*/
2222

2323
#include <Arduino.h>
24+
25+
#if SOC_WIFI_SUPPORTED
26+
#include "WiFi.h"
27+
#endif
28+
2429
#include <esp32-hal-log.h>
2530
#include <libb64/cdecode.h>
2631
#include <libb64/cencode.h>
@@ -799,13 +804,12 @@ String WebServer::_responseCodeToString(int code) {
799804
}
800805
}
801806

802-
bool ON_STA_FILTER(WebServer &server) {
803-
return (
804-
(WiFi.localIP() != IPAddress(0, 0, 0, 0) && server.client().localIP() != IPAddress(0, 0, 0, 0))
805-
&& WiFi.localIP() == server.client().localIP()
806-
);
807-
}
807+
#if SOC_WIFI_SUPPORTED
808+
bool ON_STA_FILTER(WebServer &server) {
809+
return WiFi.STA.localIP() == server.client().localIP();
810+
}
808811

809-
bool ON_AP_FILTER(WebServer &server) {
810-
return WiFi.localIP() == server.client().localIP();
811-
}
812+
bool ON_AP_FILTER(WebServer &server) {
813+
return WiFi.AP.localIP() == server.client().localIP();
814+
}
815+
#endif

libraries/WebServer/src/WebServer.h

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <functional>
2727
#include <memory>
2828
#include "FS.h"
29-
#include "WiFi.h"
3029
#include "Network.h"
3130
#include "HTTP_Method.h"
3231
#include "Uri.h"

0 commit comments

Comments
 (0)