diff --git a/src/device.c b/src/device.c
index 9e5506c..8eb212c 100644
--- a/src/device.c
+++ b/src/device.c
}
/* Mark service as claimed */
- gatt_db_service_set_active(data->cur_attr, false);
+ gatt_db_service_set_claimed(data->cur_attr, true);
data->dev->services = g_slist_append(data->dev->services, service);
}
g_strdup(data->cur_uuid));
/* Don't probe the profiles if a matching service already exists. */
- if (find_service_with_uuid(data->dev->services, data->cur_uuid))
+ if (find_service_with_uuid(data->dev->services, data->cur_uuid)) {
+ /* Mark the service as claimed by the existing profile. */
+ gatt_db_service_set_claimed(data->cur_attr, true);
return;
+ }
btd_profile_foreach(dev_probe_gatt, data);
diff --git a/src/gatt-client.c b/src/gatt-client.c
index a12c656..cb8ddf6 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
struct btd_gatt_client {
struct btd_device *device;
+ bool ready;
char devaddr[18];
struct gatt_db *db;
struct bt_gatt_client *gatt;
struct btd_gatt_client *client = user_data;
struct service *service;
- if (!gatt_db_service_get_active(attr))
+ if (gatt_db_service_get_claimed(attr))
return;
service = service_create(attr, client);
bt_gatt_client_unref(client->gatt);
client->gatt = bt_gatt_client_ref(gatt);
+ client->ready = true;
+
create_services(client);
}
void btd_gatt_client_service_added(struct btd_gatt_client *client,
struct gatt_db_attribute *attrib)
{
- if (!client)
+ if (!client || !attrib || !client->ready)
return;
export_service(attrib, client);
{
uint16_t start_handle, end_handle;
- if (!client || !attrib)
+ if (!client || !attrib || !client->ready)
return;
gatt_db_attribute_get_service_handles(attrib, &start_handle,