Handle ACL Disconnect Reason
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-event-receiver.c
index 0f69377..719681c 100644 (file)
@@ -95,7 +95,7 @@ static void __bt_hal_device_property_changed_event(GVariant *msg, const char *pa
 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);
@@ -1802,12 +1802,12 @@ static void __bt_hal_device_properties_lookup(GVariant *result, 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;
@@ -1821,12 +1821,12 @@ static void __bt_hal_send_device_acl_connection_state_event(gboolean connected,
        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;
@@ -1934,9 +1934,9 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
                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;
@@ -1949,13 +1949,14 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me
                _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;