core: Add ResetData filter
Luiz Augusto von Dentz
maintainerPATCH 1/5 core: Add ResetData filter
From: Luiz Augusto von Dentz <[email protected]>
Reset service/manufactorer data so the application can see each and every instance of them.
--- doc/adapter-api.txt | 5 +++++ src/adapter.c | 40 ++++++++++++++++++++++++++++++++++++---- src/device.c | 12 ++++++++++-- src/device.h | 5 +++-- 4 files changed, 54 insertions(+), 8 deletions(-)
doc/adapter-api.txt +5 -0
@@ -58,6 +58,7 @@ Methods void StartDiscovery() int16 RSSI : RSSI threshold value uint16 Pathloss : Pathloss threshold value string Transport : type of scan to run + bool ResetData : Reset advertisement data When a remote device is found that advertises any UUID from UUIDs, it will be reported if:
@@ -90,6 +91,10 @@ Methods void StartDiscovery() the RSSI delta-threshold, that is imposed by StartDiscovery by default, will not be applied. + If ResetData is enabled PropertiesChanged signals will + be generated for either ManufacturerData and ServiceData + everytime they are discovered. + When multiple clients call SetDiscoveryFilter, their filters are internally merged, and notifications about new devices are sent to all clients. Therefore, each
src/adapter.c +36 -4
@@ -155,6 +155,7 @@ struct discovery_filter {uint16_t pathloss;int16_t rssi;GSList *uuids; +bool reset; };struct watch_client {
@@ -2213,6 +2214,16 @@ static bool parse_transport(DBusMessageIter *value, uint8_t *transport)return true; } +static bool parse_reset_data (DBusMessageIter *value,bool *duplicates) +{ +if (dbus_message_iter_get_arg_type (value) !=DBUS_TYPE_BOOLEAN ) +return false; + +dbus_message_iter_get_basic (value, duplicates); + +return true; +} +static bool parse_discovery_filter_entry (char *key,DBusMessageIter *value,struct discovery_filter *filter) {
@@ -2228,6 +2239,9 @@ static bool parse_discovery_filter_entry(char *key, DBusMessageIter *value,if (!strcmp ("Transport" , key))return parse_transport (value, &filter->type); +if (!strcmp ("ResetData" , key)) +return parse_reset_data (value, &filter->reset); +DBG ("Unknown key parameter: %s!\n" , key);return false; }
@@ -2253,6 +2267,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, (*filter)->pathloss =DISTANCE_VAL_INVALID ; (*filter)->rssi =DISTANCE_VAL_INVALID ; (*filter)->type =get_scan_type (adapter); + (*filter)->reset = false;dbus_message_iter_init (msg, &iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
@@ -2297,8 +2312,9 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, (*filter)->rssi != DISTANCE_VAL_INVALID) goto invalid_args; -DBG ("filtered discovery params: transport: %d rssi: %d pathloss: %d" , - (*filter)->type, (*filter)->rssi, (*filter)->pathloss); +DBG ("filtered discovery params: transport: %d rssi: %d pathloss: %d " +" reset data: %s " , (*filter)->type, (*filter)->rssi, + (*filter)->pathloss, (*filter)->reset ?"true" :"false" );return true;
@@ -5568,6 +5584,17 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,return got_match; } +static void filter_reset_data (void *data,void *user_data) +{ +struct watch_client *client = data; +bool *reset = user_data; + +if (*reset || !client->discovery_filter) +return ; + + *reset = client->discovery_filter->reset; +} + static void update_found_devices(struct btd_adapter *adapter, const bdaddr_t *bdaddr, uint8_t bdaddr_type, int8_t rssi,
@@ -5579,6 +5606,7 @@ static void update_found_devices(struct btd_adapter *adapter,struct eir_data eir_data;bool name_known, discoverable;char addr[18 ]; +bool reset = false;memset (&eir_data,0 ,sizeof (eir_data));eir_parse (&eir_data, data, data_len);
@@ -5678,13 +5706,17 @@ static void update_found_devices(struct btd_adapter *adapter,device_add_eir_uuids (dev, eir_data.services); +if (adapter->discovery_list) +g_slist_foreach (adapter->discovery_list, filter_reset_data, + &reset); +if (eir_data.msd_list) { -device_set_manufacturer_data (dev, eir_data.msd_list); +device_set_manufacturer_data (dev, eir_data.msd_list, reset);adapter_msd_notify (adapter, dev, eir_data.msd_list); }if (eir_data.sd_list) -device_set_service_data (dev, eir_data.sd_list); +device_set_service_data (dev, eir_data.sd_list, reset);if (bdaddr_type !=BDADDR_BREDR )device_set_flags (dev, eir_data.flags);
src/device.c +10 -2
@@ -1611,8 +1611,12 @@ static void add_manufacturer_data(void *data, void *user_data) DEVICE_INTERFACE, "ManufacturerData"); } -void device_set_manufacturer_data (struct btd_device *dev,GSList *list) +void device_set_manufacturer_data (struct btd_device *dev,GSList *list, +bool reset) { +if (reset) +bt_ad_clear_manufacturer_data (dev->ad); +g_slist_foreach (list, add_manufacturer_data, dev); }
@@ -1632,8 +1636,12 @@ static void add_service_data(void *data, void *user_data) DEVICE_INTERFACE, "ServiceData"); } -void device_set_service_data (struct btd_device *dev,GSList *list) +void device_set_service_data (struct btd_device *dev,GSList *list, +bool reset) { +if (reset) +bt_ad_clear_service_data (dev->ad); +g_slist_foreach (list, add_service_data, dev); }
src/device.h +3 -2
@@ -76,8 +76,9 @@ void btd_device_gatt_set_service_changed(struct btd_device *device,bool device_attach_att (struct btd_device *dev,GIOChannel *io);void btd_device_add_uuid (struct btd_device *device,const char *uuid);void device_add_eir_uuids (struct btd_device *dev,GSList *uuids); -void device_set_manufacturer_data (struct btd_device *dev,GSList *list); -void device_set_service_data (struct btd_device *dev,GSList *list); +void device_set_manufacturer_data (struct btd_device *dev,GSList *list, +bool reset); +void device_set_service_data (struct btd_device *dev,GSList *list,bool reset);void device_probe_profile (gpointer a,gpointer b);void device_remove_profile (gpointer a,gpointer b);struct btd_adapter *device_get_adapter (struct btd_device *device);
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH 2/5 client: Add set-scan-filter-reset-data command
From: Luiz Augusto von Dentz <[email protected]>
This adds set-scan-filter-reset-data that makes use of ResetData filter:
[bluetooth]# set-scan-filter-reset-data on
SetDiscoveryFilter success
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:8A:60:D8:17:D7 Discovering: yes
[CHG] Device F0:79:59:2F:D6:5A RSSI: -87
[NEW] Device 39:5B:8F:12:84:2E 39-5B-8F-12-84-2E
[CHG] Device 14:99:E2:0E:AC:6B RSSI: -80
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Key: 0x004c
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x09
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x06
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x03
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x19
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 39:5B:8F:12:84:2E RSSI: -30
[CHG] Device F0:79:59:2F:D6:5A RSSI: -87
[CHG] Device 00:1B:DC:07:31:88 RSSI: -31
[CHG] Device 00:1B:DC:07:31:88 ServiceData Key: 00001827-0000-1000-8000-00805f9b34fb [CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0xdd
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0xdd
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B RSSI: -75
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Key: 0x004c
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x09
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x06
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x03
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x19
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device 14:99:E2:0E:AC:6B ManufacturerData Value: 0x00
[CHG] Device F0:79:59:2F:D6:5A RSSI: -86
[CHG] Device F0:79:59:2F:D6:5A RSSI: -86
[CHG] Device F0:79:59:2F:D6:5A RSSI: -86
[CHG] Device 00:1B:DC:07:31:88 RSSI: -27
[CHG] Device 00:1B:DC:07:31:88 ServiceData Key: 00001827-0000-1000-8000-00805f9b34fb [CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0xdd
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0xdd
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
--- client/main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
client/main.c +25 -0
@@ -1189,6 +1189,7 @@ struct set_discovery_filter_args {dbus_int16_t pathloss;char **uuids;size_t uuids_len; +dbus_bool_t reset; };static void set_discovery_filter_setup (DBusMessageIter *iter,void *user_data)
@@ -1216,6 +1217,10 @@ static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data)dict_append_entry (&dict,"Transport" ,DBUS_TYPE_STRING , &args->transport); +if (args->reset) +dict_append_entry (&dict,"ResetData" ,DBUS_TYPE_BOOLEAN , + &args->reset); +dbus_message_iter_close_container (iter, &dict); }
@@ -1239,6 +1244,7 @@ static gint filtered_scan_pathloss = DISTANCE_VAL_INVALID;static char **filtered_scan_uuids;static size_t filtered_scan_uuids_len;static char *filtered_scan_transport; +static bool filtered_scan_reset_data;static void cmd_set_scan_filter_commit (void ) {
@@ -1250,6 +1256,7 @@ static void cmd_set_scan_filter_commit(void) args.transport = filtered_scan_transport; args.uuids = filtered_scan_uuids; args.uuids_len = filtered_scan_uuids_len; + args.reset = filtered_scan_reset_data;if (check_default_ctrl () == FALSE)return ;
@@ -1319,6 +1326,22 @@ static void cmd_set_scan_filter_transport(const char *arg)cmd_set_scan_filter_commit (); } +static void cmd_set_scan_filter_reset_data (const char *arg) +{ +if (!arg || !strlen (arg)) + filtered_scan_reset_data = false; +else if (!strcmp (arg,"on" )) + filtered_scan_reset_data = true; +else if (!strcmp (arg,"off" )) + filtered_scan_reset_data = false; +else { +rl_printf ("Invalid option: %s\n" , arg); +return ; + } + +cmd_set_scan_filter_commit (); +} +static void clear_discovery_filter_setup (DBusMessageIter *iter,void *user_data) {DBusMessageIter dict;
@@ -2319,6 +2342,8 @@ static const struct { "Set scan filter pathloss, and clears rssi" }, {"set-scan-filter-transport" ,"[transport]" , cmd_set_scan_filter_transport, "Set scan filter transport" }, + { "set-scan-filter-reset-data", "[on/off]", + cmd_set_scan_filter_reset_data, "Set scan filter reset data" }, { "set-scan-filter-clear", "", cmd_set_scan_filter_clear, "Clears discovery filter." }, { "scan", "<on/off>", cmd_scan, "Scan for devices" },
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH 3/5 core: Add GetDiscoveryFilters
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
In order to extend SetDiscoveryFilter with more filters the application might have to query what filters are available.
--- doc/adapter-api.txt | 7 +++++ src/adapter.c | 86 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 67 insertions(+), 26 deletions(-)
doc/adapter-api.txt +7 -0
@@ -114,6 +114,13 @@ Methods void StartDiscovery() org.bluez.Error.NotSupported org.bluez.Error.Failed + array{string} GetDiscoveryFilters() + + Return available filters that can be given to + SetDiscoveryFilter. + + Possible errors: None + Properties string Address [readonly] The Bluetooth device address.
src/adapter.c +60 -26
161 lines not on this page · raw message
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH 4/5 client: Fix output for DBUS_TYPE_UINT32 iter
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
The correct for should be 0x%08x not 0x%06x.
--- client/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
client/main.c +1 -1
@@ -236,7 +236,7 @@ static void print_iter(const char *label, const char *name,break ;case DBUS_TYPE_UINT32 :dbus_message_iter_get_basic (iter, &valu32); -rl_printf ("%s%s: 0x%06x\n" , label, name, valu32); +rl_printf ("%s%s: 0x%08x\n" , label, name, valu32);break ;case DBUS_TYPE_UINT16 :dbus_message_iter_get_basic (iter, &valu16);
Signature · 1 line
2.13.3
Luiz Augusto von Dentz
maintainerPATCH 5/5 client: Use rl_hexdump to print fixed sized iterators
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This makes the output less clutter with duplicated infomation:
before:
[CHG] Device 00:1B:DC:07:31:88 ServiceData Key: 00001827-0000-1000-8000-00805f9b34fb [CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0xdd
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0xdd
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
[CHG] Device 00:1B:DC:07:31:88 ServiceData Value: 0x00
after:
[CHG] Device 00:1B:DC:07:31:88 ServiceData Key: 00001827-0000-1000-8000-00805f9b34fb
dd dd 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 ..
--- client/main.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
client/main.c +73 -0
@@ -203,6 +203,72 @@ static void print_device(GDBusProxy *proxy, const char *description) address, name); } +static void print_fixed_iter (const char *label,const char *name, +DBusMessageIter *iter) +{ +dbus_bool_t *valbool; +dbus_uint32_t *valu32; +dbus_uint16_t *valu16; +dbus_int16_t *vals16; +unsigned char *byte; +int len; + +switch (dbus_message_iter_get_arg_type (iter)) { +case DBUS_TYPE_BOOLEAN : +dbus_message_iter_get_fixed_array (iter, &valbool, &len); + +if (len <=0 ) +return ; + +rl_printf ("%s%s:" , label, name); +rl_hexdump ((void *)valbool, len *sizeof (*valbool)); + +break ; +case DBUS_TYPE_UINT32 : +dbus_message_iter_get_fixed_array (iter, &valu32, &len); + +if (len <=0 ) +return ; + +rl_printf ("%s%s:" , label, name); +rl_hexdump ((void *)valu32, len *sizeof (*valu32)); + +break ; +case DBUS_TYPE_UINT16 : +dbus_message_iter_get_fixed_array (iter, &valu16, &len); + +if (len <=0 ) +return ; + +rl_printf ("%s%s:" , label, name); +rl_hexdump ((void *)valu16, len *sizeof (*valu16)); + +break ; +case DBUS_TYPE_INT16 : +dbus_message_iter_get_fixed_array (iter, &vals16, &len); + +if (len <=0 ) +return ; + +rl_printf ("%s%s:" , label, name); +rl_hexdump ((void *)vals16, len *sizeof (*vals16)); + +break ; +case DBUS_TYPE_BYTE : +dbus_message_iter_get_fixed_array (iter, &byte, &len); + +if (len <=0 ) +return ; + +rl_printf ("%s%s:" , label, name); +rl_hexdump ((void *)byte, len *sizeof (*byte)); + +break ; +default : +return ; + }; +} +static void print_iter (const char *label,const char *name,DBusMessageIter *iter) {
@@ -256,6 +322,13 @@ static void print_iter(const char *label, const char *name,break ;case DBUS_TYPE_ARRAY :dbus_message_iter_recurse (iter, &subiter); + +if (dbus_type_is_fixed ( +dbus_message_iter_get_arg_type (&subiter))) { +print_fixed_iter (label, name, &subiter); +break ; + } +while (dbus_message_iter_get_arg_type (&subiter) !=DBUS_TYPE_INVALID ) {print_iter (label, name, &subiter);
Signature · 1 line
2.13.3
Hi,
Quoted 188 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Reset service/manufactorer data so the application can see each and every instance of them.
--- doc/adapter-api.txt | 5 +++++ src/adapter.c | 40 ++++++++++++++++++++++++++++++++++++---- src/device.c | 12 ++++++++++-- src/device.h | 5 +++-- 4 files changed, 54 insertions(+), 8 deletions(-)doc/adapter-api.txt +5
-0@@ -58,6 +58,7 @@ Methods void StartDiscovery() int16 RSSI : RSSI threshold value uint16 Pathloss : Pathloss threshold value string Transport : type of scan to run + bool ResetData : Reset advertisement data When a remote device is found that advertises any UUID from UUIDs, it will be reported if:@@ -90,6 +91,10 @@ Methods void StartDiscovery() the RSSI delta-threshold, that is imposed by StartDiscovery by default, will not be applied. + If ResetData is enabled PropertiesChanged signals will + be generated for either ManufacturerData and ServiceData + everytime they are discovered. + When multiple clients call SetDiscoveryFilter, their filters are internally merged, and notifications about new devices are sent to all clients. Therefore, eachsrc/adapter.c +36
-4@@ -155,6 +155,7 @@ struct discovery_filter {uint16_t pathloss;int16_t rssi;GSList *uuids; +bool reset; };struct watch_client {@@ -2213,6 +2214,16 @@ static bool parse_transport(DBusMessageIter *value, uint8_t *transport)return true; } +static bool parse_reset_data (DBusMessageIter *value,bool *duplicates) +{ +if (dbus_message_iter_get_arg_type (value) !=DBUS_TYPE_BOOLEAN ) +return false; + +dbus_message_iter_get_basic (value, duplicates); + +return true; +} +static bool parse_discovery_filter_entry (char *key,DBusMessageIter *value,struct discovery_filter *filter) {@@ -2228,6 +2239,9 @@ static bool parse_discovery_filter_entry(char *key, DBusMessageIter *value,if (!strcmp ("Transport" , key))return parse_transport (value, &filter->type); +if (!strcmp ("ResetData" , key)) +return parse_reset_data (value, &filter->reset); +DBG ("Unknown key parameter: %s!\n" , key);return false; }@@ -2253,6 +2267,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, (*filter)->pathloss =DISTANCE_VAL_INVALID ; (*filter)->rssi =DISTANCE_VAL_INVALID ; (*filter)->type =get_scan_type (adapter); + (*filter)->reset = false;dbus_message_iter_init (msg, &iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||@@ -2297,8 +2312,9 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, (*filter)->rssi != DISTANCE_VAL_INVALID) goto invalid_args; -DBG ("filtered discovery params: transport: %d rssi: %d pathloss: %d" , - (*filter)->type, (*filter)->rssi, (*filter)->pathloss); +DBG ("filtered discovery params: transport: %d rssi: %d pathloss: %d " +" reset data: %s " , (*filter)->type, (*filter)->rssi, + (*filter)->pathloss, (*filter)->reset ?"true" :"false" );return true;@@ -5568,6 +5584,17 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,return got_match; } +static void filter_reset_data (void *data,void *user_data) +{ +struct watch_client *client = data; +bool *reset = user_data; + +if (*reset || !client->discovery_filter) +return ; + + *reset = client->discovery_filter->reset; +} + static void update_found_devices(struct btd_adapter *adapter, const bdaddr_t *bdaddr, uint8_t bdaddr_type, int8_t rssi,@@ -5579,6 +5606,7 @@ static void update_found_devices(struct btd_adapter *adapter,struct eir_data eir_data;bool name_known, discoverable;char addr[18 ]; +bool reset = false;memset (&eir_data,0 ,sizeof (eir_data));eir_parse (&eir_data, data, data_len);@@ -5678,13 +5706,17 @@ static void update_found_devices(struct btd_adapter *adapter,device_add_eir_uuids (dev, eir_data.services); +if (adapter->discovery_list) +g_slist_foreach (adapter->discovery_list, filter_reset_data, + &reset); +if (eir_data.msd_list) { -device_set_manufacturer_data (dev, eir_data.msd_list); +device_set_manufacturer_data (dev, eir_data.msd_list, reset);adapter_msd_notify (adapter, dev, eir_data.msd_list); }if (eir_data.sd_list) -device_set_service_data (dev, eir_data.sd_list); +device_set_service_data (dev, eir_data.sd_list, reset);if (bdaddr_type !=BDADDR_BREDR )device_set_flags (dev, eir_data.flags);src/device.c +10
-2@@ -1611,8 +1611,12 @@ static void add_manufacturer_data(void *data, void *user_data) DEVICE_INTERFACE, "ManufacturerData"); } -void device_set_manufacturer_data (struct btd_device *dev,GSList *list) +void device_set_manufacturer_data (struct btd_device *dev,GSList *list, +bool reset) { +if (reset) +bt_ad_clear_manufacturer_data (dev->ad); +g_slist_foreach (list, add_manufacturer_data, dev); }@@ -1632,8 +1636,12 @@ static void add_service_data(void *data, void *user_data) DEVICE_INTERFACE, "ServiceData"); } -void device_set_service_data (struct btd_device *dev,GSList *list) +void device_set_service_data (struct btd_device *dev,GSList *list, +bool reset) { +if (reset) +bt_ad_clear_service_data (dev->ad); +g_slist_foreach (list, add_service_data, dev); }src/device.h +3
-3@@ -76,8 +76,9 @@ void btd_device_gatt_set_service_changed(struct btd_device *device,bool device_attach_att (struct btd_device *dev,GIOChannel *io);void btd_device_add_uuid (struct btd_device *device,const char *uuid);void device_add_eir_uuids (struct btd_device *dev,GSList *uuids); -void device_set_manufacturer_data (struct btd_device *dev,GSList *list); -void device_set_service_data (struct btd_device *dev,GSList *list); +void device_set_manufacturer_data (struct btd_device *dev,GSList *list, +bool reset); +void device_set_service_data (struct btd_device *dev,GSList *list,bool reset);void device_probe_profile (gpointer a,gpointer b);void device_remove_profile (gpointer a,gpointer b);struct btd_adapter *device_get_adapter (struct btd_device *device); --
Quoted 1 line
2.13.3
Applied.
Signature · 1 line
Luiz Augusto von Dentz