Added new CAPI to print the WiFi Connection Error State 35/132335/5
authorManeesh Jain <maneesh.jain@samsung.com>
Fri, 2 Jun 2017 09:15:19 +0000 (14:45 +0530)
committertaesub kim <taesub.kim@samsung.com>
Tue, 20 Jun 2017 10:12:52 +0000 (19:12 +0900)
Change-Id: Ia6c43e8da89bbe4ad153b79415f2a424ba51ed35
Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
include/wifi-manager.h
src/wifi_ap.c
test/wifi_manager_test.c

index 900c51f..ea3c5e8 100755 (executable)
@@ -2413,6 +2413,20 @@ int wifi_manager_ap_get_prefix_length(wifi_manager_ap_h ap,
 int wifi_manager_ap_set_prefix_length(wifi_manager_ap_h ap,
                wifi_manager_address_family_e address_family, int prefix_len);
 
+/*
+ * @brief Gets the error state.
+ * @since_tizen 4.0
+ * @param[in] ap              The access point handle
+ * @param[out] error_state    The Wi-Fi connection error state
+ * @return 0 on success, otherwise negative error value
+ * @retval #WIFI_MANAGER_ERROR_NONE                 Successful
+ * @retval #WIFI_MANAGER_ERROR_INVALID_OPERATION    Invalid operation
+ * @retval #WIFI_MANAGER_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #WIFI_MANAGER_ERROR_NOT_SUPPORTED        Not supported
+ */
+int wifi_manager_ap_get_error_state(wifi_manager_ap_h ap, wifi_manager_error_e *error_state);
+
+
 /**
 * @}
 */
index 84a1978..790b2e8 100755 (executable)
@@ -206,6 +206,41 @@ wifi_manager_connection_state_e _wifi_convert_to_ap_state(net_state_type_e state
 
        return ap_state;
 }
+
+wifi_manager_error_e __wifi_convert_to_ap_error_state(net_error_state_type_e error)
+{
+       wifi_manager_error_e ap_error_state;
+
+       switch (error) {
+       case NET_STATE_ERROR_OUT_OF_RANGE:
+               ap_error_state = WIFI_MANAGER_ERROR_OUT_OF_RANGE;
+               break;
+       case NET_STATE_ERROR_PIN_MISSING:
+               ap_error_state = WIFI_MANAGER_ERROR_PIN_MISSING;
+               break;
+       case NET_STATE_ERROR_DHCP_FAILED:
+               ap_error_state = WIFI_MANAGER_ERROR_DHCP_FAILED;
+               break;
+       case NET_STATE_ERROR_CONNECT_FAILED:
+               ap_error_state = WIFI_MANAGER_ERROR_OPERATION_FAILED;
+               break;
+       case NET_STATE_ERROR_LOGIN_FAILED:
+               ap_error_state = WIFI_MANAGER_ERROR_LOGIN_FAILED;
+               break;
+       case NET_STATE_ERROR_AUTH_FAILED:
+               ap_error_state = WIFI_MANAGER_ERROR_AUTHENTICATION_FAILED;
+               break;
+       case NET_STATE_ERROR_INVALID_KEY:
+               ap_error_state = WIFI_MANAGER_ERROR_INVALID_KEY;
+               break;
+       default:
+               ap_error_state = WIFI_MANAGER_ERROR_NONE;
+               break;
+       }
+
+       return ap_error_state;
+}
+
 //LCOV_EXCL_STOP
 
 EXPORT_API int wifi_manager_ap_create(wifi_manager_h wifi,
@@ -1809,3 +1844,20 @@ EXPORT_API int wifi_manager_ap_foreach_ipv6_address(wifi_manager_ap_h ap,
 
        return WIFI_MANAGER_ERROR_NONE;
 }
+
+EXPORT_API int wifi_manager_ap_get_error_state(wifi_manager_ap_h ap, wifi_manager_error_e* error_state)
+{
+       CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+       if (_wifi_check_ap_validity(ap) == false || error_state == NULL) {
+               WIFI_LOG(WIFI_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       net_profile_info_s *profile_info = ap;
+       *error_state = __wifi_convert_to_ap_error_state(profile_info->ProfileErrorState);
+       WIFI_LOG(WIFI_INFO, "error_state %d\n", *error_state);
+
+       return WIFI_MANAGER_ERROR_NONE;
+}
+
index 64bbc36..49a54f1 100755 (executable)
@@ -921,6 +921,11 @@ static bool __test_found_print_ap_info_callback(wifi_manager_ap_h ap, void *user
                else
                        printf("Fail to get disconnect reason\n");
 
+               if (wifi_manager_ap_get_error_state(ap, &int_value) == WIFI_MANAGER_ERROR_NONE)
+                       printf("error state of AP : %s\n", __test_convert_error_to_string(int_value));
+               else
+                       printf("Fail to get error state of AP\n");
+
                /* Network info */
                if (wifi_manager_ap_get_connection_state(ap, &conn_state) == WIFI_MANAGER_ERROR_NONE)
                        printf("Connection State : %d\n", conn_state);