Added CAPI wifi_connect_by_wps_pin_without_ssid(). 37/81737/4
authorNiraj Kumar Goit <niraj.g@samsung.com>
Mon, 27 Jun 2016 09:29:05 +0000 (14:59 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Fri, 9 Sep 2016 12:20:38 +0000 (05:20 -0700)
Change-Id: Ia06f99fcc73e1e63962c9a6c3431b7b9e423bfa8
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/libnetwork.c
src/net_wifi.c

index e753dcc8993bc4aed8078c82d675e659b6c9da09..30c2a86813bde3c3dde9fcf47b63c0cde91b7ce5 100755 (executable)
@@ -1457,6 +1457,47 @@ int _wifi_libnet_connect_with_wps_pbc_without_ssid(wifi_connected_cb callback,
 
        return WIFI_ERROR_NONE;
 }
+
+int _wifi_libnet_connect_with_wps_pin_without_ssid(const char *pin,
+               wifi_connected_cb callback, void* user_data)
+{
+       int i = 0;
+       net_wifi_wps_info_t wps_info;
+
+       memset(&wps_info, 0, sizeof(net_wifi_wps_info_t));
+
+       wps_info.type = WIFI_WPS_PIN;
+       g_strlcpy(wps_info.pin, pin, NET_WLAN_MAX_WPSPIN_LEN + 1);
+
+       WIFI_LOG(WIFI_INFO, "pin: %s\n", pin);
+
+       /* Disconnect if already connected to an AP */
+       __libnet_update_profile_iterator();
+
+       for(; i < profile_iterator.count;i++) {
+               if (profile_iterator.profiles[i].ProfileState ==
+                               NET_STATE_TYPE_ASSOCIATION ||
+                               profile_iterator.profiles[i].ProfileState ==
+                               NET_STATE_TYPE_CONFIGURATION ||
+                               profile_iterator.profiles[i].ProfileState ==
+                               NET_STATE_TYPE_READY ||
+                               profile_iterator.profiles[i].ProfileState ==
+                               NET_STATE_TYPE_ONLINE) {
+                       if (net_close_connection(profile_iterator.profiles[i].ProfileName) !=
+                                       NET_ERR_NONE)
+                               return WIFI_ERROR_OPERATION_FAILED;
+                       is_disconnect_wps_pin = true;
+               }
+       }
+
+       if (!is_disconnect_wps_pin)
+               if(net_wifi_enroll_wps_without_ssid(&wps_info) != NET_ERR_NONE)
+                       return WIFI_ERROR_OPERATION_FAILED;
+
+       __libnet_set_connected_cb(callback,user_data);
+
+       return WIFI_ERROR_NONE;
+}
 #endif
 
 int _wifi_check_feature_supported(const char *feature_name, ...)
index 12337f2446b75d8e0e67f2f5b9a7499b7ed41b33..5cc18bc925a6e53ef853f7b54c3ceffd3ac1637d 100755 (executable)
@@ -573,6 +573,37 @@ EXPORT_API int wifi_connect_by_wps_pbc_without_ssid(wifi_connected_cb callback,
 #endif
 }
 
+EXPORT_API int wifi_connect_by_wps_pin_without_ssid(const char *pin,
+               wifi_connected_cb callback, void* user_data)
+{
+
+#if defined TIZEN_TV
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       WIFI_LOG(WIFI_INFO, "[App-->TizenMW] WiFi Connect by WPS_PIN without SSID\n");
+
+       if (_wifi_is_init() == false) {
+               WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Not initialized\n");
+               return WIFI_ERROR_INVALID_OPERATION;
+       }
+
+
+       if (callback == NULL) {
+               WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((NULL == pin) || ((strlen(pin) != 4) &&
+                               (strlen(pin) != NET_WLAN_MAX_WPSPIN_LEN))){
+               WIFI_LOG(WIFI_ERROR, "[App<--TizenMW] Wrong Parameter Passed\n");
+               return WIFI_ERROR_INVALID_PARAMETER;
+       }
+
+       return _wifi_libnet_connect_with_wps_pin_without_ssid(pin,callback,user_data);
+#else
+       return WIFI_ERROR_NOT_SUPPORTED;
+#endif
+}
+
 //LCOV_EXCL_START
 EXPORT_API int wifi_tdls_disconnect(const char* peer_mac_addr)
 {