bool bonded;
bool connected;
bool svc_resolved;
+ bool initiator;
};
struct csrk_info {
return &dev->le_state;
}
+static bool get_initiator(struct btd_device *dev)
+{
+ if (dev->le_state.connected)
+ return dev->le_state.initiator;
+ if (dev->bredr_state.connected)
+ return dev->bredr_state.initiator;
+
+ return false;
+}
+
static GSList *find_service_with_profile(GSList *list, struct btd_profile *p)
{
GSList *l;
return;
state->connected = false;
+ state->initiator = false;
device->general_connect = FALSE;
device_set_svc_refreshed(device, false);
}
/* Notify driver about the new connection */
- service_accept(service);
+ service_accept(service, get_initiator(device));
}
static void device_add_gatt_services(struct btd_device *device)
if (!l)
return;
- service_accept(l->data);
+ service_accept(l->data, get_initiator(device));
}
#endif
GSList *l;
for (l = device->services; l != NULL; l = g_slist_next(l))
- service_accept(l->data);
+ service_accept(l->data, get_initiator(device));
#else
gatt_db_foreach_service(device->db, NULL, accept_gatt_service, device);
#endif
/* Keep this, so we can cancel the connection */
dev->att_io = io;
+ /* Set as initiator */
+ dev->le_state.initiator = true;
return 0;
}
btd_service_unref(service);
}
-int service_accept(struct btd_service *service)
+int service_accept(struct btd_service *service, bool initiator)
{
char addr[18];
int err;
return -ECONNABORTED;
}
+ service->initiator = initiator;
+
err = service->profile->accept(service);
if (!err)
goto done;
int service_probe(struct btd_service *service);
void service_remove(struct btd_service *service);
-int service_accept(struct btd_service *service);
+int service_accept(struct btd_service *service, bool initiator);
int service_set_connecting(struct btd_service *service);
/* Connection control API */