Did this work for you?
I tried to use esp_wifi_deauth_sta() to remove clients that matched a given mac address and ran into 2 major problems.
1. after calling esp_wifi_deauth_sta(), I get an error about 50% of the time and program panics/aborts. It is usually a heap error. it usually occurs when the client that just got kicked off tries to reconnect before my ESP32 app even gets to my_event_handler() callback. here's an example of the output when it crashes.
...
I (65037) wifi: n:5 0, o:5 0, ap:5 1, sta:255 255, prof:5
I (65037) wifi: station: 12:34:56:78:9a:bc join, AID=1, n, 20
D (65043) event: SYSTEM_EVENT_AP_STACONNECTED, mac:12:34:56:78:9a:bc, aid:1
D (65043) my_event_handler: wifi event handler invoked
D (65051) my_event_handler: New station connected to the AP.
D (65055) my_event_handler: SYSTEM_EVENT_AP_STACONNECTED, mac:12:34:56:78:9a:bc, aid:1
D (67627) DisconnectBlockedDevices: numConnectedDevices = 1
D (67627) DisconnectBlockedDevices: Disconnecting station 0
I (67627) wifi: station: 12:34:56:78:9a:bc leave, AID = 1
D (67631) event: SYSTEM_EVENT_AP_STADISCONNECTED, mac:12:34:56:78:9a:bc, aid:1
I (67633) wifi: n:5 0, o:5 0, ap:5 1, sta:255 255, prof:5
I (67631) wifi: n:5 0, o:5 0, ap:5 1, sta:255 255, prof:5
I (67645) wifi: station: 12:34:56:78:9a:bc join, AID=1, n, 20
I (67655) wpa: del sm error 0
CORRUPT HEAP: multi_heap.c:369 detected at 0x3ffe0b81
abort() was called at PC 0x40088a24 on core 0
...
There should be a line after the disconnection that says
my_event_handler: my_event_handler: A station disconnected from the AP.
but ESP32 app doesn't get there before it crashes.
here's an example when my ESP32 app does not crash when it tries to remove the client:
...
I (53179) DisconnectAllDevices: blocking new mac:12:34:56:78:9a:bc, blockedIdx=0, same=0
D (53179) DisconnectAllDevices: mac:12:34:56:78:9a:bc, blockedIdx=0, same=0, found=1
I (53185) wifi: station: 12:34:56:78:9a:bc leave, AID = 1
D (53189) event: SYSTEM_EVENT_AP_STADISCONNECTED, mac:12:34:56:78:9a:bc, aid:1
I (53189) wifi: n:5 0, o:5 0, ap:5 1, sta:255 255, prof:5
D (53197) my_event_handler: wifi event handler invoked
D (53207) my_event_handler: A station disconnected from the AP.
I (55733) wifi: n:5 0, o:5 0, ap:5 1, sta:255 255, prof:5
I (55733) wifi: station: 12:34:56:78:9a:bc join, AID=1, n, 20
D (55735) event: SYSTEM_EVENT_AP_STACONNECTED, mac:12:34:56:78:9a:bc, aid:1
D (55739) my_event_handler: wifi event handler invoked
D (55743) my_event_handler: New station connected to the AP.
D (55749) my_event_handler: SYSTEM_EVENT_AP_STACONNECTED, mac:12:34:56:78:9a:bc, aid:1
...
2. the other issue is that the client still keeps re-connecting. The client may eventually give up, but I usually don't get that far because my ESP32 app crashes due to issue 1 above before the client has tried a bunch of times. Is there some way that the ESP32 can prevent the client from re-connecting ? Or does my ESP32 app just have to keep calling esp_wifi_deauth_sta() and hope other clients can get access in the short times when the blocked client is not connected?