MAC and IP from WiFi event handler

ThinkalVB
Posts: 13
Joined: Mon Apr 22, 2019 7:09 am

MAC and IP from WiFi event handler

Postby ThinkalVB » Mon Jul 22, 2019 7:16 am

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?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: MAC and IP from WiFi event handler

Postby WiFive » Mon Jul 22, 2019 7:33 am


ThinkalVB
Posts: 13
Joined: Mon Apr 22, 2019 7:09 am

Re: MAC and IP from WiFi event handler

Postby ThinkalVB » Mon Jul 22, 2019 1:52 pm

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
    }
Error :
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: No registered users and 133 guests