Message ID | 20230802132355.4953-4-claudia.rosu@nxp.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Add support for BAP broadcast sink | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/CheckPatch | success | CheckPatch PASS |
tedd_an/GitLint | success | Gitlint PASS |
tedd_an/IncrementalBuild | success | Incremental Build PASS |
Hi Claudia, On Wed, Aug 2, 2023 at 6:49 AM Claudia Draghicescu <claudia.rosu@nxp.com> wrote: > > This adds a new method in the adapter driver, device_resolved() called > when a broadcast source that advertises the BCAA_UUID is discovered. > > --- > src/adapter.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > src/adapter.h | 2 ++ > 2 files changed, 50 insertions(+) > > diff --git a/src/adapter.c b/src/adapter.c > index 491bd7031..29c6a576a 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -7029,6 +7029,45 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data, > return got_match; > } > > +static int find_baas(gconstpointer a, gconstpointer b) > +{ > + const struct eir_sd *sd = a; > + const char *baas_uuid = b; > + > + return strcmp(sd->uuid, baas_uuid); > +} > + > +static bool accept_bcast_adv(struct btd_adapter *adapter) > +{ > + if ((btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER))) > + return true; > + > + return false; > +} > + > +static bool is_bcast_source(struct eir_data *eir_data) > +{ > + if (!(eir_data->flags & (EIR_LIM_DISC | EIR_GEN_DISC)) > + && (g_slist_find_custom(eir_data->sd_list, > + BCAA_SERVICE_UUID, find_baas))) { > + return true; > + } > + > + return false; > +} > +static void bcast_new_source(struct btd_adapter *adapter, > + struct btd_device *device) > +{ > + GSList *l; > + > + for (l = adapter->drivers; l; l = g_slist_next(l)) { > + struct btd_adapter_driver *driver = l->data; > + > + if (!strcmp(driver->name, "bcast")) > + driver->device_discovered(adapter, device); > + } > +} This code probably doesn't belong here, profile specific code like the above shall be left to the plugin to handle. > static void filter_duplicate_data(void *data, void *user_data) > { > struct discovery_client *client = data; > @@ -7152,12 +7191,21 @@ void btd_adapter_device_found(struct btd_adapter *adapter, > return; > } > > + if (accept_bcast_adv(adapter) && is_bcast_source(&eir_data)) > + monitoring = true; > + > if (!discoverable && !monitoring && !eir_data.rsi) { > eir_data_free(&eir_data); > return; > } > > dev = adapter_create_device(adapter, bdaddr, bdaddr_type); > + > + if (dev && is_bcast_source(&eir_data)) { > + bcast_new_source(adapter, dev); > + btd_device_set_temporary(dev, false); > + } > + > } > > if (!dev) { > diff --git a/src/adapter.h b/src/adapter.h > index ca96c1f65..ee32f7110 100644 > --- a/src/adapter.h > +++ b/src/adapter.h > @@ -125,6 +125,8 @@ struct btd_adapter_driver { > struct btd_device *device); > void (*device_resolved)(struct btd_adapter *adapter, > struct btd_device *device); > + void (*device_discovered)(struct btd_adapter *adapter, > + struct btd_device *device); Let me figure out the driver interface since I think it is better to use the btd_device_driver and then have a generic match by UUID. > /* Indicates the driver is experimental and shall only be registered > * when experimental has been enabled (see: main.conf:Experimental). > -- > 2.34.1 >
diff --git a/src/adapter.c b/src/adapter.c index 491bd7031..29c6a576a 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7029,6 +7029,45 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data, return got_match; } +static int find_baas(gconstpointer a, gconstpointer b) +{ + const struct eir_sd *sd = a; + const char *baas_uuid = b; + + return strcmp(sd->uuid, baas_uuid); +} + +static bool accept_bcast_adv(struct btd_adapter *adapter) +{ + if ((btd_adapter_has_settings(adapter, MGMT_SETTING_ISO_SYNC_RECEIVER))) + return true; + + return false; +} + +static bool is_bcast_source(struct eir_data *eir_data) +{ + if (!(eir_data->flags & (EIR_LIM_DISC | EIR_GEN_DISC)) + && (g_slist_find_custom(eir_data->sd_list, + BCAA_SERVICE_UUID, find_baas))) { + return true; + } + + return false; +} +static void bcast_new_source(struct btd_adapter *adapter, + struct btd_device *device) +{ + GSList *l; + + for (l = adapter->drivers; l; l = g_slist_next(l)) { + struct btd_adapter_driver *driver = l->data; + + if (!strcmp(driver->name, "bcast")) + driver->device_discovered(adapter, device); + } +} + static void filter_duplicate_data(void *data, void *user_data) { struct discovery_client *client = data; @@ -7152,12 +7191,21 @@ void btd_adapter_device_found(struct btd_adapter *adapter, return; } + if (accept_bcast_adv(adapter) && is_bcast_source(&eir_data)) + monitoring = true; + if (!discoverable && !monitoring && !eir_data.rsi) { eir_data_free(&eir_data); return; } dev = adapter_create_device(adapter, bdaddr, bdaddr_type); + + if (dev && is_bcast_source(&eir_data)) { + bcast_new_source(adapter, dev); + btd_device_set_temporary(dev, false); + } + } if (!dev) { diff --git a/src/adapter.h b/src/adapter.h index ca96c1f65..ee32f7110 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -125,6 +125,8 @@ struct btd_adapter_driver { struct btd_device *device); void (*device_resolved)(struct btd_adapter *adapter, struct btd_device *device); + void (*device_discovered)(struct btd_adapter *adapter, + struct btd_device *device); /* Indicates the driver is experimental and shall only be registered * when experimental has been enabled (see: main.conf:Experimental).