Recently when debugging equipment, encountered a strange problem: the WiFi module to work in the station mode and AP mode switch between, several consecutive times, the mobile phone's wireless WiFi list can no longer find the device's AP node named ... Use Ifconfig to view the network state of the device side, it is really switched to AP mode, PS view process, HOSTAPD and other background services are also started, but why the wireless list of the search is not this node.
I started thinking that the WiFi module was not reset at the time of switching, so through the Gpio control of the WiFi module power supply, so that the module in the switch off the first service, and then power off 2 seconds, and then back on the electricity, and then reload the driver, start the related service process, the result is still unable to find AP node.
Later worried that the service start sequence or the wrong time, and then manually start each service to try, the results found in the multiple switch to the AP's startup process reported an error, the following figure:
Prompt to manually remove "/var/run/hostapd/wlan0", set Wlan0 control interface failed.
So in the switching application, try to remove the wlan0 before resetting the WiFi module, and after reloading the WiFi drive module, it automatically creates the Wlan0 node in the corresponding directory.
Add an action to delete "/var/run/hostapd/wlan0" in your application, as shown in the following illustration:
After proven, the problem is solved.