简体   繁体   English

esp32软AP模式如何获取远程客户端IP地址

[英]How to retrieve remote client IP address esp32 soft AP mode

My goal is to retrieve the IP address of client connected to an esp32 in soft Access Point mode WITHOUT client sending a request.我的目标是在软接入点模式下检索连接到 esp32 的客户端的 IP 地址,而无需客户端发送请求。

So far calling "remoteIP()" method from "client" object seems to be the only way I can successfully retrieve connected client IP is when an HTTP request is made.到目前为止,从“客户端”对象调用“remoteIP()”方法似乎是我可以成功检索连接的客户端 IP 的唯一方法是在发出 HTTP 请求时。

If I call "client.remoteIP()" before the remote client sends an HTTP request I get All zeros, yikes.如果我在远程客户端发送 HTTP 请求之前调用“client.remoteIP()”,我会得到全零,哎呀。

Currently I'm polling the "softAPgetStationNum()" method from "WiFi" object and I'm alerted as soon as a device is connected or disconnected.目前,我正在从“WiFi”对象轮询“softAPgetStationNum()”方法,一旦设备连接或断开连接,我就会收到警报。 I would like to get the client IP along with the new connection alert.我想获取客户端 IP 以及新的连接警报。

My advanced apologies for not including my code hopefully my description has enough clarity to properly relay my intended objective.对于没有包含我的代码,我深表歉意,希望我的描述足够清晰,可以正确传达我的预期目标。 Thanks谢谢

Ps- if I could get guidance on retrieving MAC of remote client too that would be dope! Ps-如果我也能获得有关检索远程客户端 MAC 的指导,那就太棒了!

我不知道 Arduino 在 Espressif 框架之上构建了什么接口,但底层的 ESP IDF v4.3 具有函数esp_wifi_ap_get_sta_list() ,它为您提供所有连接站(包括 MAC)的列表和映射此列表的esp_netif_get_sta_list()客户端到他们的 IP 地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM