Added new CAPI to get the wps pin number from supplicant 02/175002/4
authortaesub kim <taesub.kim@samsung.com>
Fri, 6 Apr 2018 01:43:48 +0000 (10:43 +0900)
committertaesub kim <taesub.kim@samsung.com>
Fri, 13 Apr 2018 07:26:32 +0000 (16:26 +0900)
Change-Id: I9231e26bb6e788d1412bbed86bbf88df9e49962f
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
include/network_dbus.h
include/network_interface.h
include/wifi-manager.h
include/wifi_internal.h
src/network_dbus.c
src/network_interface.c
src/wifi_internal.c
src/wifi_manager.c
test/wifi_manager_test.c

index 3c5fa15..fcc4c14 100755 (executable)
@@ -83,7 +83,7 @@ int _net_dbus_get_scan_state(int *state);
 int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_e mode);
 int _net_dbus_set_agent_passphrase_and_connect(
                const char *passphrase, const char *profilename);
-int _net_dbus_get_wps_pin(char **wps_pin);
+int _net_dbus_get_wps_generated_pin(char **wps_pin);
 int _net_dbus_set_agent_wps_pbc_and_connect(const char *profilename);
 int _net_dbus_set_agent_wps_pin_and_connect(
                const char *wps_pin, const char *profilename);
index 0ec7a68..0802f8e 100755 (executable)
@@ -262,7 +262,7 @@ int net_delete_profile(const char *profile_name);
 int net_get_wifi_state(net_wifi_state_e *current_state);
 int net_init_profile_info(net_profile_info_s *ProfInfo);
 int net_specific_scan_wifi(const char *ssid);
-int net_get_wps_pin(char **wps_pin);
+int net_get_wps_generated_pin(char **wps_pin);
 int net_bssid_scan_wifi(int activated);
 int net_netlink_scan_wifi(GSList *nl_scan_list, const char *vsie);
 int net_wifi_get_passpoint(int *enable);
index 6fad29e..1555dab 100755 (executable)
@@ -1649,6 +1649,19 @@ int wifi_manager_connect_by_wps_pin_without_ssid(wifi_manager_h wifi,
 int wifi_manager_cancel_wps(wifi_manager_h wifi);
 
 /**
+ * @brief Gets the WPS generated PIN code.
+ * @since_tizen 5.0
+ * @remarks You must release @a wps_pin using free().
+ * @param[in] wifi            The Wi-Fi handle
+ * @param[out] wps_pin        The WPS PIN
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_get_wps_generated_pin(wifi_manager_h wifi, char **wps_pin);
+
+/**
  * @brief Deletes the information of a stored access point and disconnects from it if it was connected to.
  * @details If an AP is connected to, then connection information will be stored.
  * This information is used when a connection to that AP is established automatically.
index 45511e8..01bf649 100755 (executable)
@@ -330,6 +330,8 @@ int _wifi_ip_conflict_detect_is_enabled(bool *state);
 int _wifi_set_ip_conflict_period(unsigned int initial_time);
 int _wifi_get_ip_conflict_state(wifi_manager_ip_conflict_state_e *state);
 int _wifi_get_ip_conflict_period(unsigned int* initial_time);
+int _wifi_get_wps_generated_pin(char **wps_pin);
+
 
 /* WIFI Privilege Check */
 int _wifi_check_get_privilege();
index 4227b3c..e0c824a 100755 (executable)
@@ -1171,7 +1171,7 @@ int _net_dbus_set_agent_fields_and_connect(const char *ssid,
        return Error;
 }
 
-int _net_dbus_get_wps_pin(char **wps_pin)
+int _net_dbus_get_wps_generated_pin(char **wps_pin)
 {
        __NETWORK_FUNC_ENTER__;
        net_err_e error = NET_ERR_NONE;
@@ -1190,7 +1190,7 @@ int _net_dbus_get_wps_pin(char **wps_pin)
        g_variant_get(reply, "(&o)", &path);
 
        reply = _net_invoke_dbus_method(SUPPLICANT_SERVICE, path,
-                       SUPPLICANT_INTERFACE ".Interface.WPS", "GetPin", NULL, &error);
+                       SUPPLICANT_INTERFACE ".Interface.WPS", "GeneratePin", NULL, &error);
        if (reply == NULL) {
                WIFI_LOG(WIFI_ERROR, "Failed to get wps pin");
                return error;
index 40703af..7e97b6a 100755 (executable)
@@ -1607,10 +1607,10 @@ int net_multi_scan_wifi(GSList *multi_scan_list, int type)
        return Error;
 }
 
-int net_get_wps_pin(char **wps_pin)
+int net_get_wps_generated_pin(char **wps_pin)
 {
        net_err_e error = NET_ERR_NONE;
-       error = _net_dbus_get_wps_pin(wps_pin);
+       error = _net_dbus_get_wps_generated_pin(wps_pin);
 
        if (error != NET_ERR_NONE)
                WIFI_LOG(WIFI_ERROR, "Failed to get wps pin : %d", error);
index 404b30b..195c59b 100755 (executable)
@@ -3048,6 +3048,19 @@ int _wifi_get_ip_conflict_state(wifi_manager_ip_conflict_state_e *state)
        return WIFI_MANAGER_ERROR_NONE;
 }
 
+int _wifi_get_wps_generated_pin(char **wps_pin)
+{
+       int rv;
+
+       rv = net_get_wps_generated_pin(wps_pin);
+
+       if (rv != NET_ERR_NONE) {
+               WIFI_LOG(WIFI_ERROR, "Failed to get WPS PIN");
+       }
+
+       return rv;
+}
+
 int _wifi_get_module_state(wifi_manager_module_state_e *state)
 {
        int rv = 0;
index 72640da..9b4c556 100755 (executable)
@@ -1144,6 +1144,21 @@ EXPORT_API int wifi_manager_cancel_wps(wifi_manager_h wifi)
        return rv;
 }
 
+EXPORT_API int wifi_manager_get_wps_generated_pin(wifi_manager_h wifi, char **wps_pin)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+       int rv;
+
+       if (!__wifi_check_handle_validity(wifi)) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter");
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER;
+       }
+
+       rv = _wifi_get_wps_generated_pin(wps_pin);
+
+       return rv;
+}
+
 //LCOV_EXCL_START
 EXPORT_API int wifi_manager_set_autoscan(wifi_manager_h wifi, bool autoscan)
 {
index 16a2037..2619731 100755 (executable)
@@ -2400,6 +2400,21 @@ int test_wifi_manager_cancel_wps(void)
        return 1;
 }
 
+int test_wifi_manager_get_wps_generated_pin(void)
+{
+       int rv = 0;
+       char *wps_pin = NULL;
+
+       rv = wifi_manager_get_wps_generated_pin(wifi, &wps_pin);
+       if (rv != WIFI_MANAGER_ERROR_NONE) {
+               printf("wifi_manager_get_wps_generated_pin() is failed [%s]\n", __test_convert_error_to_string(rv));
+               return -1;
+       }
+       printf("Generaged pin number is [%s]\n", wps_pin);
+       g_free(wps_pin);
+       return 1;
+}
+
 int test_wifi_manager_set_autoscan_state(void)
 {
        int autoscan = 0;
@@ -3146,22 +3161,23 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("F   - Set IP conflict detection mode\n");
                printf("G   - Get IP conflict detection mode\n");
                printf("H   - Get IP conflict state\n");
+               printf("I   - Get generated PIN number\n");
 /* Extension APIs */
                printf(LOG_BLUE "[Extension API]\n" LOG_END);
-               printf("I   - Set Enable or Disable Auto Scan\n");
-               printf("J   - Set Mode of Auto Scan\n");
-               printf("K   - Get Enable or Disable Auto Scan\n");
-               printf("L   - Get Mode of Auto Scan\n");
-               printf("M   - Flush BSS\n");
-               printf("N   - Set enable or disable auto connect\n");
-               printf("O   - Get enable or disable auto connect\n");
-               printf("P   - Set enable or disable of Wi-Fi profile auto-connect\n");
-               printf("Q   - Get enable or disable of Wi-Fi profile auto-connect\n");
-               printf("R   - Set the IP conflict detection period\n");
-               printf("S   - Get the IP conflict detection period\n");
-               printf("T   - Netlink Scan Normal/Specific-AP\n");
-               printf("U   - Get passpoint state\n");
-               printf("V   - Set passpoint on/off\n");
+               printf("J   - Set Enable or Disable Auto Scan\n");
+               printf("K   - Set Mode of Auto Scan\n");
+               printf("L   - Get Enable or Disable Auto Scan\n");
+               printf("M   - Get Mode of Auto Scan\n");
+               printf("N   - Flush BSS\n");
+               printf("O   - Set enable or disable auto connect\n");
+               printf("P   - Get enable or disable auto connect\n");
+               printf("Q   - Set enable or disable of Wi-Fi profile auto-connect\n");
+               printf("R   - Get enable or disable of Wi-Fi profile auto-connect\n");
+               printf("S   - Set the IP conflict detection period\n");
+               printf("T   - Get the IP conflict detection period\n");
+               printf("U   - Netlink Scan Normal/Specific-AP\n");
+               printf("V   - Get passpoint state\n");
+               printf("W   - Set passpoint on/off\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
 
                printf("ENTER  - Show options menu.......\n");
@@ -3298,47 +3314,51 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'H':
                rv = test_wifi_manager_get_ip_conflict_state();
                break;
-/* Extension APIs */
        case 'I':
-               rv = test_wifi_manager_set_autoscan_state();
+               rv = test_wifi_manager_get_wps_generated_pin();
                break;
+
+/* Extension APIs */
        case 'J':
-               rv = test_wifi_manager_set_autoscan_mode();
+               rv = test_wifi_manager_set_autoscan_state();
                break;
        case 'K':
-               rv = test_wifi_manager_get_autoscan_state();
+               rv = test_wifi_manager_set_autoscan_mode();
                break;
        case 'L':
-               rv = test_wifi_manager_get_autoscan_mode();
+               rv = test_wifi_manager_get_autoscan_state();
                break;
        case 'M':
-               rv = test_wifi_manager_flush_bss();
+               rv = test_wifi_manager_get_autoscan_mode();
                break;
        case 'N':
-               rv = test_wifi_manager_set_auto_connect();
+               rv = test_wifi_manager_flush_bss();
                break;
        case 'O':
-               rv = test_wifi_manager_get_auto_connect();
+               rv = test_wifi_manager_set_auto_connect();
                break;
        case 'P':
-               rv = test_wifi_manager_set_ap_auto_connect();
+               rv = test_wifi_manager_get_auto_connect();
                break;
        case 'Q':
-               rv = test_wifi_manager_get_ap_auto_connect();
+               rv = test_wifi_manager_set_ap_auto_connect();
                break;
        case 'R':
-               rv = test_wifi_manager_set_ip_conflict_period();
+               rv = test_wifi_manager_get_ap_auto_connect();
                break;
        case 'S':
-               rv = test_wifi_manager_get_ip_conflict_period();
+               rv = test_wifi_manager_set_ip_conflict_period();
                break;
        case 'T':
-               rv = test_wifi_manager_netlink_scan();
+               rv = test_wifi_manager_get_ip_conflict_period();
                break;
        case 'U':
-               rv = test_wifi_manager_get_passpoint_state();
+               rv = test_wifi_manager_netlink_scan();
                break;
        case 'V':
+               rv = test_wifi_manager_get_passpoint_state();
+               break;
+       case 'W':
                rv = test_wifi_manager_set_passpoint_enable();
                break;
        default: