Hi, I've noticed that, in AP+STA mode, the AP is switched off when the STA is not connected. I would like to prevent this from happening and make it possible for the AP to stay up even if the STA is not connected.
I understand that the main limitation is that the PHY can only operate in one channel at a time and the AP being up means you are stuck to the current channel and cannot initiate a STA association in a different channel. I guess the current implementation is based in the assumption that this mode is most commonly used in a repeater configuration, where the STA is the only link facing the Internet and it's ok to turn off the AP if it is not providing Internet access. However, I think that keeping the AP up makes sense in environments where lan local services exist (printers, samba, DLNA services...). I have no in-depth knowledge of the code of hostapd/wpa_supplicant, only what I've been able to deduce with some "greps", but maybe the AP could be switched off only when the STA wants to associate, and switched back on in case the association was unsuccessful. As I understand, the AP is turned off when wpa_supplicant goes to states DISCONNECTED, ASSOCIATING or ASSOCIATING and is only turned on again when wpa_supplicant reaches COMPLETED. As a first approach, my idea is to also turn the AP on when wpa_supplicant goes to state INACTIVE, so that some shell scripting can be coded to stop wpa_supplicant from trying to associate after a given timeout and let it try again after a while (if scan results show suitable candidates). This is what I have tried: --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -123,6 +123,19 @@ return 0; } +static int hostapd_start(struct wpa_supplicant *wpa_s) +{ + const char *cmd = "UPDATE "; + char buf[256]; + int len = sizeof(buf); + + if (wpa_ctrl_request(wpa_s->hostapd, cmd, os_strlen(cmd), buf, &len, NULL) < 0) { + wpa_printf(MSG_ERROR, "\nFailed to start hostapd AP interfaces\n"); + return -1; + } + return 0; +} + static int hostapd_reload(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) { char *cmd = NULL; @@ -734,6 +747,13 @@ wpa_drv_set_supp_port(wpa_s, 0); #endif /* IEEE8021X_EAPOL */ sme_sched_obss_scan(wpa_s, 0); +#ifdef MULTICALL + } else if (state == WPA_INACTIVE && wpa_s->hostapd) { + if (wpa_s->current_bss) + hostapd_reload(wpa_s, wpa_s->current_bss); + else + hostapd_start(wpa_s); +#endif } wpa_s->wpa_state = state; Unfortunately, it does not work. I have one AP Router, the OpenWrt AP+STA and one PC. OpenWrt STA connects to the AP Router and my PC's wifi connects to OpenWrt AP. In the initial configuration, everything goes fine, wireless connections work as I just said, but if I issue the following command in a console in my OpenWrt: # wpa_cli -p /var/run/wpa_supplicant-wlan0-1 -i wlan0-1 disable_net 0 OK The OpenWrt AP is turned off and my PC's wifi is disconnected from OpenWrt and cannot connect back anymore even though wpa_supplicant has gone to INACTIVE: # wpa_cli -p /var/run/wpa_supplicant-wlan0-1 -i wlan0-1 status wpa_state=INACTIVE ip_address=X.X.X.X address=xx:xx:xx:xx:xx:xx What am I missing? Can the behavior I propose be implemented? Regards, Diego
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel