When a station connects to the softAP I think the IP address assigned to the station is very much important. However the event handler only gives us the MAC address and the aid that ESP32 soft-AP gives to the station.
1) So is there any way in which I can get the IP of the stations when they connect ? How ?
2) If I have the MAC addresses of stations, then can I use the MAC to send UDP packets? How?
MAC and IP from WiFi event handler
Re: MAC and IP from WiFi event handler
The documentation says
Event ID (legacy event ID)---------------------------------------------------------Event data structure
IP_EVENT_AP_STAIPASSIGNED (SYSTEM_EVENT_AP_STAIPASSIGNED)-------- n/a
Code: Select all
WiFi.onEvent(handleSTAip, WiFiEvent_t::SYSTEM_EVENT_AP_STAIPASSIGNED);
void AirMesh::handleSTAip(WiFiEvent_t event, WiFiEventInfo_t info)
{
#ifdef _AIRMESH_DEBUG_
auto example = info.ap_staipassigned;
Serial.printf("Assigned new IP to STA\n");
#endif
}
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "ESP32 Wrover Module, Default, QIO, 80MHz, 921600, None"
C:\Users\think\Documents\Arduino\libraries\AirMesh\AirMesh.cpp: In static member function 'static void AirMesh::handleSTAip(system_event_id_t, system_event_info_t)':
C:\Users\think\Documents\Arduino\libraries\AirMesh\AirMesh.cpp:70:25: error: 'union system_event_info_t' has no member named 'ap_staipassigned'
auto example = info.ap_staipassigned;
^
Multiple libraries were found for "WiFi.h"
Used: C:\Users\think\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.2\libraries\WiFi
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
Error compiling for board ESP32 Wrover Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Who is online
Users browsing this forum: Bing [Bot] and 72 guests