conn_info.addr_type = addr_type;
conn_info.disc_reason = result;
- BT_DBG("Sending Event to Framework");
+ BT_DBG("Sending Event to Framework, disconnect reason [0x%x]", result);
_bt_common_event_cb(BLUETOOTH_EVENT_DEVICE_DISCONNECTED,
result, &conn_info,
event_info->cb, event_info->user_data);
}
}
+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;
GVariant *_bt_hal_get_managed_objects(void);
+ char * _bt_hal_convert_disc_reason_to_string(int reason);
+
+ int _bt_hal_convert_disc_reason_to_status(int reason);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
static void __bt_hal_dbus_device_found_properties(const char *device_path);
static void __bt_hal_device_properties_lookup(GVariant *result, char *address);
static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *member, const char *path);
-static void __bt_hal_send_device_acl_connection_state_event(gboolean connected, const char *address);
+static void __bt_hal_send_device_acl_connection_state_event(int status, gboolean connected, const char *address);
static void __bt_hal_handle_input_event(GVariant *msg, const char *path);
static void __bt_hal_send_av_connection_state_event(gboolean connected, const char *address);
static void __bt_hal_send_a2dp_sink_connection_state_event(gboolean connected, const char *address);
DBG("-");
}
-static void __bt_hal_send_device_acl_connection_state_event(gboolean connected, const 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 = BT_STATUS_SUCCESS;
+ ev.status = status;
ev.state = (connected == TRUE) ?
HAL_ACL_STATE_CONNECTED :
HAL_ACL_STATE_DISCONNECTED;
DBG("-");
}
-static void __bt_hal_send_device_le_connection_state_event(gboolean connected, const char *address)
+static void __bt_hal_send_device_le_connection_state_event(int status, gboolean connected, const char *address)
{
DBG("+");
struct hal_ev_le_conn_state_changed ev;
- ev.status = BT_STATUS_SUCCESS;
+ ev.status = status;
ev.state = (connected == TRUE) ?
HAL_LE_STATE_CONNECTED :
HAL_LE_STATE_DISCONNECTED;
DBG("Member: [%s]", member);
ERR_C("Connected [%s] [%s]", !addr_type ? "BREDR" : "LE", address);
if (!addr_type)
- __bt_hal_send_device_acl_connection_state_event(TRUE, address);
+ __bt_hal_send_device_acl_connection_state_event(BT_STATUS_SUCCESS, TRUE, address);
else
- __bt_hal_send_device_le_connection_state_event(TRUE, address);
+ __bt_hal_send_device_le_connection_state_event(BT_STATUS_SUCCESS, TRUE, address);
g_free(address);
} else if (strcasecmp(member, "Disconnected") == 0) {
unsigned char disc_reason = 0;
_bt_hal_convert_device_path_to_address(path, address);
DBG("Member: [%s]", member);
+
ERR_C("DisConnected [%s] [%s]", !addr_type ? "BREDR" : "LE", address);
- DBG("Disconnect Reason: %d", disc_reason);
+ DBG("Disconnected Reason [%d : %s]", disc_reason, _bt_hal_convert_disc_reason_to_string(disc_reason));
DBG("Name: %s", name);
if (!addr_type)
- __bt_hal_send_device_acl_connection_state_event(FALSE, address);
+ __bt_hal_send_device_acl_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
else
- __bt_hal_send_device_le_connection_state_event(FALSE, address);
+ __bt_hal_send_device_le_connection_state_event(_bt_hal_convert_disc_reason_to_status(disc_reason), FALSE, address);
g_free(address);
} else if (strcasecmp(member, "ProfileStateChanged") == 0) {
int state = 0;
case BT_STATUS_UNSUPPORTED:
ret = OAL_STATUS_NOT_SUPPORT;
break;
+ case BT_STATUS_CONN_TOUT:
+ ret = OAL_STATUS_LINK_LOSS;
+ break;
+#ifdef TIZEN_BT_HAL
+ case BT_STATUS_CONN_TERM_LOCAL_HOST:
+ ret = OAL_STATUS_CONN_TERM_LOCAL_HOST;
+ break;
+ case BT_STATUS_CONN_TERM_RMT_HOST:
+ ret = OAL_STATUS_CONN_TERM_RMT_HOST;
+ break;
+#endif
case BT_STATUS_UNHANDLED:
case BT_STATUS_FAIL:
case BT_STATUS_NOMEM:
BT_STATUS_UNHANDLED,
BT_STATUS_AUTH_FAILURE,
BT_STATUS_RMT_DEV_DOWN,
- BT_STATUS_AUTH_REJECTED
-
+#ifndef TIZEN_BT_HAL
+ BT_STATUS_CONN_TOUT /* disconnection due to supervision timeout */
+#else
+ BT_STATUS_CONN_TOUT, /* disconnection due to supervision timeout */
+ BT_STATUS_AUTH_REJECTED,
+ BT_STATUS_CONN_TERM_LOCAL_HOST,
+ BT_STATUS_CONN_TERM_RMT_HOST
+#endif
} bt_status_t;
/** Bluetooth PinKey Code */
OAL_STATUS_PENDING,
OAL_STATUS_CONN_TIMEOUT,
/* HID */
- OAL_STATUS_HID_FAILED_MOUSE
+ OAL_STATUS_HID_FAILED_MOUSE,
+#ifndef TIZEN_BT_HAL
+ OAL_STATUS_LINK_LOSS
+#else
+ OAL_STATUS_LINK_LOSS,
+ OAL_STATUS_CONN_TERM_LOCAL_HOST,
+ OAL_STATUS_CONN_TERM_RMT_HOST
+#endif
} oal_status_t;
memcpy(conn_status->address.addr, bd_addr->address, 6);
+#ifdef TIZEN_BT_HAL
+ conn_status->status = convert_to_oal_status(status);
+#else
if (BT_STATUS_SUCCESS != status) {
/* At present only timeout will cause non-success status, later we can add more */
conn_status->status = OAL_STATUS_CONN_TIMEOUT;
conn_status->status = OAL_STATUS_SUCCESS;
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);
+
switch (state) {
case BT_ACL_STATE_CONNECTED:
event = OAL_EVENT_DEVICE_ACL_CONNECTED;
BT_DBG("LE conn status:%d, state: %d", status, state);
memcpy(conn_status->address.addr, bd_addr->address, 6);
- if (BT_STATUS_SUCCESS != status)
- /* At present only timeout will cause non-success status, later we can add more */
- conn_status->status = OAL_STATUS_CONN_TIMEOUT;
- else
- conn_status->status = OAL_STATUS_SUCCESS;
+ conn_status->status = convert_to_oal_status(status);
switch (state) {
case BT_LE_CONN_STATE_CONNECTED:
static void __bt_device_handle_bond_removal_event(bt_address_t *bd_addr);
static void __bt_device_handle_bond_failed_event(event_dev_bond_failed_t* bond_fail_event);
static void __bt_handle_ongoing_bond(bt_remote_dev_info_t *remote_dev_info, gboolean incoming_bond);
-static void __bt_device_conn_state_changed_callback(event_dev_conn_status_t *acl_event,
+static void __bt_device_acl_state_changed_callback(event_dev_conn_status_t *acl_event,
gboolean connected, unsigned char type);
static void __bt_free_pairing_info(bt_pairing_data_t **p_info);
case OAL_EVENT_DEVICE_ACL_CONNECTED: {
BT_INFO("ACL Connected event Received");
event_dev_conn_status_t* param = event_data;
- __bt_device_conn_state_changed_callback(param, TRUE, 0);
+ __bt_device_acl_state_changed_callback(param, TRUE, 0);
break;
}
case OAL_EVENT_DEVICE_ACL_DISCONNECTED: {
BT_INFO("ACL Disconnected event Received");
- __bt_device_conn_state_changed_callback((event_dev_conn_status_t *)event_data, FALSE, 0);
+ __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_conn_state_changed_callback(param, TRUE, 1);
+ __bt_device_acl_state_changed_callback(param, TRUE, 1);
break;
}
case OAL_EVENT_DEVICE_LE_DISCONNECTED: {
BT_INFO("LE Disconnected event Received");
- __bt_device_conn_state_changed_callback((event_dev_conn_status_t *)event_data, FALSE, 1);
+ __bt_device_acl_state_changed_callback((event_dev_conn_status_t *)event_data, FALSE, 1);
break;
}
case OAL_EVENT_DEVICE_PIN_REQUEST: {
BT_DBG("-");
}
-static void __bt_device_conn_state_changed_callback(event_dev_conn_status_t *acl_event,
+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];
_bt_logging_connection(connected, type);
+ result = __bt_oal_status_to_bt_error(acl_event->status);
+ BT_INFO("Result [0x%x]", result);
+
if (connected) {
param = g_variant_new("(isy)", result, address, type);
_bt_send_event(BT_DEVICE_EVENT,