Add converting function to bt error from oal status 60/234360/4
authorWootak Jung <wootak.jung@samsung.com>
Tue, 26 May 2020 01:25:57 +0000 (10:25 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Tue, 2 Jun 2020 02:19:02 +0000 (02:19 +0000)
Change-Id: Idab6e37fdca38d00254fb7b82d5fa7ec3d79594b
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
15 files changed:
bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c
bt-service-adaptation/services/adapter/bt-service-core-adapter.c
bt-service-adaptation/services/audio/a2dp_sink/bt-service-a2dp-sink.c
bt-service-adaptation/services/audio/a2dp_src/bt-service-a2dp-src.c
bt-service-adaptation/services/audio/avrcp/bt-service-avrcp-ctrl.c
bt-service-adaptation/services/audio/avrcp/bt-service-avrcp-tg.c
bt-service-adaptation/services/audio/bt-service-audio.c
bt-service-adaptation/services/audio/hf/bt-service-hf-client.c
bt-service-adaptation/services/audio/hf/bt-service-hf.c
bt-service-adaptation/services/bt-service-common.c
bt-service-adaptation/services/device/bt-service-core-device.c
bt-service-adaptation/services/gatt/bt-service-gatt.c
bt-service-adaptation/services/hid/bt-service-hidhost.c
bt-service-adaptation/services/include/bt-service-common.h
bt-service-adaptation/services/socket/bt-service-socket.c

index ab6d4b8..5608b12 100644 (file)
@@ -1118,7 +1118,7 @@ static int __bt_le_state_handle_request(gboolean enable)
                        result = le_disable();  //change
                        if (result != OAL_STATUS_SUCCESS) {
                                BT_ERR("LE_enable failed: [%d]", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                                /*TODO: perform if anything more needs to be done to handle failure */
                        } else {
                                /* TODO: To be handled */
@@ -1142,7 +1142,7 @@ static int __bt_le_state_handle_request(gboolean enable)
                        result = le_disable();
                        if (result != OAL_STATUS_SUCCESS) {
                                BT_ERR("LE_enable failed: [%d]", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                                /*TODO: perform if anything more needs to be done to handle failure */
                        } else {
                                /* TODO: To be handled */
@@ -1163,7 +1163,7 @@ static int __bt_le_state_handle_request(gboolean enable)
                        if (result != OAL_STATUS_SUCCESS && result != OAL_STATUS_PENDING) {
                                BT_ERR("LE_enable failed: [%d]", result);
                                le_disable();
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                                /*TODO: perform if anything more needs to be done to handle failure */
                        } else {
                                /* TODO: To be handled */
@@ -1183,7 +1183,7 @@ static int __bt_le_state_handle_request(gboolean enable)
                        if (result != OAL_STATUS_SUCCESS && result != OAL_STATUS_PENDING) {
                                BT_ERR("LE_enable failed: [%d]", result);
                                le_disable();
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                                /*TODO: perform if anything more needs to be done to handle failure */
                        } else {
                                /* TODO: To be handled */
@@ -1282,7 +1282,7 @@ int _bt_set_advertising(const char *sender, int adv_handle, gboolean enable, gbo
                result = adapter_ble_multi_adv_disable(server_instance);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("OAL API adapter_ble_multi_adv_enable Fail %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        /* Update adv handle in table */
@@ -1340,20 +1340,20 @@ int _bt_set_custom_advertising(const char *sender, int adv_handle,
 
                if (result != OAL_STATUS_SUCCESS){
                        BT_ERR("OAL API adapter_ble_set_filter_policy Fail %d", result);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(result);
                }
                /* Set Advertising parameters to Stack */
                result = adapter_ble_multi_adv_update(server_instance, params->interval_min, params->interval_max,
                                params->type, BT_ADV_DEFAULT_CHANNEL_MAP, params->tx_power_level, BT_ADV_DEFAULT_TIMEOUT);
                if (result != OAL_STATUS_SUCCESS) {
                        BT_ERR("OAL API adapter_ble_multi_adv_update Fail %d", result);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(result);
                }
                /* Start Advertising when Adv update event is received */
                result = adapter_ble_multi_adv_enable(server_instance);
                if (result != OAL_STATUS_SUCCESS) {
                        BT_ERR("OAL API adapter_ble_multi_adv_enable Fail %d", result);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(result);
                }
                /* Update adv handle in table */
                _bt_update_adv_handle(sender, adv_handle);
@@ -1364,7 +1364,7 @@ int _bt_set_custom_advertising(const char *sender, int adv_handle,
 
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("OAL API adapter_ble_multi_adv_disable Fail %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -1803,7 +1803,7 @@ int _bt_set_scan_parameters(bluetooth_le_scan_params_t *params)
        ret = gattc_set_le_scan_param(params->type, itv, win);
        if (OAL_STATUS_SUCCESS != ret) {
                BT_ERR("gattc_set_le_scan_param failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        is_le_set_scan_parameter = TRUE;
@@ -1935,7 +1935,7 @@ int _bt_register_scan_filter(const char *sender, bluetooth_le_scan_filter_t *fil
 
        if (OAL_STATUS_SUCCESS != ret) {
                BT_ERR("gattc_register_scan_filter failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        scanner = __bt_find_scanner_from_list(sender);
@@ -2061,7 +2061,7 @@ int _bt_start_le_scan(const char *sender, uid_t uid, pid_t pid)
 
        if (OAL_STATUS_SUCCESS != ret) {
                BT_ERR("gattc_start_le_discovery failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -2103,7 +2103,7 @@ int _bt_stop_le_scan(const char *sender)
 
                if (OAL_STATUS_SUCCESS != ret) {
                        BT_ERR("gattc_start_le_discovery failed");
-                       result = BLUETOOTH_ERROR_INTERNAL;
+                       result = _bt_convert_oal_status_to_bt_error(ret);
                }
 
 // TODO: Disable scan filter
@@ -2214,10 +2214,10 @@ int _bt_set_le_privacy(gboolean set_privacy)
                return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
        }
 
-       result =  adapter_ble_set_privacy(set_privacy);
+       result = adapter_ble_set_privacy(set_privacy);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_set_le_privacy failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        }
 
        return result;
@@ -2244,11 +2244,11 @@ int _bt_set_white_list(bluetooth_device_address_t *device_address, int address_t
 
        result = adapter_set_white_list((bt_address_t*)device_address, address_type, is_add);
        if (result != OAL_STATUS_SUCCESS) {
-               if(is_add)
+               if (is_add)
                        BT_ERR("Add to White List Failed %d", result);
                else
                        BT_ERR("Remove from white list Failed %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        return result;
@@ -2268,7 +2268,7 @@ int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data)
        result = adapter_set_manufacturer_data((oal_manufacturer_data_t*)m_data);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("Set manufacturer data Failed %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
        /*data has been successfully sent to the stack, inititate manufacturer data change event */
        manufac_data = g_variant_new_from_data((const GVariantType *)"ay",
@@ -2297,10 +2297,10 @@ int _bt_set_le_static_random_address(gboolean is_enable)
                return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
        }
 
-       result =  adapter_set_le_static_random_address(is_enable);
+       result = adapter_set_le_static_random_address(is_enable);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_set_le_static_random_address failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else {
                BT_INFO("SetLeStaticRandomAddress as %d", is_enable);
                result = BLUETOOTH_ERROR_NONE;
index 3228d89..4e5e4c3 100644 (file)
@@ -138,7 +138,7 @@ int _bt_stack_init(void)
                return BLUETOOTH_ERROR_NONE;
        } else if (OAL_STATUS_SUCCESS != ret) {
                _bt_service_unregister_event_handler_callback(BT_ADAPTER_MODULE);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -191,7 +191,7 @@ int _bt_recover_adapter(void)
        result = adapter_recover();
 
        if (result != OAL_STATUS_SUCCESS)
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
 
        __bt_disconnect_all();
 
@@ -200,9 +200,11 @@ int _bt_recover_adapter(void)
 
 int _bt_reset_adapter(void)
 {
+       int result;
        BT_INFO("+");
-       if (OAL_STATUS_SUCCESS != adapter_reset())
-               return BLUETOOTH_ERROR_INTERNAL;
+       result = adapter_reset();
+       if (result != OAL_STATUS_SUCCESS)
+               return _bt_convert_oal_status_to_bt_error(result);
 
        /* TODO_40 : 4.0 merge  */
        /* TODO Currently bt-service is not terminated in tizen next.
@@ -253,12 +255,14 @@ int _bt_check_adapter(int *status)
 {
        BT_INFO("+");
        gboolean powered = FALSE;
+       int result;
        BT_CHECK_PARAMETER(status, return);
 
        *status = BT_ADAPTER_DISABLED;
 
-       if (OAL_STATUS_SUCCESS != adapter_get_powered_status(&powered))
-               return BLUETOOTH_ERROR_INTERNAL;
+       result = adapter_get_powered_status(&powered);
+       if (result != OAL_STATUS_SUCCESS)
+               return _bt_convert_oal_status_to_bt_error(result);
        else if (powered) {
                BT_INFO("Adapter is in Powered Up state");
                *status = BT_ADAPTER_ENABLED;
@@ -481,10 +485,10 @@ int _bt_get_local_address(void)
 
        BT_DBG("+");
 
-       result =  adapter_get_address();
+       result = adapter_get_address();
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_address failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -497,10 +501,10 @@ int _bt_get_local_version(void)
        int result;
        BT_DBG("+");
 
-       result =  adapter_get_version();
+       result = adapter_get_version();
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_version failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -514,10 +518,10 @@ int _bt_get_local_name(void)
 
        BT_DBG("+");
 
-       result =  adapter_get_name();
+       result = adapter_get_name();
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_name failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -532,10 +536,10 @@ int _bt_set_local_name(char *local_name)
 
        retv_if(NULL == local_name, BLUETOOTH_ERROR_INVALID_PARAM);
 
-       result =  adapter_set_name(local_name);
+       result = adapter_set_name(local_name);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_set_name failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -595,6 +599,7 @@ int _bt_get_timeout_value(int *timeout)
 int _bt_get_energy_info(unsigned int *tx_time, unsigned int *rx_time,
                                        unsigned int *idle_time, unsigned int *energy_used)
 {
+       int result;
        BT_INFO("+");
 
        BT_CHECK_PARAMETER(tx_time, return);
@@ -607,8 +612,9 @@ int _bt_get_energy_info(unsigned int *tx_time, unsigned int *rx_time,
        *idle_time = 0;
        *energy_used = 0;
 
-       if (OAL_STATUS_SUCCESS != adapter_get_energy_info(tx_time, rx_time, idle_time, energy_used))
-               return BLUETOOTH_ERROR_INTERNAL;
+       result = adapter_get_energy_info(tx_time, rx_time, idle_time, energy_used);
+       if (result != OAL_STATUS_SUCCESS)
+               return _bt_convert_oal_status_to_bt_error(result);
 
        return BLUETOOTH_ERROR_NONE;
 }
@@ -816,13 +822,13 @@ int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
 
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("set scan mode failed %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        result = adapter_set_discoverable_timeout(timeout);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_set_discoverable_timeout failed %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE) {
@@ -871,10 +877,10 @@ int _bt_set_connectable(gboolean connectable)
        int result = BLUETOOTH_ERROR_NONE;
 
        BT_DBG("+");
-       result =  adapter_set_connectable(connectable);
+       result = adapter_set_connectable(connectable);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_set_connectable failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -888,10 +894,10 @@ int _bt_get_connectable(void)
 
        BT_DBG("+");
 
-       result =  adapter_get_connectable();
+       result = adapter_get_connectable();
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_connectable failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -905,10 +911,10 @@ int _bt_is_service_used(void)
 
        BT_DBG("+");
 
-       result =  adapter_get_service_uuids();
+       result = adapter_get_service_uuids();
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_service_uuids failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else {
                result = BLUETOOTH_ERROR_NONE;
        }
@@ -922,10 +928,10 @@ int _bt_adapter_get_bonded_devices(void)
        int result = BLUETOOTH_ERROR_NONE;
 
        BT_DBG("+");
-       result =  adapter_get_bonded_devices();
+       result = adapter_get_bonded_devices();
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_bonded_devices failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -941,7 +947,7 @@ int _bt_get_profile_connected_devices(const char *profile_uuid)
        result = adapter_get_profile_connected_devices(profile_uuid);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("adapter_get_profile_connected_devices failed: %d", result);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(result);
        } else
                result = BLUETOOTH_ERROR_NONE;
 
@@ -1688,7 +1694,7 @@ static int __bt_adapter_state_handle_request(gboolean enable)
                        result = adapter_disable();
                        if (result != OAL_STATUS_SUCCESS) {
                                BT_ERR("adapter_disable failed: [%d]", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                                /*TODO: perform if anything more needs to be done to handle failure */
                        } else {
                                /* TODO: To be handled */
@@ -1708,7 +1714,7 @@ static int __bt_adapter_state_handle_request(gboolean enable)
                        if (result != OAL_STATUS_SUCCESS && result != OAL_STATUS_PENDING) {
                                BT_ERR("adapter_enable failed: [%d]", result);
                                adapter_disable();
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                                /*TODO: perform if anything more needs to be done to handle failure */
                        } else {
                                /* TODO: To be handled */
@@ -1750,7 +1756,7 @@ static int __bt_adapter_state_discovery_request(gboolean enable,
                        result = adapter_stop_inquiry();
                        if (result != OAL_STATUS_SUCCESS) {
                                BT_ERR("Discover stop failed: %d", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                        } else {
                                BT_ERR("Stop Discovery Triggered successfully");
                                __bt_adapter_update_discovery_status(ADAPTER_DISCOVERY_STOPPING);
@@ -1783,7 +1789,7 @@ static int __bt_adapter_state_discovery_request(gboolean enable,
 
                        if (result != OAL_STATUS_SUCCESS) {
                                BT_ERR("Start Discovery failed: %d", result);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                        } else {
                                BT_ERR("Start Discovery Triggered successfully");
                                __bt_adapter_update_discovery_status(ADAPTER_DISCOVERY_STARTING);
index 0f6962f..31fe10f 100644 (file)
@@ -43,7 +43,7 @@ int _bt_a2dp_connect_remote_source(bluetooth_device_address_t *device_address/*,
        status = a2dp_sink_connect((bt_address_t*)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Connection could not be established, err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
@@ -58,7 +58,7 @@ int _bt_a2dp_disconnect_remote_source(bluetooth_device_address_t *device_address
        status = a2dp_sink_disconnect((bt_address_t*)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("DisConnection err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
index 65c626d..5cc255d 100644 (file)
@@ -42,7 +42,7 @@ int _bt_a2dp_connect_remote_sink(bluetooth_device_address_t *device_address)
        status = audio_connect((bt_address_t*)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Connection could not be established, err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
@@ -56,7 +56,7 @@ int _bt_a2dp_disconnect_remote_sink(bluetooth_device_address_t *device_address)
        status = audio_disconnect((bt_address_t*)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("DisConnection err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
index ebfc5cb..8bd7886 100644 (file)
@@ -105,7 +105,7 @@ int _bt_avrcp_connect_remote_target(bluetooth_device_address_t *device_address)
        status = avrcp_ct_connect((bt_address_t*)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Connection could not be established, err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
@@ -119,7 +119,7 @@ int _bt_avrcp_disconnect_remote_target(bluetooth_device_address_t *device_addres
        status = avrcp_ct_disconnect((bt_address_t*)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("DisConnection err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
@@ -182,7 +182,7 @@ int _bt_avrcp_control_cmd(int type)
 
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Send pass through command err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
 
        return result;
@@ -246,7 +246,7 @@ int _bt_avrcp_control_cmd_to_dest(int type, bluetooth_device_address_t *device_a
 
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Send pass through command err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
 
        return result;
@@ -274,7 +274,7 @@ int _bt_avrcp_control_set_property(int type, unsigned int value)
                                oal_type, value);
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Set peoperty err: [%d]", status);
-                       result = BLUETOOTH_ERROR_INTERNAL;
+                       result = _bt_convert_oal_status_to_bt_error(status);
                }
        } else {
                BT_ERR("Device is not connected:");
@@ -300,7 +300,7 @@ int _bt_avrcp_transport_set_property(int type, unsigned int value)
                                type, value);
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Set peoperty err: [%d]", status);
-                       result = BLUETOOTH_ERROR_INTERNAL;
+                       result = _bt_convert_oal_status_to_bt_error(status);
                }
        } else {
                BT_ERR("Device is not connected:");
@@ -329,7 +329,7 @@ int _bt_avrcp_control_get_property(int type)
                        status = avrcp_ct_get_play_status(&device_address);
                        if (status != OAL_STATUS_SUCCESS) {
                                BT_ERR("Get play status err: [%d]", status);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(status);
                        }
                } else {
                        oal_type = __media_prop_to_oal_type(type);
@@ -338,7 +338,7 @@ int _bt_avrcp_control_get_property(int type)
                        status = avrcp_ct_get_property(&device_address, oal_type);
                        if (status != OAL_STATUS_SUCCESS) {
                                BT_ERR("Get peoperty err: [%d]", status);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(status);
                        }
                }
        } else {
@@ -366,7 +366,7 @@ int _bt_avrcp_control_get_track_info(void)
                status = avrcp_ct_get_media_attribute((bt_address_t*)&device_address);
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Get track info err: [%d]", status);
-                       result = BLUETOOTH_ERROR_INTERNAL;
+                       result = _bt_convert_oal_status_to_bt_error(status);
                }
        } else {
                BT_ERR("Device is not connected:");
index d360780..351e674 100644 (file)
@@ -76,7 +76,7 @@ static int __bt_avrcp_set_equalizer(media_player_equalizer_status equalizer)
        result = avrcp_set_property(AVRCP_EQUALIZER, value);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("avrcp_set_property failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -111,7 +111,7 @@ static int __bt_avrcp_set_repeat_status(media_player_repeat_status repeat_status
        result = avrcp_set_property(AVRCP_REPEAT, value);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("avrcp_set_property failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -143,7 +143,7 @@ static int __bt_avrcp_set_shuffel_mode(media_player_shuffle_status shuffel)
        result = avrcp_set_property(AVRCP_SHUFFLE, value);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("avrcp_set_property failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -175,7 +175,7 @@ static int __bt_avrcp_set_scan_mode(media_player_scan_status scan_status)
        result = avrcp_set_property(AVRCP_SCAN, value);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("avrcp_set_property failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -216,7 +216,7 @@ static int __bt_avrcp_set_player_status(media_player_status status)
        result = avrcp_set_property(AVRCP_STATUS, value);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("avrcp_set_property failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -232,7 +232,7 @@ static int __bt_avrcp_set_play_position(unsigned int position)
        result = avrcp_set_property(AVRCP_POSITION, position);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("avrcp_set_property failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -251,7 +251,7 @@ int _bt_avrcp_connect_remote_ctrl(bluetooth_device_address_t *address)
        status = avrcp_tg_connect(&bdaddr);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Connection could not be established, err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
 
        BT_DBG("-");
@@ -270,7 +270,7 @@ int _bt_avrcp_disconnect_remote_ctrl(bluetooth_device_address_t *address)
        status = avrcp_tg_disconnect(&bdaddr);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("DisConnection err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
 
        BT_DBG("-");
@@ -297,7 +297,7 @@ int _bt_avrcp_set_track_info(media_metadata_attributes_t *meta_data)
        result = avrcp_set_track_info(&media_attr);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("hid_connect error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -314,7 +314,7 @@ int _bt_avrcp_target_notify_volume(bluetooth_device_address_t *address, unsigned
        result = avrcp_tg_set_volume(&bdaddr, volume);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("hid_connect error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -330,7 +330,7 @@ int _bt_avrcp_target_get_volume(bluetooth_device_address_t *address, unsigned in
        result = avrcp_tg_get_volume(&bdaddr, volume);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("hid_connect error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -643,7 +643,7 @@ int _bt_service_avrcp_enable(void)
        status = avrcp_enable();
        if (OAL_STATUS_SUCCESS != status) {
                BT_ERR("Failed to initialize Bluetooth AVRCP Target Profile, status: %d", status);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(status);
        }
 
        /* Register AVRCP target event handler */
@@ -659,7 +659,7 @@ int _bt_service_avrcp_disable(void)
        status = avrcp_disable();
        if (OAL_STATUS_SUCCESS != status) {
                BT_ERR("Failed to initialize Bluetooth A2DP Source Profile, status: %d", status);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(status);
        }
 
        /* Register AVRCP target event handler */
index 6d1af1b..ffed1d4 100644 (file)
@@ -535,7 +535,7 @@ int _bt_audio_initialize(bt_service_module_t module)
                status = audio_enable(NULL, NULL);
                if (OAL_STATUS_SUCCESS != status) {
                        BT_ERR("Failed to initialize Bluetooth A2DP Source Profile, status: %d", status);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(status);
                }
                /* Register Audio module event handler */
                _bt_service_register_event_handler_callback(module, _bt_a2dp_source_event_handler);
@@ -545,7 +545,7 @@ int _bt_audio_initialize(bt_service_module_t module)
                status = a2dp_sink_enable(NULL, NULL);
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Failed to initialize Bluetooth A2DP Sink Profile, status: %d", status);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(status);
                }
                /* Register Audio sink module event handler */
                _bt_service_register_event_handler_callback(module, _bt_a2dp_sink_event_handler);
@@ -555,7 +555,7 @@ int _bt_audio_initialize(bt_service_module_t module)
                status = hf_client_enable();
                if (OAL_STATUS_SUCCESS != status) {
                        BT_ERR("Failed to initialize Bluetooth HFP client Profile, status: %d", status);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(status);
                }
                /* Register Audio module event handler */
                _bt_service_register_event_handler_callback(module, _bt_hf_client_event_handler);
@@ -565,7 +565,7 @@ int _bt_audio_initialize(bt_service_module_t module)
                status = hfp_enable(1);
                if (OAL_STATUS_SUCCESS != status) {
                        BT_ERR("Failed to initialize Bluetooth HFP Audio Gateway Profile, status: %d", status);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(status);
                }
                /* Register Audio module event handler */
                _bt_service_register_event_handler_callback(module, _bt_hf_event_handler);
@@ -580,7 +580,7 @@ int _bt_audio_initialize(bt_service_module_t module)
                status = avrcp_ct_enable();
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Failed to initialize Bluetooth AVRCP Controller Profile, status: %d", status);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(status);
                }
                /* Register Avrcp Controller event handler */
                _bt_service_register_event_handler_callback(module, _bt_avrcp_ctrl_event_handler);
@@ -1177,7 +1177,7 @@ static gboolean __handle_pending_audio_select_role(gpointer data)
                status = a2dp_sink_disable();
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Failed to Disable Bluetooth A2DP Sink Profile, status: %d", status);
-                       ret = BLUETOOTH_ERROR_INTERNAL;
+                       ret = _bt_convert_oal_status_to_bt_error(status);
                        goto done;
                }
 
@@ -1185,7 +1185,7 @@ static gboolean __handle_pending_audio_select_role(gpointer data)
                status = avrcp_ct_disable();
                if (status != OAL_STATUS_SUCCESS) {
                        BT_ERR("Failed to Disable Bluetooth AVRCP Controller Profile, status: %d", status);
-                       ret = BLUETOOTH_ERROR_INTERNAL;
+                       ret = _bt_convert_oal_status_to_bt_error(status);
                        goto done;
                }
 
@@ -1207,7 +1207,7 @@ static gboolean __handle_pending_audio_select_role(gpointer data)
                status = audio_disable();
                if (OAL_STATUS_SUCCESS != status) {
                        BT_ERR("Failed to disable Bluetooth A2DP Source Profile, status: %d", status);
-                       ret = BLUETOOTH_ERROR_INTERNAL;
+                       ret = _bt_convert_oal_status_to_bt_error(status);
                        goto done;
                }
 
@@ -1267,7 +1267,7 @@ int _bt_audio_select_role(bluetooth_audio_role_t role)
                        result = _bt_audio_disconnect(BT_AUDIO_A2DP, &dev_addr);
                        if (result != BLUETOOTH_ERROR_NONE) {
                                BT_ERR("_bt_audio_disconnect(BT_AUDIO_A2DP, %s) Failed", address);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                        }
                } else {
                        BT_INFO("No BT_AUDIO_A2DP device is connected, proceed with role switch");
@@ -1280,7 +1280,7 @@ int _bt_audio_select_role(bluetooth_audio_role_t role)
                        result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &dev_addr);
                        if (result != BLUETOOTH_ERROR_NONE) {
                                BT_ERR("_bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, %s) Failed", address);
-                               result = BLUETOOTH_ERROR_INTERNAL;
+                               result = _bt_convert_oal_status_to_bt_error(result);
                        }
                } else {
                        BT_INFO("No BT_AUDIO_A2DP_SOURCE device is connected, proceed with role switch");
index 9d4f054..646669f 100644 (file)
@@ -164,7 +164,7 @@ int _bt_connect_remote_ag(bluetooth_device_address_t *device_address)
        status = hf_client_connect((bt_address_t *)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("HF Client Connection could not be established, err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
@@ -178,7 +178,7 @@ int _bt_disconnect_remote_ag(bluetooth_device_address_t *device_address)
        status = hf_client_disconnect((bt_address_t *)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("HF Client DisConnection err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
index 7d79a93..3917a92 100755 (executable)
@@ -280,7 +280,7 @@ int _bt_connect_remote_hfp(bluetooth_device_address_t *device_address)
        status = hfp_connect((bt_address_t *)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("Connection could not be established, err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
@@ -294,7 +294,7 @@ int _bt_disconnect_remote_hfp(bluetooth_device_address_t *device_address)
        status = hfp_disconnect((bt_address_t *)device_address);
        if (status != OAL_STATUS_SUCCESS) {
                BT_ERR("DisConnection err: [%d]", status);
-               result = BLUETOOTH_ERROR_INTERNAL;
+               result = _bt_convert_oal_status_to_bt_error(status);
        }
        return result;
 }
index 4eda6a8..0b60679 100644 (file)
@@ -471,6 +471,43 @@ void _bt_convert_addr_type_to_string(char *address,
                        addr[3], addr[4], addr[5]);
 }
 
+int _bt_convert_oal_status_to_bt_error(oal_status_t oal_status)
+{
+       switch (oal_status) {
+       case OAL_STATUS_SUCCESS:
+               return BLUETOOTH_ERROR_NONE;
+       case OAL_STATUS_INVALID_PARAM:
+               return BLUETOOTH_ERROR_INVALID_PARAM;
+       case OAL_STATUS_NOT_SUPPORT:
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       case OAL_STATUS_NOT_READY:
+               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+       case OAL_STATUS_BUSY:
+               return BLUETOOTH_ERROR_DEVICE_BUSY;
+       case OAL_STATUS_NOT_PAIRED:
+               return BLUETOOTH_ERROR_NOT_PAIRED;
+       case OAL_STATUS_ALREADY_DONE:
+               return BLUETOOTH_ERROR_ALREADY_CONNECT;
+       case OAL_STATUS_PENDING:
+               return BLUETOOTH_ERROR_IN_PROGRESS;
+       case OAL_STATUS_INTERNAL_ERROR:
+       case OAL_STATUS_RMT_DEVICE_DOWN:
+       case OAL_STATUS_AUTH_FAILED:
+       case OAL_STATUS_CONN_TIMEOUT:
+       case OAL_STATUS_HID_FAILED_MOUSE:
+#ifndef TIZEN_BT_HAL
+       case OAL_STATUS_LINK_LOSS:
+#else
+       case OAL_STATUS_LINK_LOSS:
+       case OAL_STATUS_CONN_TERM_LOCAL_HOST:
+       case OAL_STATUS_CONN_TERM_RMT_HOST:
+       case OAL_STATUS_ALREADY_CONNECT:
+#endif
+       default:
+               return BLUETOOTH_ERROR_INTERNAL;
+       }
+}
+
 gboolean _bt_compare_adddress(const bluetooth_device_address_t *addr1,
                const bluetooth_device_address_t *addr2)
 {
index b454651..9585a7b 100644 (file)
@@ -446,7 +446,7 @@ int _bt_set_trust_profile(bluetooth_device_address_t *addr,
        result = device_set_trust_profile(&bd_addr, oal_profile, trust);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("device_set_trust_profile error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -471,7 +471,7 @@ int _bt_get_trust_profile(bluetooth_device_address_t *addr,
        result = device_get_trust_profile(&bd_addr, oal_profile, trust);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("device_set_trust_profile error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -1737,7 +1737,7 @@ static int __bt_device_handle_bond_state(void)
        }
 
        if (ret != OAL_STATUS_SUCCESS)
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        else
                return BLUETOOTH_ERROR_NONE;
 }
@@ -1753,7 +1753,7 @@ int _bt_device_get_bonded_device_info(bluetooth_device_address_t *addr)
        result = device_query_attributes(&bd_addr);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("device_query_attributes error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -1769,7 +1769,7 @@ int _bt_set_alias(bluetooth_device_address_t *device_address, const char *alias)
        ret = device_set_alias((bt_address_t *)device_address, (char *)alias);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("device_set_alias: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        /* Update local cache */
@@ -1883,10 +1883,7 @@ fail:
                        sizeof(bluetooth_device_info_t));
        __bt_free_bond_info(BT_DEVICE_UNBOND_INFO);
 
-       if (result == OAL_STATUS_NOT_PAIRED)
-               return BLUETOOTH_ERROR_NOT_PAIRED;
-
-       return BLUETOOTH_ERROR_INTERNAL;
+       return _bt_convert_oal_status_to_bt_error(result);
 }
 
 int _bt_cancel_bonding(void)
@@ -1932,7 +1929,7 @@ int _bt_passkey_reply(const char *passkey, gboolean cnfm_reply)
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("_bt_device_handle_passkey_reply: err [%d]", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        BT_INFO("-");
@@ -2023,7 +2020,7 @@ int _bt_search_device(bluetooth_device_address_t *device_address)
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("Device Service Search Failed..: %d", result);
                __bt_free_service_search_info(&service_search_info);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2037,7 +2034,7 @@ int _bt_cancel_search_device(void)
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("SDP Cancel request failed [%d]", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        __bt_device_handle_pending_requests(BLUETOOTH_ERROR_CANCEL_BY_USER, BT_SEARCH_SERVICE,
@@ -2061,7 +2058,7 @@ int _bt_set_authorization(bluetooth_device_address_t *device_address,
        ret = device_set_authorized((bt_address_t*)device_address, authorize);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("device_set_authorized: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -2123,7 +2120,7 @@ int _bt_rfcomm_reply_conn_authorization(char *address, gboolean reply)
        res = device_reply_auth_request(&bd_addr, 0, reply, FALSE);
        if (res != OAL_STATUS_SUCCESS) {
                BT_ERR("authorize_response: %d", res);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(res);
        }
 
        BT_DBG("-");
@@ -2145,7 +2142,7 @@ int _bt_enable_rssi(bluetooth_device_address_t *addr, int link_type,
                        low_threshold, in_range_threshold, high_threshold);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("device_get_connected_link_rssi_strength error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -2165,7 +2162,7 @@ int _bt_get_rssi_strength(bluetooth_device_address_t *addr, int link_type)
        result = device_get_connected_link_rssi_strength(&bd_addr, link_type);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("device_get_connected_link_rssi_strength error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
@@ -2182,7 +2179,7 @@ int _bt_set_passkey_notification(const char *sender, gboolean enable)
        result = device_enable_gap_auth_notifications(OAL_PASSKEY_DISPLAY, enable);
        if (OAL_STATUS_SUCCESS != result) {
                BT_ERR("device_enable_gap_auth_notifications error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        g_free(passkey_watcher);
@@ -2296,7 +2293,7 @@ int _bt_device_get_ida(bluetooth_device_address_t *device_address, bluetooth_dev
 
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("device_get_ida Failed %d", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        return result;
@@ -2605,7 +2602,7 @@ update:
        if (ret != OAL_STATUS_SUCCESS) {
                _bt_remove_le_conn_param_info(address, sender);
                BT_DBG("fail to update the LE connection parameter");
-               ret = BLUETOOTH_ERROR_INTERNAL;
+               ret = _bt_convert_oal_status_to_bt_error(ret);
                goto fail;
        }
 
@@ -2628,7 +2625,7 @@ int _bt_disconnect_device(bluetooth_device_address_t *device_address)
        result = device_disconnect((bt_address_t *)device_address);
        if (result != OAL_STATUS_SUCCESS) {
                BT_DBG("Failed to disconnect device");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        BT_DBG("-");
index 78368c9..a3a0d78 100644 (file)
@@ -471,12 +471,14 @@ static void __bt_register_default_gatt_client()
 int _bt_gatt_init(void)
 {
        const char *stack_name = NULL;
+       int result;
 
        BT_DBG("+");
 
-       if (OAL_STATUS_SUCCESS != gatt_enable()) {
+       result = gatt_enable();
+       if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("gatt Init failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        /* Register gatt event handler */
@@ -693,7 +695,7 @@ static int __bt_unregister_gatt_client_instance(int client_if)
                        ret = gattc_deregister(client_if);
                        if (ret != OAL_STATUS_SUCCESS) {
                                BT_ERR("DeAllocate GATT Client instance with stack Fail ret: %d", ret);
-                               return BLUETOOTH_ERROR_INTERNAL;
+                               return _bt_convert_oal_status_to_bt_error(ret);
                        }
                        break;
                }
@@ -710,7 +712,7 @@ static int __bt_unregister_gatt_server_instance(int server_instance)
        ret = gatts_unregister(server_instance);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("DeAllocate server instance with stack Fail ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        BT_INFO("DeAllocated server instance with stack successful..");
 
@@ -872,7 +874,7 @@ int _bt_register_server_instance(const char *sender, int adv_handle)
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(uuid_string);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        BT_DBG("GATT Server registration call successfully accepted by OAL..wait for Instance Initialized event from OAL..");
        /* Return & wait for GATT Server Instance Initialization event */
@@ -2261,7 +2263,7 @@ int _bt_gatt_server_add_service(char *sender, int service_type,
        ret = gatts_add_service(instance_id, &svc_data, num_handles);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -2277,7 +2279,7 @@ int _bt_gatt_server_add_included_service(char *sender, int instance_id,
        ret = gatts_add_included_services(instance_id, service_handle, included_svc_handle);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2301,7 +2303,7 @@ int _bt_gatt_server_add_characteristic(char *sender, char *char_uuid,
                        param->properties, (int)param->permissions);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2326,7 +2328,7 @@ int _bt_gatt_server_add_descriptor(char *sender, char *desc_uuid,
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2339,7 +2341,7 @@ int _bt_gatt_server_start_service(char *sender, int service_handle, int instance
        ret = gatts_start_service(instance_id, service_handle, BT_GATT_TRANSPORT_LE);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2352,7 +2354,7 @@ int _bt_gatt_server_stop_service(char *sender, int service_handle, int instance_
        ret = gatts_stop_service(instance_id, service_handle);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -2367,7 +2369,7 @@ int _bt_gatt_server_delete_service(char *sender, int service_handle, int instanc
        ret = gatts_delete_service(instance_id, service_handle);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        /* Remove the Service Handle */
@@ -2423,7 +2425,7 @@ int _bt_gatt_server_send_response(char *sender, bluetooth_gatt_att_data_t *data,
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        /* Remove GATT server request from list */
@@ -2457,7 +2459,7 @@ int _bt_gatt_server_acquire_send_response(char *sender, bluetooth_gatt_server_ac
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        /* Remove GATT server request from list */
@@ -2497,7 +2499,7 @@ int _bt_gatt_server_send_indication(char *sender, bluetooth_device_address_t *de
                if (ret != OAL_STATUS_SUCCESS) {
                        BT_ERR("ret: %d", ret);
                        g_free(address);
-                       return BLUETOOTH_ERROR_INTERNAL;
+                       return _bt_convert_oal_status_to_bt_error(ret);
                }
 
        } else {
@@ -2511,7 +2513,7 @@ int _bt_gatt_server_send_indication(char *sender, bluetooth_device_address_t *de
                                BT_ERR("ret: %d", ret);
                                BT_INFO("Indication failed to send to Remote GATT Client [%s]", address);
                                g_free(address);
-                               return BLUETOOTH_ERROR_INTERNAL;
+                               return _bt_convert_oal_status_to_bt_error(ret);
                        }
                        BT_INFO("Indication sent to Remote GATT Client [%s] wait for Notification completed event from OAL", address);
                        g_free(address);
@@ -2547,7 +2549,7 @@ int _bt_gatt_server_update_attribute_value(char *sender, int instance_id,
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -2575,7 +2577,7 @@ int _bt_request_att_mtu(bluetooth_device_address_t *device_address,
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        g_free(addr);
@@ -2608,7 +2610,7 @@ int _bt_get_att_mtu(bluetooth_device_address_t *address,
        ret = gatts_get_att_mtu(conn_info->connection_id, &stack_mtu);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        BT_INFO("ATT MTU received from OAL [%d]", stack_mtu);
@@ -3054,7 +3056,7 @@ int _bt_register_gatt_client_instance(const char *sender,
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(uuid_string);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        BT_DBG("GATT Client registration call successfully accepted by OAL..wait for Instance Initialized event from OAL..");
@@ -4286,7 +4288,7 @@ int _bt_connect_le_device(bluetooth_device_address_t *address,
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("gattc_connect is failed. ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        /* Mark this as outgoing connection */
@@ -4329,7 +4331,7 @@ int _bt_gatt_get_primary_services(char *address)
        ret = gattc_search_service(conn_info->connection_id, NULL);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -4380,7 +4382,7 @@ int _bt_gatt_get_all_characteristic(bluetooth_gatt_client_svc_prop_info_t *svc)
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4441,7 +4443,7 @@ int _bt_gatt_get_all_characteristic_properties(
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4502,7 +4504,7 @@ int _bt_gatt_read_characteristic_value(
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4570,7 +4572,7 @@ int _bt_gatt_read_descriptor_value(
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4613,7 +4615,7 @@ int _bt_gatt_acquire_notify(bluetooth_gatt_client_char_prop_info_t *chr, int *fd
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        BT_INFO("GATT characterstics FD [%d]  mtu[%d]", *fd, *mtu);
        g_free(addr);
@@ -4658,7 +4660,7 @@ int _bt_gatt_acquire_write(bluetooth_gatt_client_char_prop_info_t *chr, int *fd,
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        BT_INFO("GATT characterstics FD [%d]  mtu [%d]", *fd, *mtu);
        g_free(addr);
@@ -4729,7 +4731,7 @@ int _bt_gatt_write_characteristic_value_by_type(
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4810,7 +4812,7 @@ int _bt_gatt_write_descriptor_value_by_type(
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4865,7 +4867,7 @@ int _bt_gatt_watch_characteristic(
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4932,7 +4934,7 @@ int _bt_disconnect_le_device(bluetooth_device_address_t *address,
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
                g_free(addr);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
        g_free(addr);
        return BLUETOOTH_ERROR_NONE;
@@ -4986,7 +4988,7 @@ int _bt_unregister_gatt_client_instance(const char *sender, int client_id)
                        ret = gattc_deregister(client_id);
                        if (ret != OAL_STATUS_SUCCESS) {
                                BT_ERR("DeAllocate GATT Client instance with stack Fail ret: %d", ret);
-                               return BLUETOOTH_ERROR_INTERNAL;
+                               return _bt_convert_oal_status_to_bt_error(ret);
                        } else {
                                return BLUETOOTH_ERROR_NONE;
                        }
@@ -5108,9 +5110,7 @@ int _bt_gatt_get_data_batching_available_packets(
        ret = gatt_get_data_batching_available_packets(available_packets);
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               if (ret == OAL_STATUS_NOT_SUPPORT)
-                       return BLUETOOTH_ERROR_NOT_SUPPORT;
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -5132,11 +5132,7 @@ int _bt_gatt_enable_data_batching(bluetooth_device_address_t *address,
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               if (ret == OAL_STATUS_INVALID_PARAM)
-                       return BLUETOOTH_ERROR_INVALID_PARAM;
-               else if (ret == OAL_STATUS_NOT_SUPPORT)
-                       return BLUETOOTH_ERROR_NOT_SUPPORT;
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
@@ -5156,9 +5152,7 @@ int _bt_gatt_disable_data_batching(bluetooth_device_address_t *address)
 
        if (ret != OAL_STATUS_SUCCESS) {
                BT_ERR("ret: %d", ret);
-               if (ret == OAL_STATUS_NOT_SUPPORT)
-                       return BLUETOOTH_ERROR_NOT_SUPPORT;
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(ret);
        }
 
        return BLUETOOTH_ERROR_NONE;
index 71fa458..e0197f6 100644 (file)
@@ -257,7 +257,7 @@ static void __bt_hid_event_handler(int event_type, gpointer event_data)
                }
 
                if (OAL_STATUS_SUCCESS != event->status)
-                       result = BLUETOOTH_ERROR_INTERNAL;
+                       result = _bt_convert_oal_status_to_bt_error(event->status);
 
                if (BLUETOOTH_ERROR_NONE == result)
                        __bt_handle_hid_disconnection(address);
@@ -283,12 +283,14 @@ static void __bt_hid_event_handler(int event_type, gpointer event_data)
 
 int _bt_hidhost_initialize()
 {
+       int result;
        BT_DBG("+");
 
        /* Enable HID Profile */
-       if (OAL_STATUS_SUCCESS != hid_enable()) {
+       result = hid_enable();
+       if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("HID Enable failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        /* Register HID event handler */
@@ -336,7 +338,7 @@ int _bt_hid_connect(bluetooth_device_address_t *device_address)
        result = hid_connect(&bd_addr);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("hid_connect error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
        return BLUETOOTH_ERROR_NONE;
 }
@@ -357,7 +359,7 @@ int _bt_hid_disconnect(bluetooth_device_address_t *device_address)
        result = hid_disconnect(&bd_addr);
        if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("hid_disconnect error: [%d]", result);
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
        return BLUETOOTH_ERROR_NONE;
 }
index db3596f..69bc03f 100644 (file)
@@ -385,6 +385,8 @@ void _bt_convert_addr_string_to_type(unsigned char *addr,
 void _bt_convert_addr_type_to_string(char *address,
                                unsigned char *addr);
 
+int _bt_convert_oal_status_to_bt_error(oal_status_t oal_status);
+
 void _bt_swap_byte_ordering(char *data, int data_len);
 
 int _bt_byte_arr_cmp(const char *data1, const char *data2, int data_len);
index 1d899e9..f89e941 100644 (file)
@@ -254,11 +254,13 @@ int _bt_socket_listen(int sock_type, char *svc_name, char *server_uuid, int chan
 
 int _bt_socket_init(void)
 {
+       int result;
        BT_INFO("Socket Init");
 
-       if (OAL_STATUS_SUCCESS != socket_enable()) {
+       result = socket_enable();
+       if (result != OAL_STATUS_SUCCESS) {
                BT_ERR("Socket init failed");
-               return BLUETOOTH_ERROR_INTERNAL;
+               return _bt_convert_oal_status_to_bt_error(result);
        }
 
        /* Register SOCKET event handler */