Skip to content

Commit

Permalink
Retrieve the Service UUID from the advertising data.
Browse files Browse the repository at this point in the history
- If ServiceData cannot be retrieved, obtain only the Service UUID.
  • Loading branch information
tyano463 authored and oliviermartin committed Jul 17, 2024
1 parent fec9499 commit 1580056
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions dbus/gattlib_advertisement.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,29 @@ int get_advertisement_data_from_device(OrgBluezDevice1 *bluez_device1,

*advertisement_data = advertisement_data_ptr;
} else {
*advertisement_data_count = 0;
*advertisement_data = NULL;
const gchar* const* service_strs = org_bluez_device1_get_uuids(bluez_device1);
if (service_strs && (*service_strs)) {
uuid_t uuid;
int ret, len = strlen((char *)*service_strs);
if (!len) goto error_return;

ret = gattlib_string_to_uuid((char *)*service_strs, len, &uuid);
if (ret) goto error_return;

*advertisement_data = calloc(sizeof(gattlib_advertisement_data_t), 1);
if (!(*advertisement_data)) {
*advertisement_data_count = 0;
return GATTLIB_OUT_OF_MEMORY;
}
*advertisement_data_count = 1;
memcpy(&(*advertisement_data)[0].uuid, &uuid, sizeof(uuid));
}
else
{
error_return:
*advertisement_data_count = 0;
*advertisement_data = NULL;
}
}

return GATTLIB_SUCCESS;
Expand Down

0 comments on commit 1580056

Please sign in to comment.