From 47c8e3c411e5599b8fff175a3b8f6dced5ae6cfe Mon Sep 17 00:00:00 2001 From: "injun.yang" Date: Tue, 17 Oct 2017 15:34:36 +0900 Subject: [PATCH] Enhance debug message When service added from remote device, get uuid information and display it Change-Id: Id8188ae2d0695ef023fc45d33c1f22382f384bf7 --- bt-api/bt-event-handler.c | 57 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index b2ad54a..243911b 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -3526,6 +3526,46 @@ void _bt_unregister_name_owner_changed(void) } } +static void __bt_gatt_get_uuid_from_path(char *path, char **service_uuid) +{ + GDBusProxy *proxy = NULL; + GError *err = NULL; + GDBusConnection *g_conn; + GVariant *ret = NULL; + GVariant *value = NULL; + + g_conn = _bt_gdbus_get_system_gconn(); + ret_if(g_conn == NULL); + + proxy = g_dbus_proxy_new_sync(g_conn, + G_DBUS_PROXY_FLAGS_NONE, NULL, + BT_BLUEZ_NAME, + path, + BT_PROPERTIES_INTERFACE, + NULL, &err); + + ret_if(proxy == NULL); + + ret = g_dbus_proxy_call_sync(proxy, "Get", + g_variant_new("(ss)", GATT_SERV_INTERFACE, "UUID"), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err); + if (err) { + BT_ERR("DBus Error : %s", err->message); + g_clear_error(&err); + } else { + g_variant_get(ret, "(v)", &value); + *service_uuid = g_variant_dup_string(value, NULL); + g_variant_unref(value); + g_variant_unref(ret); + } + + if (proxy) + g_object_unref(proxy); + + return; +} + + static void __bt_manager_event_filter(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, @@ -3559,9 +3599,17 @@ static void __bt_manager_event_filter(GDBusConnection *connection, BT_INFO("GATT Service [%s] added, but no watcher for %s", path, secure_address); return; - } else + } else { + char *uuid = NULL; + char *name = NULL; + __bt_gatt_get_uuid_from_path(path, &uuid); + bluetooth_get_uuid_name(uuid, &name); + BT_INFO(" ### GATT Service added [%s] [%s]", - path, secure_address); + path, name); + g_free(name); + g_free(uuid); + } change.svc_path = g_strdup(path); change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD; @@ -3587,10 +3635,7 @@ static void __bt_manager_event_filter(GDBusConnection *connection, if (g_strcmp0(interface_str, GATT_SERV_INTERFACE) != 0) continue; - _bt_convert_addr_type_to_secure_string(secure_address, - change.device_addr.addr); - BT_INFO(" ### GATT Service removed [%s] [%s]", - path, secure_address); + BT_INFO(" ### GATT Service removed [%s]", path); change.svc_path = g_strdup(path); change.change_type = BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE; -- 2.7.4