From: Anuj Jain Date: Tue, 3 Aug 2021 08:46:59 +0000 (+0530) Subject: GATT: Send client address to HAL layer on Notification state change X-Git-Tag: accepted/tizen/6.5/unified/20211028.224421^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F262169%2F4;p=platform%2Fupstream%2Fbluez.git GATT: Send client address to HAL layer on Notification state change In gatt Server role Client address is added to dbus method calls corresponding to StartNotify and StopNotify methods at BLUEZ layer. This patchset should be merged with the following capi and bluetooth-frwk's patchset in order to match API and avoid crash: bluetooth-frwk Change-Id: Ib54ba54c318692b4ee0eaef9b2310c60dadeb661 capi Change-Id: Ic4868234a4fc682f9bff2c66ac1aee2683f3d6c6 Change-Id: I81a0994f2299e988f8ef6428537647c899700fda Signed-off-by: Anuj Jain --- diff --git a/src/gatt-database.c b/src/gatt-database.c index a6b9dbc..6e65929 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -3043,6 +3043,23 @@ static struct pending_op *acquire_write(struct external_chrc *chrc, return NULL; } +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY +static void start_notify_setup(DBusMessageIter *iter, void *user_data) +{ + struct pending_op *op = user_data; + struct btd_device *device = op->device; + char dst_addr[18] = { 0 }; + char *addr_value = dst_addr; + + if (device_get_rpa_exist(device) == true) + ba2str(device_get_rpa(device), dst_addr); + else + ba2str(device_get_address(device), dst_addr); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_value); +} +#endif + static void acquire_notify_reply(DBusMessage *message, void *user_data) { struct pending_op *op = user_data; @@ -3088,9 +3105,13 @@ static void acquire_notify_reply(DBusMessage *message, void *user_data) return; retry: +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + g_dbus_proxy_method_call(chrc->proxy, "StartNotify", + start_notify_setup, NULL, op, NULL); +#else g_dbus_proxy_method_call(chrc->proxy, "StartNotify", NULL, NULL, NULL, NULL); - +#endif __sync_fetch_and_add(&chrc->ntfy_cnt, 1); } @@ -3111,6 +3132,23 @@ static void acquire_notify_setup(DBusMessageIter *iter, void *user_data) dbus_message_iter_close_container(iter, &dict); } +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY +static void stop_notify_setup(DBusMessageIter *iter, void *user_data) +{ + struct pending_op *op = user_data; + struct btd_device *device = op->device; + char dst_addr[18] = { 0 }; + char *addr_value = dst_addr; + + if (device_get_rpa_exist(device) == true) + ba2str(device_get_rpa(device), dst_addr); + else + ba2str(device_get_address(device), dst_addr); + + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &addr_value); +} +#endif + static uint8_t ccc_write_cb(struct pending_op *op, void *user_data) { struct external_chrc *chrc = user_data; @@ -3143,8 +3181,13 @@ static uint8_t ccc_write_cb(struct pending_op *op, void *user_data) * Send request to stop notifying. This is best-effort * operation, so simply ignore the return the value. */ +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + g_dbus_proxy_method_call(chrc->proxy, "StopNotify", + stop_notify_setup, NULL, op, NULL); +#else g_dbus_proxy_method_call(chrc->proxy, "StopNotify", NULL, NULL, NULL, NULL); +#endif goto done; } @@ -3179,8 +3222,13 @@ static uint8_t ccc_write_cb(struct pending_op *op, void *user_data) * Always call StartNotify for an incoming enable and ignore the return * value for now. */ +#ifdef TIZEN_FEATURE_BLUEZ_MODIFY + if (g_dbus_proxy_method_call(chrc->proxy, "StartNotify", start_notify_setup, NULL, + op, NULL) == FALSE) +#else if (g_dbus_proxy_method_call(chrc->proxy, "StartNotify", NULL, NULL, NULL, NULL) == FALSE) +#endif return BT_ATT_ERROR_UNLIKELY; __sync_fetch_and_add(&chrc->ntfy_cnt, 1);