From: Anuj Jain Date: Wed, 27 Mar 2024 10:29:34 +0000 (+0530) Subject: Handle connection failed event during le coc connection request X-Git-Tag: accepted/tizen/7.0/unified/20240330.125447~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=679a5c5d380df3e56a6bff53e629d8a136832faa;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Handle connection failed event during le coc connection request This patch ensures connection fail event passed to application in case of connection connection failure during connect request. This patch should be merged after bluez patch (Change-Id: Id4cf266603e64eab8685325f218b1180c9c5b125) to avoid any conflicts. Change-Id: I6a2a043e0d2077b45a1da316c193a2a53b4bbae1 Signed-off-by: Anuj Jain --- 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 5f9c2ad..4baa020 100644 --- a/bt-oal/bluez_hal/src/bt-hal-event-receiver.c +++ b/bt-oal/bluez_hal/src/bt-hal-event-receiver.c @@ -40,6 +40,7 @@ #include "bt-hal-gatt-server.h" #include "bt-hal-gatt-client.h" #include "bt-hal-adapter-dbus-handler.h" +#include "bt-hal-l2cap-le-dbus-handler.h" #include "bt-hal-tds.h" #include "bt-internal-types.h" @@ -2056,6 +2057,27 @@ static void __bt_hal_handle_device_specific_events(GVariant *msg, const char *me else __bt_hal_send_device_le_connection_state_event(BT_STATUS_SUCCESS, TRUE, address); g_free(address); + } else if (strcasecmp(member, "ConnectionFail") == 0) { + DBG("Received Connection failed error"); + DBG("path : %s", path); + l2cap_le_cb_data_t *info; + l2cap_le_conn_info_t *conn_info; + char *info_path; + int res = -1; + g_variant_get(msg, "(s)", &info_path); + + if (NULL != info_path) { + info = __find_l2cap_le_client_info_from_path(info_path); + if (info != NULL) { + conn_info = info->conn_info; + if (write(conn_info->hal_fd, &res, sizeof(res)) != sizeof(res)) { + ERR("Error Sending l2cap_le connection result"); + } + __l2cap_le_cb_data_remove(info); + } else + ERR("info is NULL"); + } else + ERR("info_path is NULL"); } else if (strcasecmp(member, "Disconnected") == 0) { unsigned char disc_reason = 0; unsigned char addr_type = 0; diff --git a/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.c index 374aa67..2a6baba 100644 --- a/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.c @@ -39,23 +39,6 @@ #define L2CAP_LE_UUID_SUBSTR "FFFFFFFF-FFFF-FFFF-FFFF-" typedef struct { - char remote_addr[BT_HAL_ADDRESS_STRING_SIZE]; - int hal_fd; - unsigned int hal_watch; - int stack_fd; - unsigned int bt_watch; -} l2cap_le_conn_info_t; - -typedef struct { - int psm; - char *device_path; - char *obj_path; - int object_id; - int id; - l2cap_le_conn_info_t *conn_info; -} l2cap_le_cb_data_t; - -typedef struct { int psm; char *obj_path; int object_id; @@ -113,7 +96,7 @@ static void __l2cap_le_delete_id(int id) } /*************************** L2CAP_LE Client Implementation ***************************/ -static l2cap_le_cb_data_t *__find_l2cap_le_client_info_from_path(const char *path) +l2cap_le_cb_data_t *__find_l2cap_le_client_info_from_path(const char *path) { GSList *l; @@ -174,7 +157,7 @@ static void __bt_free_cb_data(l2cap_le_cb_data_t *cb_data) DBG("-"); } -static void __l2cap_le_cb_data_remove(l2cap_le_cb_data_t *info) +void __l2cap_le_cb_data_remove(l2cap_le_cb_data_t *info) { if (!info) { ERR("info is NULL"); diff --git a/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.h b/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.h index 419cbe2..6714df9 100644 --- a/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.h +++ b/bt-oal/bluez_hal/src/bt-hal-l2cap-le-dbus-handler.h @@ -31,12 +31,33 @@ extern "C" { #endif +typedef struct { + char remote_addr[18]; + int hal_fd; + unsigned int hal_watch; + int stack_fd; + unsigned int bt_watch; +} l2cap_le_conn_info_t; + +typedef struct { + int psm; + char *device_path; + char *obj_path; + int object_id; + int id; + l2cap_le_conn_info_t *conn_info; +} l2cap_le_cb_data_t; + int _bt_hal_dbus_handler_l2cap_le_connect( unsigned char *addr, int psm, int *sock); int _bt_hal_dbus_handler_l2cap_le_listen( int psm, int *sock); +l2cap_le_cb_data_t *__find_l2cap_le_client_info_from_path(const char *path); + +void __l2cap_le_cb_data_remove(l2cap_le_cb_data_t *info); + gboolean _is_l2cap_le_server_uuid(const char *uuid); #ifdef __cplusplus