advertising: Add SupportedFeatures
Luiz Augusto von Dentz
maintainerPATCH v2 1/5 advertising: Add SupportedFeatures
From: Luiz Augusto von Dentz <[email protected]>
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(+)
doc/advertising-api.txt +8 -0
@@ -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"
src/advertising.c +42 -0
62 lines not on this page · raw message
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH v2 2/5 advertising: Add IncludeName property
From: Luiz Augusto von Dentz <[email protected]>
This adds support to include adapter name, or alias, in the scan response with use of IncludeName property.
--- doc/advertising-api.txt | 5 +++++ src/advertising.c | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)
doc/advertising-api.txt +5 -0
@@ -66,6 +66,11 @@ Properties string Type Includes the Tx Power in the advertising packet. If missing, the Tx Power is not included. + bool IncludeName + + Include adapter Name, or Alias if set, as scan + response data. + LE Advertising Manager hierarchy ================================
src/advertising.c +27 -0
@@ -64,6 +64,7 @@ struct btd_adv_client {DBusMessage *reg;uint8_t type;/* Advertising type */ bool include_tx_power; +bool include_name;struct bt_ad *data;uint8_t instance; };
@@ -412,6 +413,24 @@ static bool parse_include_tx_power(GDBusProxy *proxy, bool *included)return true; } +static bool parse_include_name (GDBusProxy *proxy,bool *included) +{ +DBusMessageIter iter; +dbus_bool_t b; + +if (!g_dbus_proxy_get_property (proxy,"IncludeName" , &iter)) +return true; + +if (dbus_message_iter_get_arg_type (&iter) !=DBUS_TYPE_BOOLEAN ) +return false; + +dbus_message_iter_get_basic (&iter, &b); + + *included = b; + +return true; +} +static void add_client_complete (struct btd_adv_client *client,uint8_t status) {DBusMessage *reply;
@@ -498,6 +517,9 @@ static DBusMessage *refresh_advertisement(struct btd_adv_client *client)if (client->include_tx_power) flags |=MGMT_ADV_FLAG_TX_POWER ; +if (client->include_name) + flags |=MGMT_ADV_FLAG_LOCAL_NAME ; + adv_data =bt_ad_generate (client->data, &adv_data_len);if (!adv_data || (adv_data_len >calc_max_adv_len (client, flags))) {
@@ -574,6 +596,11 @@ static DBusMessage *parse_advertisement(struct btd_adv_client *client) goto fail; } +if (!parse_include_name (client->proxy, &client->include_name)) { +error ("Property \"IncludeName\" failed to parse" ); + goto fail; + } +return refresh_advertisement (client); fail:
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH v2 3/5 client: Add set-advertise-name command
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds set-advertise-name which enables the use of adapter name/alias in the scan response:
[bluetooth]# set-advertise-name on
[bluetooth]# advertise on
@ MGMT Command: Add Advertising (0x003e) plen 11
Instance: 1
Flags: 0x00000043
Switch into Connectable mode
Advertise as Discoverable
Add Local Name in Scan Response
Duration: 0
Timeout: 0
Advertising data length: 0
Scan response length: 0
--- client/advertising.c | 21 +++++++++++++++++++++ client/advertising.h | 1 + client/main.c | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+)
client/advertising.c +21 -0
@@ -49,6 +49,7 @@ static uint16_t ad_manufacturer_id;static uint8_t ad_manufacturer_data[25 ];static uint8_t ad_manufacturer_data_len =0 ;static gboolean ad_tx_power = FALSE; +static gboolean ad_name = FALSE;static void ad_release (DBusConnection *conn) {
@@ -252,6 +253,20 @@ static gboolean get_tx_power(const GDBusPropertyTable *property,return TRUE; } +static gboolean include_name_exists (const GDBusPropertyTable *property, +void *data) +{ +return ad_name; +} + +static gboolean get_include_name (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *user_data) +{ +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &ad_name); + +return TRUE; +} +static const GDBusPropertyTable ad_props[] = { {"Type" ,"s" , get_type }, {"ServiceUUIDs" ,"as" , get_uuids,NULL , uuids_exists },
@@ -259,6 +274,7 @@ static const GDBusPropertyTable ad_props[] = { {"ManufacturerData" ,"a{qv}" , get_manufacturer_data,NULL , manufacturer_data_exists }, { "IncludeTxPower", "b", get_tx_power, NULL, tx_power_exists }, + { "IncludeName", "b", get_include_name, NULL, include_name_exists }, { } };
@@ -453,3 +469,8 @@ void ad_advertise_tx_power(gboolean value) { ad_tx_power = value; } + +void ad_advertise_name (gboolean value) +{ + ad_name = value; +}
client/advertising.h +1 -0
@@ -28,3 +28,4 @@ void ad_advertise_uuids(const char *arg);void ad_advertise_service (const char *arg);void ad_advertise_manufacturer (const char *arg);void ad_advertise_tx_power (gboolean value); +void ad_advertise_name (gboolean value);
client/main.c +22 -0
@@ -2362,6 +2362,26 @@ static void cmd_set_advertise_tx_power(const char *arg)rl_printf ("Invalid argument\n" ); } +static void cmd_set_advertise_name (const char *arg) +{ +if (arg ==NULL ||strlen (arg) ==0 ) { +rl_printf ("Missing on/off argument\n" ); +return ; + } + +if (strcmp (arg,"on" ) ==0 ||strcmp (arg,"yes" ) ==0 ) { +ad_advertise_name (TRUE); +return ; + } + +if (strcmp (arg,"off" ) ==0 ||strcmp (arg,"no" ) ==0 ) { +ad_advertise_name (FALSE); +return ; + } + +rl_printf ("Invalid argument\n" ); +} + static const struct { const char *cmd; const char *arg;
@@ -2406,6 +2426,8 @@ static const struct { {"set-advertise-tx-power" ,"<on/off>" , cmd_set_advertise_tx_power, "Enable/disable TX power to be advertised" }, + { "set-advertise-name", "<on/off>", cmd_set_advertise_name, + "Enable/disable local name to be advertised" }, { "set-scan-filter-uuids", "[uuid1 uuid2 ...]", cmd_set_scan_filter_uuids, "Set scan filter uuids" }, { "set-scan-filter-rssi", "[rssi]", cmd_set_scan_filter_rssi,
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH v2 4/5 advertising: Add IncludeAppearance property
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds support to include appearance in the advertisement data with use of IncludeAppearance property.
--- doc/advertising-api.txt | 6 ++ src/advertising.c | 189 ++++++++++++++++++++++++------------------------ 2 files changed, 100 insertions(+), 95 deletions(-)
doc/advertising-api.txt +6 -0
@@ -66,6 +66,12 @@ Properties string Type Includes the Tx Power in the advertising packet. If missing, the Tx Power is not included. + uint16 IncludeAppearance + + Includes Appearance in the advertising packet. + + Possible values: as found on Device.Appearance + bool IncludeName Include adapter Name, or Alias if set, as scan
src/advertising.c +94 -95
334 lines not on this page · raw message
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH v2 5/5 client: Add set-advertise-name command
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This adds set-advertise-name which enables the use of adapter name/alias in the scan response:
[bluetooth]# set-advertise-appearance on
[bluetooth]# advertise on
@ MGMT Command: Add Advertising (0x003e) plen 11
Instance: 1
Flags: 0x00000023
Switch into Connectable mode
Advertise as Discoverable
Add Appearance field to Scan Response
Duration: 0
Timeout: 0
Advertising data length: 0
Scan response length: 0
--- client/advertising.c | 163 ++++++++++++++++++++++++++++++++------------------- client/advertising.h | 5 +- client/main.c | 30 ++++++++-- 3 files changed, 131 insertions(+), 67 deletions(-)
client/advertising.c +102 -61
@@ -28,6 +28,7 @@#include <stdio.h> #include <stdlib.h> #include <stdint.h> +#include <stdbool.h> #include <readline/readline.h> #include <wordexp.h>
@@ -38,22 +39,36 @@#define AD_PATH "/org/bluez/advertising"#define AD_IFACE "org.bluez.LEAdvertisement1" -static gboolean registered = FALSE; -static char *ad_type =NULL ; -static char **ad_uuids =NULL ; -static size_t ad_uuids_len =0 ; -static char *ad_service_uuid =NULL ; -static uint8_t ad_service_data[25 ]; -static uint8_t ad_service_data_len =0 ; -static uint16_t ad_manufacturer_id; -static uint8_t ad_manufacturer_data[25 ]; -static uint8_t ad_manufacturer_data_len =0 ; -static gboolean ad_tx_power = FALSE; -static gboolean ad_name = FALSE; +struct ad_data { +uint8_t data[25 ]; +uint8_t len; +}; + +struct service_data { +char *uuid; +struct ad_data data; +}; + +struct manufacturer_data { +uint16_t id; +struct ad_data data; +}; + +static struct ad { +bool registered; +char *type; +char **uuids; +size_t uuids_len; +struct service_data service; +struct manufacturer_data manufacturer; +bool tx_power; +bool name; +bool appearance; +} ad;static void ad_release (DBusConnection *conn) { - registered = FALSE; + ad.registered = false;g_dbus_unregister_interface (conn,AD_PATH ,AD_IFACE ); }
@@ -95,7 +110,7 @@ static void register_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == FALSE) { - registered = TRUE; + ad.registered = true;rl_printf ("Advertising object registered\n" ); }else {rl_printf ("Failed to register advertisement: %s\n" , error.name);
@@ -112,8 +127,8 @@ static gboolean get_type(const GDBusPropertyTable *property, {const char *type ="peripheral" ; -if (!ad_type ||strlen (ad_type) >0 ) - type = ad_type; +if (!ad.type ||strlen (ad.type) >0 ) + type = ad.type;dbus_message_iter_append_basic (iter,DBUS_TYPE_STRING , &type);
@@ -122,7 +137,7 @@ static gboolean get_type(const GDBusPropertyTable *property,static gboolean uuids_exists (const GDBusPropertyTable *property,void *data) { -return ad_uuids_len !=0 ; +return ad.uuids_len !=0 ; } static gboolean get_uuids(const GDBusPropertyTable *property,
@@ -133,9 +148,9 @@ static gboolean get_uuids(const GDBusPropertyTable *property,dbus_message_iter_open_container (iter,DBUS_TYPE_ARRAY ,"as" , &array); -for (i =0 ; i < ad_uuids_len; i++) +for (i =0 ; i < ad.uuids_len; i++)dbus_message_iter_append_basic (&array,DBUS_TYPE_STRING , - &ad_uuids[i]); + &ad.uuids[i]);dbus_message_iter_close_container (iter, &array);
@@ -198,19 +213,19 @@ static void dict_append_array(DBusMessageIter *dict, const char *key, int type,static gboolean service_data_exists (const GDBusPropertyTable *property,void *data) { -return ad_service_uuid !=NULL ; +return ad.service.uuid !=NULL ; }static gboolean get_service_data (const GDBusPropertyTable *property,DBusMessageIter *iter,void *user_data) {DBusMessageIter dict; -const uint8_t *data = ad_service_data; +struct ad_data *data = &ad.service.data;dbus_message_iter_open_container (iter,DBUS_TYPE_ARRAY ,"{sv}" , &dict); -dict_append_array (&dict, ad_service_uuid,DBUS_TYPE_BYTE , &data, - ad_service_data_len); +dict_append_array (&dict, ad.service.uuid,DBUS_TYPE_BYTE , &data->data, + data->len);dbus_message_iter_close_container (iter, &dict);
@@ -220,20 +235,19 @@ static gboolean get_service_data(const GDBusPropertyTable *property,static gboolean manufacturer_data_exists (const GDBusPropertyTable *property,void *data) { -return ad_manufacturer_id !=0 ; +return ad.manufacturer.id !=0 ; }static gboolean get_manufacturer_data (const GDBusPropertyTable *property,DBusMessageIter *iter,void *user_data) {DBusMessageIter dict; -const uint8_t *data = ad_manufacturer_data; +struct ad_data *data = &ad.manufacturer.data;dbus_message_iter_open_container (iter,DBUS_TYPE_ARRAY ,"{qv}" , &dict); -dict_append_basic_array (&dict,DBUS_TYPE_UINT16 , &ad_manufacturer_id, -DBUS_TYPE_BYTE , &data, - ad_manufacturer_data_len); +dict_append_basic_array (&dict,DBUS_TYPE_UINT16 , &ad.manufacturer.id, +DBUS_TYPE_BYTE , &data->data, data->len);dbus_message_iter_close_container (iter, &dict);
@@ -242,13 +256,15 @@ static gboolean get_manufacturer_data(const GDBusPropertyTable *property,static gboolean tx_power_exists (const GDBusPropertyTable *property,void *data) { -return ad_tx_power; +return ad.tx_power; }static gboolean get_tx_power (const GDBusPropertyTable *property,DBusMessageIter *iter,void *user_data) { -dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &ad_tx_power); +dbus_bool_t b = ad.tx_power; + +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &b);return TRUE; }
@@ -256,13 +272,31 @@ static gboolean get_tx_power(const GDBusPropertyTable *property,static gboolean include_name_exists (const GDBusPropertyTable *property,void *data) { -return ad_name; +return ad.name; }static gboolean get_include_name (const GDBusPropertyTable *property,DBusMessageIter *iter,void *user_data) { -dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &ad_name); +dbus_bool_t b = ad.name; + +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &b); + +return TRUE; +} + +static gboolean include_appearance_exists (const GDBusPropertyTable *property, +void *data) +{ +return ad.appearance; +} + +static gboolean get_include_appearance (const GDBusPropertyTable *property, +DBusMessageIter *iter,void *user_data) +{ +dbus_bool_t b = ad.appearance; + +dbus_message_iter_append_basic (iter,DBUS_TYPE_BOOLEAN , &b);return TRUE; }
@@ -275,17 +309,19 @@ static const GDBusPropertyTable ad_props[] = { manufacturer_data_exists }, { "IncludeTxPower", "b", get_tx_power, NULL, tx_power_exists }, { "IncludeName", "b", get_include_name, NULL, include_name_exists }, + { "IncludeAppearance", "b", get_include_appearance, NULL, + include_appearance_exists }, { } };void ad_register (DBusConnection *conn,GDBusProxy *manager,const char *type) { -if (registered == TRUE) { +if (ad.registered) {rl_printf ("Advertisement is already registered\n" );return ; } - ad_type =g_strdup (type); + ad.type =g_strdup (type);if (g_dbus_register_interface (conn,AD_PATH ,AD_IFACE , ad_methods,NULL , ad_props,NULL ,NULL ) == FALSE) {
@@ -316,7 +352,7 @@ static void unregister_reply(DBusMessage *message, void *user_data)dbus_error_init (&error);if (dbus_set_error_from_message (&error, message) == FALSE) { - registered = FALSE; + ad.registered = false;rl_printf ("Advertising object unregistered\n" );if (g_dbus_unregister_interface (conn,AD_PATH ,AD_IFACE ) == FALSE)
@@ -333,7 +369,7 @@ void ad_unregister(DBusConnection *conn, GDBusProxy *manager)if (!manager)ad_release (conn); -if (!registered) +if (!ad.registered)return ; if (g_dbus_proxy_method_call(manager, "UnregisterAdvertisement",
@@ -346,34 +382,33 @@ void ad_unregister(DBusConnection *conn, GDBusProxy *manager)void ad_advertise_uuids (const char *arg) { -g_strfreev (ad_uuids); - ad_uuids =NULL ; - ad_uuids_len =0 ; +g_strfreev (ad.uuids); + ad.uuids =NULL ; + ad.uuids_len =0 ;if (!arg || !strlen (arg))return ; - ad_uuids =g_strsplit (arg," " ,-1 ); -if (!ad_uuids) { + ad.uuids =g_strsplit (arg," " ,-1 ); +if (!ad.uuids) {rl_printf ("Failed to parse input\n" );return ; } - ad_uuids_len =g_strv_length (ad_uuids); + ad.uuids_len =g_strv_length (ad.uuids); }static void ad_clear_service (void ) { -g_free (ad_service_uuid); - ad_service_uuid =NULL ; -memset (ad_service_data,0 ,sizeof (ad_service_data)); - ad_service_data_len =0 ; +g_free (ad.service.uuid); +memset (&ad.service,0 ,sizeof (ad.service)); }void ad_advertise_service (const char *arg) {wordexp_t w;unsigned int i; +struct ad_data *data;if (wordexp (arg, &w,WRDE_NOCMD )) {rl_printf ("Invalid argument\n" );
@@ -385,13 +420,14 @@ void ad_advertise_service(const char *arg)if (w.we_wordc ==0 ) goto done; - ad_service_uuid =g_strdup (w.we_wordv[0 ]); + ad.service.uuid =g_strdup (w.we_wordv[0 ]); + data = &ad.service.data;for (i =1 ; i < w.we_wordc; i++) {long int val;char *endptr =NULL ; -if (i >=G_N_ELEMENTS (ad_service_data)) { +if (i >=G_N_ELEMENTS (data->data)) {rl_printf ("Too much data\n" ); goto done; }
@@ -403,8 +439,8 @@ void ad_advertise_service(const char *arg) goto done; } - ad_service_data[ad_service_data_len] = val; - ad_service_data_len++; + data->data[data->len] = val; + data->len++; } done:
@@ -413,9 +449,7 @@ done:static void ad_clear_manufacturer (void ) { - ad_manufacturer_id =0 ; -memset (ad_manufacturer_data,0 ,sizeof (ad_manufacturer_data)); - ad_manufacturer_data_len =0 ; +memset (&ad.manufacturer,0 ,sizeof (ad.manufacturer)); }void ad_advertise_manufacturer (const char *arg)
@@ -424,6 +458,7 @@ void ad_advertise_manufacturer(const char *arg)unsigned int i;char *endptr =NULL ;long int val; +struct ad_data *data;if (wordexp (arg, &w,WRDE_NOCMD )) {rl_printf ("Invalid argument\n" );
@@ -441,10 +476,11 @@ void ad_advertise_manufacturer(const char *arg) goto done; } - ad_manufacturer_id = val; + ad.manufacturer.id = val; + data = &ad.manufacturer.data;for (i =1 ; i < w.we_wordc; i++) { -if (i >=G_N_ELEMENTS (ad_service_data)) { +if (i >=G_N_ELEMENTS (data->data)) {rl_printf ("Too much data\n" ); goto done; }
@@ -456,8 +492,8 @@ void ad_advertise_manufacturer(const char *arg) goto done; } - ad_manufacturer_data[ad_manufacturer_data_len] = val; - ad_manufacturer_data_len++; + data->data[data->len] = val; + data->len++; } done:
@@ -465,12 +501,17 @@ done: } -void ad_advertise_tx_power (gboolean value) +void ad_advertise_tx_power (bool value) +{ + ad.tx_power = value; +} + +void ad_advertise_name (bool value) { - ad_tx_power = value; + ad.name = value; } -void ad_advertise_name (gboolean value) +void ad_advertise_appearance (bool value) { - ad_name = value; + ad.appearance = value; }
client/advertising.h +3 -2
@@ -27,5 +27,6 @@ void ad_unregister(DBusConnection *conn, GDBusProxy *manager);void ad_advertise_uuids (const char *arg);void ad_advertise_service (const char *arg);void ad_advertise_manufacturer (const char *arg); -void ad_advertise_tx_power (gboolean value); -void ad_advertise_name (gboolean value); +void ad_advertise_tx_power (bool value); +void ad_advertise_name (bool value); +void ad_advertise_appearance (bool value);
client/main.c +26 -4
@@ -2350,12 +2350,12 @@ static void cmd_set_advertise_tx_power(const char *arg) }if (strcmp (arg,"on" ) ==0 ||strcmp (arg,"yes" ) ==0 ) { -ad_advertise_tx_power (TRUE); +ad_advertise_tx_power (true);return ; }if (strcmp (arg,"off" ) ==0 ||strcmp (arg,"no" ) ==0 ) { -ad_advertise_tx_power (FALSE); +ad_advertise_tx_power (false);return ; }
@@ -2370,12 +2370,32 @@ static void cmd_set_advertise_name(const char *arg) }if (strcmp (arg,"on" ) ==0 ||strcmp (arg,"yes" ) ==0 ) { -ad_advertise_name (TRUE); +ad_advertise_name (true);return ; }if (strcmp (arg,"off" ) ==0 ||strcmp (arg,"no" ) ==0 ) { -ad_advertise_name (FALSE); +ad_advertise_name (false); +return ; + } + +rl_printf ("Invalid argument\n" ); +} + +static void cmd_set_advertise_appearance (const char *arg) +{ +if (arg ==NULL ||strlen (arg) ==0 ) { +rl_printf ("Missing value argument\n" ); +return ; + } + +if (strcmp (arg,"on" ) ==0 ||strcmp (arg,"yes" ) ==0 ) { +ad_advertise_appearance (true); +return ; + } + +if (strcmp (arg,"off" ) ==0 ||strcmp (arg,"no" ) ==0 ) { +ad_advertise_appearance (false);return ; }
@@ -2428,6 +2448,8 @@ static const struct { "Enable/disable TX power to be advertised" }, {"set-advertise-name" ,"<on/off>" , cmd_set_advertise_name, "Enable/disable local name to be advertised" }, + { "set-advertise-appearance", "<value>", cmd_set_advertise_appearance, + "Set custom appearance to be advertised" }, { "set-scan-filter-uuids", "[uuid1 uuid2 ...]", cmd_set_scan_filter_uuids, "Set scan filter uuids" }, { "set-scan-filter-rssi", "[rssi]", cmd_set_scan_filter_rssi,
Signature · 1 line
2.13.3
Marcel Holtmann
maintainerHi Luiz,
Quoted 15 lines
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(+)doc/advertising-api.txt +0
-0@@ -116,3 +116,11 @@ Methods RegisterAdvertisement(object advertisement, dict options)Properties byte AdvertisementInstaces
Number of available advertisement instances.
doc/advertising-api.txt Methods RegisterAdvertisement(object advertisement, dict options)
Quoted 8 lines
doc/advertising-api.txt +8
-0+ + 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.
Quoted 46 lines
src/advertising.c +31
-0@@ -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);
src/advertising.c static gboolean get_instances(const GDBusPropertyTable *property, · line 781
Quoted 10 lines
src/advertising.c +8
-0+ +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?
src/advertising.c static void read_adv_features_callback(uint8_t status, uint16_t length, · line 828
Quoted 10 lines
src/advertising.c +3
-0+ { "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
Marcel Holtmann
maintainerRe: [PATCH v2 2/5] advertising: Add IncludeName property
In reply to Luiz Augusto von DentzHi Luiz,
Quoted 12 lines
This adds support to include adapter name, or alias, in the scan response with use of IncludeName property.
---doc/advertising-api.txt| 5 +++++src/advertising.c| 27 +++++++++++++++++++++++++++2 files changed, 32 insertions(+)doc/advertising-api.txt +0
-0
doc/advertising-api.txt Properties string Type · line 73
Quoted 8 lines
doc/advertising-api.txt +5
-0@@ -66,6 +66,11 @@ Properties string Type Includes the Tx Power in the advertising packet. If missing, the Tx Power is not included. + bool IncludeName + + Include adapter Name, or Alias if set, as scan + response data. +
would be an array{string} SystemAdvertisingData or something a lot better. Mapping the mgmt API one to one seems a really pointless idea.
Regards
Marcel