From 8bf32adc91ecf2e2334079f429110481e0bcdb0a Mon Sep 17 00:00:00 2001 From: Anuj Jain Date: Tue, 3 Aug 2021 14:14:07 +0530 Subject: [PATCH] GATT: Parse client address in StartNotify and StopNotify DBUS APIs This patch enables client address to be reported in Notification Enable/Diable callback in Tizen CAPI. In GATT server role, client address is parsed from incoming dbus message and is passed up the stack. This patchset should be merged with the following capi and bluez's patchset in order to match API and avoid crash: bluez Change-Id: I81a0994f2299e988f8ef6428537647c899700fda capi Change-Id: Ic4868234a4fc682f9bff2c66ac1aee2683f3d6c6 Change-Id: Ib54ba54c318692b4ee0eaef9b2310c60dadeb661 Signed-off-by: Anuj Jain --- bt-oal/bluez_hal/src/bt-hal-gatt-server.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-gatt-server.c b/bt-oal/bluez_hal/src/bt-hal-gatt-server.c index 376fbe6..dfc766a 100644 --- a/bt-oal/bluez_hal/src/bt-hal-gatt-server.c +++ b/bt-oal/bluez_hal/src/bt-hal-gatt-server.c @@ -282,8 +282,10 @@ static const gchar characteristics_introspection_xml[] = " " " " " " +" " " " " " +" " " " " " " " @@ -1401,22 +1403,31 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection, DBG("StartNotify"); #ifdef TIZEN_BT_HAL struct gatt_service_info *svc_info = NULL; + struct gatt_client_info_t *conn_info = NULL; struct hal_ev_gatt_server_notifcation_change ev; int char_hdl = -1; + gchar *addr = NULL; + + g_variant_get(parameters, "(&s)", &addr); + INFO("Remote address %s", addr); svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl); - if (svc_info == NULL || event_cb == NULL) + + conn_info = __bt_find_remote_gatt_client_info(addr); + + if (svc_info == NULL || conn_info == NULL + || event_cb == NULL) return; /* Send HAL event */ memset(&ev, 0, sizeof(ev)); - ev.conn_id = -1; /*TODO Bluez does not provide remote GATT client address, so no conn_id */ + ev.conn_id = conn_info->connection_id; ev.trans_id = -1; /*TODO Bluez does not provide request id or transacion ID */ ev.att_handle = char_hdl; ev.notify = true; /* Convert address to hex */ - _bt_hal_convert_addr_string_to_type(ev.bdaddr, "00:00:00:00:00"); /* TODO Bluez Does not provide address of GATT client */ + _bt_hal_convert_addr_string_to_type(ev.bdaddr, addr); event_cb(HAL_EV_GATT_NOTIFICATION_CHANGE, (void *)&ev, sizeof(ev)); #endif @@ -1425,22 +1436,30 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection, DBG("StopNotify"); #ifdef TIZEN_BT_HAL struct gatt_service_info *svc_info = NULL; + struct gatt_client_info_t *conn_info = NULL; struct hal_ev_gatt_server_notifcation_change ev; int char_hdl = -1; + gchar *addr = NULL; + + g_variant_get(parameters, "(&s)", &addr); + INFO("Remote address %s", addr); + + conn_info = __bt_find_remote_gatt_client_info(addr); svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl); - if (svc_info == NULL || event_cb == NULL) + if (svc_info == NULL || conn_info == NULL + || event_cb == NULL) return; /* Send HAL event */ memset(&ev, 0, sizeof(ev)); - ev.conn_id = -1; /*TODO Bluez does not provide remote GATT client address, so no conn_id */ + ev.conn_id = conn_info->connection_id; ev.trans_id = -1; /*TODO Bluez does not provide request id or transacion ID */ ev.att_handle = char_hdl; ev.notify = false; /* Convert address to hex */ - _bt_hal_convert_addr_string_to_type(ev.bdaddr, "00:00:00:00:00"); /* TODO Bluez DOes not provide address of GATT client */ + _bt_hal_convert_addr_string_to_type(ev.bdaddr, addr); event_cb(HAL_EV_GATT_NOTIFICATION_CHANGE, (void *)&ev, sizeof(ev)); #endif -- 2.7.4