int nWifiTimeoutId = -1;
bool bIsActive = false;
+ wifi_ap_h connectedAPHandle;
- int nRet = wifi_is_activated(&bIsActive);
+ int nRet = wifi_get_connected_ap(&connectedAPHandle);
+ if (nRet == WIFI_ERROR_NONE) {
+ FPRINTF("[Line : %d][%s] AP is already connected.\\n", __LINE__, API_NAMESPACE);
+ nRet = wifi_ap_clone(&g_pWifiAPHandle, connectedAPHandle);
+ if ( (nRet == WIFI_ERROR_NONE) && (g_pWifiAPHandle != NULL) )
+ {
+ wifi_ap_destroy(connectedAPHandle);
+ return true;
+ }
+ wifi_ap_destroy(connectedAPHandle);
+ return false;
+ }
+
+ nRet = wifi_is_activated(&bIsActive);
if ( bIsActive != true )
{
g_bWifiCb = false;
wifi_connect(g_pWifiAPHandle, WifiConnectedCallback, NULL);
return 1;
}
-// Done as per suggestion from connectivity team,
-// as calling wifi_forget_ap(), before wifi_disconnect() is not logical.
- nRet = wifi_forget_ap(g_pWifiAPHandle);
- PRINT_RESULT(WIFI_ERROR_NONE, nRet, "wifi_forget_ap", WifiGetError(nRet));
//Done to avoid disconnect after complete execution
g_bCheckCb = false;