From bf678926efe92b7609d8748853c1f355ec174c58 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Sun, 14 Dec 2014 19:52:09 +0100 Subject: [PATCH] android/gatt: Fix incorrect UUID conversion Android framework requires 128 bit UUIDs to be passed to it. It was expected that bt_string_to_uuid() creates 128bit UUID if passed string was in 128bit format. Since e5af5138 "lib/uuid: Simplify BT base UUIDs when possible" this is no longer valid. Resulting UUID was shortened and Android Framework didn't recognized it. This results in non-working HoG and possibly other GATT profiles. Fix this by explicitly converting UUID to 128bit before accessing u128 data. --- android/gatt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/android/gatt.c b/android/gatt.c index 37bd6dea7..71112a259 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -1340,7 +1340,7 @@ static void discover_primary_cb(uint8_t status, GSList *services, for (l = services; l; l = l->next) { struct gatt_primary *prim = l->data; uint8_t *new_uuid; - bt_uuid_t uuid; + bt_uuid_t uuid, u128; DBG("uuid: %s", prim->uuid); @@ -1349,7 +1349,8 @@ static void discover_primary_cb(uint8_t status, GSList *services, continue; } - new_uuid = g_memdup(&uuid.value.u128, sizeof(uuid.value.u128)); + bt_uuid_to_uuid128(&uuid, &u128); + new_uuid = g_memdup(&u128.value.u128, sizeof(u128.value.u128)); uuids = g_slist_prepend(uuids, new_uuid); } @@ -7199,10 +7200,11 @@ unsigned int bt_gatt_register_app(const char *uuid, gatt_type_t type, gatt_conn_cb_t func) { struct gatt_app *app; - bt_uuid_t uuid128; + bt_uuid_t u, u128; - bt_string_to_uuid(&uuid128, uuid); - app = register_app((void *) &uuid128.value.u128, type); + bt_string_to_uuid(&u, uuid); + bt_uuid_to_uuid128(&u, &u128); + app = register_app((void *) &u128.value.u128, type); if (!app) return 0; -- 2.47.3