Re: [PATCH v2 1/5] advertising: Add SupportedFeatures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Luiz,

> This adds SupportedFeatures so application can detect what features
> are supported by the system.
> ---
> doc/advertising-api.txt |  8 ++++++++
> src/advertising.c       | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 50 insertions(+)
> 
> diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt
> index 7a29b7095..78c1c04e3 100644
> --- a/doc/advertising-api.txt
> +++ b/doc/advertising-api.txt
> @@ -116,3 +116,11 @@ Methods		RegisterAdvertisement(object advertisement, dict options)
> Properties	byte AdvertisementInstaces
> 
> 			Number of available advertisement instances.
> +
> +		array{string} SupportedFeatures
> +
> +			List of supported features.
> +
> +			Possible values: "Tx Power"
> +					 "Appearance"
> +					 "Local Name”

we never did this. They should be lowercase and no spaces. So tx-power, appearance, local-name etc.

> diff --git a/src/advertising.c b/src/advertising.c
> index c2af3acb4..195ed9fc1 100644
> --- a/src/advertising.c
> +++ b/src/advertising.c
> @@ -48,6 +48,7 @@ struct btd_adv_manager {
> 	uint16_t mgmt_index;
> 	uint8_t max_adv_len;
> 	uint8_t max_ads;
> +	uint32_t supported_flags;
> 	unsigned int instance_bitmap;
> };
> 
> @@ -738,8 +739,48 @@ static gboolean get_instances(const GDBusPropertyTable *property,
> 	return TRUE;
> }
> 
> +static struct adv_feat {
> +	uint8_t flag;
> +	const char *name;
> +} feats[] = {
> +	{ MGMT_ADV_FLAG_TX_POWER, "Tx Power" },
> +	{ MGMT_ADV_FLAG_APPEARANCE, "Appearance" },
> +	{ MGMT_ADV_FLAG_LOCAL_NAME, "Local Name" },
> +	{ },
> +};
> +
> +static void append_features(struct btd_adv_manager *manager,
> +						DBusMessageIter *iter)
> +{
> +	struct adv_feat *feat;
> +
> +	for (feat = feats; feat && feat->name; feat++) {
> +		if (manager->supported_flags & feat->flag)
> +			dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
> +								&feat->name);
> +	}
> +}
> +
> +static gboolean get_supported_features(const GDBusPropertyTable *property,
> +					DBusMessageIter *iter, void *data)
> +{
> +	struct btd_adv_manager *manager = data;
> +	DBusMessageIter entry;
> +
> +	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
> +					DBUS_TYPE_STRING_AS_STRING, &entry);
> +
> +	append_features(manager, &entry);
> +
> +	dbus_message_iter_close_container(iter, &entry);
> +
> +	return TRUE;
> +}
> +
> static const GDBusPropertyTable properties[] = {
> 	{ "AdvertisementInstances", "y", get_instances },

Wouldn’t this be AdvertisingInstances?

> +	{ "SupportedFeatures", "as", get_supported_features },
> +	{ }
> };
> 
> static const GDBusMethodTable methods[] = {
> @@ -784,6 +825,7 @@ static void read_adv_features_callback(uint8_t status, uint16_t length,
> 
> 	manager->max_adv_len = feat->max_adv_data_len;
> 	manager->max_ads = feat->max_instances;
> +	manager->supported_flags = feat->supported_flags;

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux