diff --git a/src/shared/vcp.c b/src/shared/vcp.c
index 5a3cc36..dcd4d70 100644
--- a/src/shared/vcp.c
+++ b/src/shared/vcp.c
if (!queue_remove(sessions, vcp))
return;
- bt_gatt_client_unref(vcp->client);
- vcp->client = NULL;
-
- queue_foreach(vcp_cbs, vcp_detached, vcp);
+ if (vcp->client) {
+ bt_gatt_client_unref(vcp->client);
+ vcp->client = NULL;
+ }
}
static void vcp_db_free(void *data)
static void vcp_disconnected(int err, void *user_data)
{
+ /* called only when this device is acting a a server */
struct bt_vcp *vcp = user_data;
DBG(vcp, "vcp %p disconnected err %d", vcp, err);
return vcp;
}
+ /* called only when this device is acting a a server */
vcp = bt_vcp_new(db, NULL);
vcp->att = att;
bt_att_register_disconnect(att, vcp_disconnected, vcp, NULL);
- bt_vcp_attach(vcp, NULL);
+ if (!sessions)
+ sessions = queue_new();
+ queue_push_tail(sessions, vcp);
return vcp;
DBG(vcp, "VCS Vol state found: handle 0x%04x", value_handle);
vcs = vcp_get_vcs(vcp);
- if (!vcs || vcs->vs)
+ if (!vcs)
return;
vcs->vs = attr;
DBG(vcp, "VCS Volume CP found: handle 0x%04x", value_handle);
vcs = vcp_get_vcs(vcp);
- if (!vcs || vcs->vol_cp)
+ if (!vcs)
return;
vcs->vol_cp = attr;
DBG(vcp, "VCS Vol Flag found: handle 0x%04x", value_handle);
vcs = vcp_get_vcs(vcp);
- if (!vcs || vcs->vf)
+ if (!vcs)
return;
vcs->vf = attr;