diff --git a/softap/jni/QWiFiSoftApCfg.c b/softap/jni/QWiFiSoftApCfg.c index 12b3e1c..28ef074 100644 --- a/softap/jni/QWiFiSoftApCfg.c +++ b/softap/jni/QWiFiSoftApCfg.c @@ -35,7 +35,7 @@ int rc; \ rc = snprintf(resp, sizeof(resp), "failure %s:%s",msg, code); \ if ( rc == sizeof(resp)) resp[sizeof(resp)-1] = 0; \ - LOGE("%s", resp); \ + LOGE("%s",resp); \ } static struct sockaddr_nl rtnl_local; diff --git a/softap/sdk/qsap.c b/softap/sdk/qsap.c index c5ed607..3a049c8 100644 --- a/softap/sdk/qsap.c +++ b/softap/sdk/qsap.c @@ -224,6 +224,36 @@ end: return ret; } + +void qsap_send_module_down_indication(void) +{ + int s, ret; + struct iwreq wrq; + + /* + * If the driver is loaded, ask it to broadcast a netlink message + * that it will be closing, so listeners can close their sockets. + * + */ + + + /* Equivalent to: iwpriv wlan0 sendModuleInd */ + if ((s = socket(PF_INET, SOCK_DGRAM, 0)) >= 0) { + strncpy(wrq.ifr_name, "wlan0", IFNAMSIZ); + wrq.u.data.length = 0; /* No Set arguments */ + wrq.u.mode = 5; /* WE_MODULE_DOWN_IND sub-command */ + ret = ioctl(s, (SIOCIWFIRSTPRIV + 1), &wrq); + close(s); + if (ret < 0 ) { + LOGE("ioctl failed: %s", strerror(errno)); + } + sched_yield(); + } + else { + LOGE("Socket open failed: %s", strerror(errno)); + } +} + s32 wifi_qsap_unload_wifi_sta_driver(void) { s32 ret = 0; @@ -233,6 +263,7 @@ s32 wifi_qsap_unload_wifi_sta_driver(void) } if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) { + qsap_send_module_down_indication(); if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) { LOGE("Unable to unload the station mode wifi driver...\n"); ret = 1; @@ -267,6 +298,7 @@ s32 wifi_qsap_unload_driver() } if ( check_driver_loaded(WIFI_DRIVER_MODULE_NAME " ") ) { + qsap_send_module_down_indication(); if ( rmmod(WIFI_DRIVER_MODULE_NAME) ) { LOGE("Unable to unload the libra_softap driver\n"); ret = eERR_UNLOAD_FAILED_SOFTAP; diff --git a/softap/sdk/qsap_api.c b/softap/sdk/qsap_api.c index e93fb93..2defa43 100644 --- a/softap/sdk/qsap_api.c +++ b/softap/sdk/qsap_api.c @@ -1849,11 +1849,14 @@ static int qsap_send_cmd_to_hostapd(s8 *pcmd) LOGE("Command failed in hostapd \n"); goto close_ret; } + else { + break; + } } else { LOGE("%s: Select failed \n", __func__); goto close_ret; - } + } } ret = eSUCCESS; @@ -2516,8 +2519,7 @@ static void qsap_handle_set_request(s8 *pcmd, s8 *presp, u32 *plen) case eCMD_RESET_TO_DEFAULT: if(eSUCCESS == (status = wifi_qsap_reset_to_default(pconffile, DEFAULT_CONFIG_FILE_PATH))) { if(eSUCCESS == (status = wifi_qsap_reset_to_default(fIni, DEFAULT_INI_FILE))) { - gIniUpdated = 1; - status = commit(); + status = wifi_qsap_reload_softap(); } } *plen = snprintf(presp, *plen, "%s", (status == eSUCCESS) ? SUCCESS : ERR_UNKNOWN);