core/advertising: Parse SolicitUUIDs

Parse the SolicitUUIDs property of the LEAdvertisement1 object.
This commit is contained in:
Michael Janssen 2015-04-03 15:02:04 -07:00 committed by Luiz Augusto von Dentz
parent 815d35416c
commit 9b0922dea7

View File

@ -205,6 +205,45 @@ fail:
return false;
}
static bool parse_advertising_solicit_uuids(GDBusProxy *proxy,
struct bt_ad *data)
{
DBusMessageIter iter, ariter;
if (!g_dbus_proxy_get_property(proxy, "SolicitUUIDs", &iter))
return true;
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
return false;
dbus_message_iter_recurse(&iter, &ariter);
bt_ad_clear_solicit_uuid(data);
while (dbus_message_iter_get_arg_type(&ariter) == DBUS_TYPE_STRING) {
const char *uuid_str;
bt_uuid_t uuid;
dbus_message_iter_get_basic(&ariter, &uuid_str);
DBG("Adding SolicitUUID: %s", uuid_str);
if (bt_string_to_uuid(&uuid, uuid_str) < 0)
goto fail;
if (!bt_ad_add_solicit_uuid(data, &uuid))
goto fail;
dbus_message_iter_next(&ariter);
}
return true;
fail:
bt_ad_clear_solicit_uuid(data);
return false;
}
static void refresh_advertisement(struct advertisement *ad)
{
DBG("Refreshing advertisement: %s", ad->path);
@ -222,6 +261,11 @@ static bool parse_advertisement(struct advertisement *ad)
return false;
}
if (!parse_advertising_solicit_uuids(ad->proxy, ad->data)) {
error("Property \"SolicitUUIDs\" failed to parse");
return false;
}
/* TODO: parse the rest of the properties */
refresh_advertisement(ad);