Support NoCarrier error type 21/298521/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Fri, 8 Sep 2023 07:48:09 +0000 (16:48 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 8 Sep 2023 07:48:09 +0000 (16:48 +0900)
When requesting a scan, if the wifi is down in another module,
a NoCarrier error may occur depending on the timing.
There is a need to handle this separately in the APP,
so an error type is added.

Change-Id: I89ed7c84a9e177a36596949c5460b720f0aaf4fb
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/wifi-manager.h
src/network_dbus.c
src/network_error.h
src/wifi_internal.c

index 780169f..7eeba5c 100755 (executable)
@@ -187,6 +187,11 @@ typedef enum {
         * Association failed (Since 7.0)
         */
        WIFI_MANAGER_ERROR_ASSOCIATION_FAILED = TIZEN_ERROR_WIFI_MANAGER|0x15,
+
+       /**
+        * The wireless device is unavailable (Since 8.0)
+        */
+       WIFI_MANAGER_ERROR_NO_CARRIER = TIZEN_ERROR_WIFI_MANAGER|0x16,
 } wifi_manager_error_e;
 
 
index 85128ec..b628ac4 100755 (executable)
@@ -71,7 +71,7 @@ static int __net_error_string_to_enum(const char *error)
        else if (NULL != strstr(error, "NotFound"))
                return NET_ERR_NOT_SUPPORTED;
        else if (NULL != strstr(error, "NoCarrier"))
-               return NET_ERR_NOT_SUPPORTED;
+               return NET_ERR_WIFI_NO_CARRIER;
        else if (NULL != strstr(error, "InProgress"))
                return NET_ERR_IN_PROGRESS;
        else if (NULL != strstr(error, "AlreadyExists"))
index af6afd7..ba1e6cd 100644 (file)
@@ -59,7 +59,8 @@ typedef enum {
        NET_ERR_SECURITY_RESTRICTED = -790,                             /** Operation is restricted */
        NET_ERR_ALREADY_EXISTS = -789,                                  /** Already exists */
        NET_ERR_NO_PROFILE = -788,                                              /** There is no profile */
-       NET_ERR_OUT_OF_MEMORY = -787,                                           /** Failed to allocate memory */
+       NET_ERR_OUT_OF_MEMORY = -787,                                   /** Failed to allocate memory */
+       NET_ERR_WIFI_NO_CARRIER = -786,                                 /** The wireless device is unavailable */
 
        /** WiFi driver on/off failed */
        NET_ERR_WIFI_DRIVER_FAILURE = -699,
index 8dbe608..52f4f22 100644 (file)
@@ -70,6 +70,8 @@ static wifi_manager_error_e __convert_to_ap_error_type(net_err_e err_type)
        case NET_ERR_ACTIVE_CONNECTION_EXISTS:
        case NET_ERR_ALREADY_EXISTS:
                return WIFI_MANAGER_ERROR_ALREADY_EXISTS;
+       case NET_ERR_WIFI_NO_CARRIER:
+               return WIFI_MANAGER_ERROR_NO_CARRIER;
 /*Connection Failure Error Codes*/
        case NET_ERR_CONNECTION_OUT_OF_RANGE:
                return WIFI_MANAGER_ERROR_OUT_OF_RANGE;
@@ -840,12 +842,10 @@ static void __set_multi_scan_cb(wifi_manager_handle_s *wifi_handle,
 static void __scan_cb(wifi_manager_handle_s *wifi_handle,
                net_event_info_s *event_cb, bool is_requested)
 {
-       wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error);
 
-       if (event_cb->Error != NET_ERR_NONE) {
+       if (error_code != WIFI_MANAGER_ERROR_NONE)
                WIFI_LOG(WIFI_ERROR, "Scan failed[%d]", event_cb->Error);
-               error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
-       }
 
        if (wifi_handle->scan_request_cb) {
                wifi_handle->scan_request_cb(error_code, wifi_handle->scan_request_user_data);
@@ -873,13 +873,12 @@ static void __scan_changed_cb(wifi_manager_handle_s *wifi_handle, wifi_manager_s
 
 static void __specific_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
 {
-       wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error);
 
        __clear_profile_list(&(wifi_handle->specific_profile_iterator));
 
-       if (event_cb->Error != NET_ERR_NONE) {
+       if (error_code != WIFI_MANAGER_ERROR_NONE) {
                WIFI_LOG(WIFI_ERROR, "Specific scan failed!, Error [%d]", event_cb->Error);
-               error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
        } else if (event_cb->Data) {
                __update_specific_iterator(wifi_handle, (GSList *)event_cb->Data);
                WIFI_LOG(WIFI_INFO, "Specific AP count : %d",
@@ -895,14 +894,13 @@ static void __specific_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_inf
 
 static void __bssid_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
 {
-       wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error);
 
        __clear_profile_list(&(wifi_handle->bss_profile_iterator));
 
-       if (event_cb->Error != NET_ERR_NONE) {
+       if (error_code != WIFI_MANAGER_ERROR_NONE) {
                WIFI_LOG(WIFI_ERROR, "BSSID scan failed!, Error [%d]",
                                 event_cb->Error);
-               error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
        } else if (event_cb->Data) {
                __update_bss_profile_iterator(wifi_handle, (GSList *)event_cb->Data);
                WIFI_LOG(WIFI_INFO, "BSS AP count : %d",
@@ -944,14 +942,13 @@ static void __ip_conflict_cb(wifi_manager_handle_s *wifi_handle, net_event_info_
 
 static void __netlink_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
 {
-       wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error);
 
        __clear_profile_list(&(wifi_handle->bss_profile_iterator));
 
-       if (event_cb->Error != NET_ERR_NONE) {
+       if (error_code != WIFI_MANAGER_ERROR_NONE) {
                WIFI_LOG(WIFI_ERROR, "NETLINK scan failed!, Error [%d]",
                                 event_cb->Error);
-               error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
        } else if (event_cb->Data) {
                __update_netlink_scan_profile_iterator(wifi_handle, (GSList *)event_cb->Data);
                WIFI_LOG(WIFI_INFO, "BSS AP count : %d",
@@ -967,12 +964,10 @@ static void __netlink_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info
 
 static void __multi_scan_cb(wifi_manager_handle_s *wifi_handle, net_event_info_s *event_cb)
 {
-       wifi_manager_error_e error_code = WIFI_MANAGER_ERROR_NONE;
+       wifi_manager_error_e error_code = __convert_to_ap_error_type(event_cb->Error);
 
-       if (event_cb->Error != NET_ERR_NONE) {
+       if (error_code != WIFI_MANAGER_ERROR_NONE)
                WIFI_LOG(WIFI_ERROR, "Multi Scan failed[%d]", event_cb->Error);
-               error_code = WIFI_MANAGER_ERROR_OPERATION_FAILED;
-       }
 
        if (wifi_handle->multi_scan_cb)
                wifi_handle->multi_scan_cb(error_code, wifi_handle->multi_scan_user_data);