summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/adapter.c12
-rw-r--r--src/adapter.h1
-rw-r--r--src/device.c26
-rw-r--r--src/device.h1
4 files changed, 40 insertions, 0 deletions
diff --git a/src/adapter.c b/src/adapter.c
index e154c695..6731444a 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2051,6 +2051,18 @@ static void probe_profile(struct btd_profile *profile, void *data)
adapter->profiles = g_slist_prepend(adapter->profiles, profile);
}
+void adapter_add_profile(struct btd_adapter *adapter, gpointer p)
+{
+ struct btd_profile *profile = p;
+
+ if (!adapter->initialized)
+ return;
+
+ probe_profile(profile, adapter);
+
+ g_slist_foreach(adapter->devices, device_probe_profile, profile);
+}
+
static void load_connections(struct btd_adapter *adapter)
{
GSList *l, *conns;
diff --git a/src/adapter.h b/src/adapter.h
index eece6f5d..9f840e88 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -145,6 +145,7 @@ struct btd_adapter_driver {
typedef void (*service_auth_cb) (DBusError *derr, void *user_data);
+void adapter_add_profile(struct btd_adapter *adapter, gpointer p);
int btd_register_adapter_driver(struct btd_adapter_driver *driver);
void btd_unregister_adapter_driver(struct btd_adapter_driver *driver);
int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
diff --git a/src/device.c b/src/device.c
index 57fdf005..cb256060 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1372,6 +1372,32 @@ static void dev_probe(struct btd_profile *p, void *user_data)
g_slist_free(probe_uuids);
}
+void device_probe_profile(gpointer a, gpointer b)
+{
+ struct btd_device *device = a;
+ struct btd_profile *profile = b;
+ GSList *probe_uuids;
+ char addr[18];
+ int err;
+
+ if (profile->device_probe == NULL)
+ return;
+
+ probe_uuids = device_match_profile(device, profile, device->uuids);
+ if (!probe_uuids)
+ return;
+
+ ba2str(&device->bdaddr, addr);
+
+ err = profile->device_probe(profile, device, probe_uuids);
+ if (err < 0)
+ error("%s profile probe failed for %s", profile->name, addr);
+ else
+ device->profiles = g_slist_append(device->profiles, profile);
+
+ g_slist_free(probe_uuids);
+}
+
void device_probe_profiles(struct btd_device *device, GSList *uuids)
{
struct probe_data d = { device, uuids };
diff --git a/src/device.h b/src/device.h
index aee6d131..02c1782e 100644
--- a/src/device.h
+++ b/src/device.h
@@ -61,6 +61,7 @@ void device_register_services(struct btd_device *device,
GSList *device_services_from_record(struct btd_device *device,
GSList *profiles);
void btd_device_add_uuid(struct btd_device *device, const char *uuid);
+void device_probe_profile(gpointer a, gpointer b);
struct btd_adapter *device_get_adapter(struct btd_device *device);
void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
uint8_t *bdaddr_type);