From: injun.yang Date: Wed, 11 Mar 2020 04:32:20 +0000 (+0900) Subject: Use standard error code for ACL disconnection X-Git-Tag: submit/tizen/20200316.013847~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f0755f6e0352fa912fa66496932de87f5e1f83e;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Use standard error code for ACL disconnection [Model] All [BinType] AP [Customer] OPEN [Issue#] N/A [Request] Internal [Occurrence Version] N/A [Problem] Disconnection reason is not exact in bt-service [Cause & Measure] Use standard error code in bt-service [Checking Method] n/a [Team] Convergence BT [Developer] Injun Yang [Solution company] Samsung [Change Type] Specification change Change-Id: I8b3d36a9cc5cb67b087aa0585757f4863e9dd7d1 --- diff --git a/bt-oal/bluez_hal/inc/bt-hal-msg.h b/bt-oal/bluez_hal/inc/bt-hal-msg.h index 5caaaa8..03e6f6b 100644 --- a/bt-oal/bluez_hal/inc/bt-hal-msg.h +++ b/bt-oal/bluez_hal/inc/bt-hal-msg.h @@ -182,9 +182,9 @@ struct hal_ev_sock_conn_auth { #define HAL_EV_ACL_STATE_CHANGED 0x8A struct hal_ev_acl_state_changed { - uint8_t status; + uint8_t status; /* Error code */ uint8_t bdaddr[6]; - uint8_t state; + uint8_t state; /* Link state */ } __attribute__((packed)); #define HAL_DEVICE_TRUSTED 0x00 diff --git a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c index 49a7ad7..35859ad 100644 --- a/bt-oal/bluez_hal/src/bt-hal-bluetooth.c +++ b/bt-oal/bluez_hal/src/bt-hal-bluetooth.c @@ -753,7 +753,8 @@ static void __bt_hal_handle_device_acl_state_changed_event(void *buf, uint16_t l bt_bdaddr_t bd_addr; memcpy(bd_addr.address, ev->bdaddr, 6); - INFO("ACL status[0x%x], state[0x%x]: XX:XX:XX:XX:XX:%02X", ev->status, ev->state, bd_addr.address[5]); + DBG("ACL status[0x%x], Link state[0x%x] XX:XX:XX:XX:%02X:%02X", + ev->status, ev->state, bd_addr.address[4], bd_addr.address[5]); if (!bt_hal_cbacks->acl_state_changed_cb) { ERR("HAL User acl_state_changed_cb is not set!!"); @@ -770,9 +771,8 @@ static void __bt_hal_handle_device_le_conn_state_changed_event(void *buf, uint16 memcpy(bd_addr.address, ev->bdaddr, 6); - DBG("LE conn Status [0x%x] State [0x%x] [%02X:%02X:%02X:%02X:%02X:%02X]", ev->status, ev->state, - bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], - bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]); + DBG("ACL status[0x%x], Link state[0x%x] XX:XX:XX:XX:%02X:%02X", + ev->status, ev->state, bd_addr.address[4], bd_addr.address[5]); #ifdef TIZEN_BT_HAL if (!bt_hal_cbacks->le_conn_state_changed_cb) { @@ -1042,7 +1042,6 @@ static void __bt_hal_handle_stack_messages(int message, void *buf, uint16_t len) __bt_hal_handle_bond_state_changed_event(buf, len); break; case HAL_EV_ACL_STATE_CHANGED: - DBG("Event: HAL_ACL_STATE_CONNECTED or Disconnected"); __bt_hal_handle_device_acl_state_changed_event(buf, len); break; case HAL_EV_LE_CONN_STATE_CHANGED: diff --git a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c index 90f74fc..10dde52 100644 --- a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c +++ b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.c @@ -1199,21 +1199,6 @@ char * _bt_hal_convert_disc_reason_to_string(int reason) } } -int _bt_hal_convert_disc_reason_to_status(int reason) -{ - switch (reason) { - case 1: - return BT_STATUS_CONN_TOUT; //"Link loss" - case 2: - return BT_STATUS_CONN_TERM_LOCAL_HOST; //"Connection terminated by local host"; - case 3: - return BT_STATUS_CONN_TERM_RMT_HOST; //"Connection terminated by local host"; - case 0: - default: - return BT_STATUS_FAIL; - } -} - void _bt_hal_logging_connection(gboolean connect, int addr_type) { static int le_conn = 0; diff --git a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h index 8615f7c..1206c2f 100644 --- a/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h +++ b/bt-oal/bluez_hal/src/bt-hal-dbus-common-utils.h @@ -485,8 +485,6 @@ extern "C" { char * _bt_hal_convert_disc_reason_to_string(int reason); - int _bt_hal_convert_disc_reason_to_status(int reason); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c index 8369fb9..5483abf 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -1894,7 +1894,6 @@ static void __bt_hal_device_properties_lookup(GVariant *result, char *address) static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean connected, const char *address) { - DBG("+"); struct hal_ev_acl_state_changed ev; ev.status = status; @@ -2035,9 +2034,9 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason), address, name); if (!addr_type) - __bt_hal_send_device_acl_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address); + __bt_hal_send_device_acl_connection_state_event(disc_reason, FALSE, address); else - __bt_hal_send_device_le_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address); + __bt_hal_send_device_le_connection_state_event(disc_reason, FALSE, address); g_free(address); } else if (strcasecmp(member, "ProfileStateChanged") == 0) { int state = 0; diff --git a/bt-oal/oal-device-mgr.c b/bt-oal/oal-device-mgr.c index d3da0d3..790ff2c 100755 --- a/bt-oal/oal-device-mgr.c +++ b/bt-oal/oal-device-mgr.c @@ -762,16 +762,13 @@ void cb_device_acl_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_acl_state_t state) { event_dev_conn_status_t * conn_status = g_new0(event_dev_conn_status_t, 1); - //bt_address_t * address = g_new0(bt_address_t, 1); oal_event_t event; gsize size = 0; - BT_DBG("ACL State:%d, state: %d", status, state); - memcpy(conn_status->address.addr, bd_addr->address, 6); #ifdef TIZEN_BT_HAL - conn_status->status = convert_to_oal_status(status); + conn_status->status = status; #else if (BT_STATUS_SUCCESS != status) { /* At present only timeout will cause non-success status, later we can add more */ @@ -783,7 +780,7 @@ void cb_device_acl_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, memcpy(conn_status->address.addr, bd_addr->address, 6); #endif - BT_INFO("ACL STATE :%d, conn_status->status :%d, BT_ACL_STATE: %d", status, conn_status->status, state); + BT_INFO("[ACL] Status: %d, State: %d", conn_status->status, state); switch (state) { case BT_ACL_STATE_CONNECTED: @@ -808,13 +805,12 @@ void cb_device_le_conn_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_le_conn_state_t state) { event_dev_conn_status_t * conn_status = g_new0(event_dev_conn_status_t, 1); - //bt_address_t * address = g_new0(bt_address_t, 1); oal_event_t event; gsize size = 0; - BT_DBG("LE conn status:%d, state: %d", status, state); memcpy(conn_status->address.addr, bd_addr->address, 6); - conn_status->status = convert_to_oal_status(status); + conn_status->status = status; + BT_INFO("[LE ACL] Status: %d, State: %d", conn_status->status, state); switch (state) { case BT_LE_CONN_STATE_CONNECTED: diff --git a/bt-service-adaptation/services/device/bt-service-core-device.c b/bt-service-adaptation/services/device/bt-service-core-device.c index d0ce179..a0fe7cc 100644 --- a/bt-service-adaptation/services/device/bt-service-core-device.c +++ b/bt-service-adaptation/services/device/bt-service-core-device.c @@ -1062,24 +1062,22 @@ static void __bt_device_event_handler(int event_type, gpointer event_data) break; } case OAL_EVENT_DEVICE_ACL_CONNECTED: { - BT_INFO("ACL Connected event Received"); - event_dev_conn_status_t* param = event_data; - __bt_device_acl_state_changed_callback(param, TRUE, 0); + BT_DBG("ACL Connected event Received"); + __bt_device_acl_state_changed_callback((event_dev_conn_status_t *)event_data, TRUE, 0); break; } case OAL_EVENT_DEVICE_ACL_DISCONNECTED: { - BT_INFO("ACL Disconnected event Received"); + BT_DBG("ACL Disconnected event Received"); __bt_device_acl_state_changed_callback((event_dev_conn_status_t *)event_data, FALSE, 0); break; } case OAL_EVENT_DEVICE_LE_CONNECTED: { - BT_INFO("LE Connected event Received"); - event_dev_conn_status_t* param = event_data; - __bt_device_acl_state_changed_callback(param, TRUE, 1); + BT_DBG("LE Connected event Received"); + __bt_device_acl_state_changed_callback((event_dev_conn_status_t *)event_data, TRUE, 1); break; } case OAL_EVENT_DEVICE_LE_DISCONNECTED: { - BT_INFO("LE Disconnected event Received"); + BT_DBG("LE Disconnected event Received"); __bt_device_acl_state_changed_callback((event_dev_conn_status_t *)event_data, FALSE, 1); break; } @@ -1468,42 +1466,11 @@ static void __bt_device_ssp_consent_callback(remote_device_t* dev_info) BT_DBG("-"); } -static int __bt_oal_status_to_bt_error(int oal_status) -{ - int ret = 0; - - switch (oal_status) { - case OAL_STATUS_SUCCESS: - ret = BLUETOOTH_ERROR_NONE; - break; - case OAL_STATUS_CONN_TIMEOUT: - case OAL_STATUS_LINK_LOSS: - BT_INFO("Connection Timeout"); - ret = BLUETOOTH_ERROR_CONNECTION_TIMEOUT; - break; -#ifdef TIZEN_BT_HAL - case OAL_STATUS_CONN_TERM_LOCAL_HOST: - ret = BLUETOOTH_ERROR_LOCAL_HOST_TERM; - break; - case OAL_STATUS_CONN_TERM_RMT_HOST: - ret = BLUETOOTH_ERROR_REMOTE_USER_TERM; - break; -#endif - case OAL_STATUS_INTERNAL_ERROR: - ret = BLUETOOTH_ERROR_INTERNAL; - break; - default: - ret = BLUETOOTH_ERROR_INTERNAL; - break; - } - return ret; -} - static void __bt_device_acl_state_changed_callback(event_dev_conn_status_t *acl_event, gboolean connected, unsigned char type) { gchar address[BT_ADDRESS_STR_LEN]; - int result = BLUETOOTH_ERROR_NONE; + int disc_reason = 0; GVariant *param = NULL; bt_device_conn_info_t conn_info; @@ -1511,22 +1478,21 @@ static void __bt_device_acl_state_changed_callback(event_dev_conn_status_t *acl_ _bt_logging_connection(connected, type); - result = __bt_oal_status_to_bt_error(acl_event->status); - BT_DBG("Result [0x%x]", result); + disc_reason = acl_event->status; if (connected) { - param = g_variant_new("(isy)", result, address, type); + BT_PERMANENT_LOG("Connected %s %s", !type ? "EDR" : "LE", address + 12); + param = g_variant_new("(isy)", BLUETOOTH_ERROR_NONE, address, type); _bt_send_event(BT_DEVICE_EVENT, BLUETOOTH_EVENT_DEVICE_CONNECTED, param); } else { - param = g_variant_new("(isyi)", result, address, type, dbfw_rssi); + BT_PERMANENT_LOG("Disconnected %s(%d) %s", !type ? "EDR" : "LE", disc_reason, address + 12); + param = g_variant_new("(isyi)", disc_reason, address, type, dbfw_rssi); _bt_send_event(BT_DEVICE_EVENT, BLUETOOTH_EVENT_DEVICE_DISCONNECTED, param); } - BT_PERMANENT_LOG("%sonnected %s %s", - connected ? "C" : "Disc", !type ? "EDR" : "LE", address + 12); conn_info.connected = connected; conn_info.type = type;