Search code examples
embedded-linuxwpa-supplicant

how get a WiFi disconnect event using wpa_cli when wifi is disconnected


i'm Working on a embedded Linux system. I need to connect to new WiFi when the existing WiFi disconnects. I can use a loop with a fixed sleep time and see if the wifi is connected or not, but it seems inefficient. Can anyone suggest a way that wpa_cli can be started as a daemon that fires an event when WiFi is disconnected.

Thanks in advance. Sundeep.


Solution

  • You could use the control socket that wpa_supplicant exposes to allow external applications to control it.docs are here. You try it out on wpa_cli, eg: run following commmand in wpa_cli scan and scan_results. When you connect to the socket you get all the events like connection,disconection etc. These events are described in the docs