From 71fdc901e3d14262aafa3733e18d940833dc089e Mon Sep 17 00:00:00 2001 From: Arun Jagadish Date: Tue, 13 Dec 2016 18:48:24 +0530 Subject: [PATCH] Bluetooth: AVDTP: Add AVDTP_Timer & Handler Added AVDTP_TIMER = 6secs for tracking sent Singalling Request. Timeout handler function added. Change-Id: I76ddcdcfba2b5e9317f66f9815e0d9d3f4cc87e7 Signed-off-by: Arun Jagadish --- subsys/bluetooth/host/avdtp.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/avdtp.c b/subsys/bluetooth/host/avdtp.c index 45856d77b81..c5ceefbccd9 100644 --- a/subsys/bluetooth/host/avdtp.c +++ b/subsys/bluetooth/host/avdtp.c @@ -55,15 +55,36 @@ static struct bt_avdtp_seid_lsep *lseps; #define AVDTP_CHAN(_ch) CONTAINER_OF(_ch, struct bt_avdtp, br_chan.chan) +#define AVDTP_KWORK(_work) CONTAINER_OF(_work, struct bt_avdtp,\ + req.timeout_work) + +#define AVDTP_TIMEOUT K_SECONDS(6) + +/* Timeout handler */ +static void avdtp_timeout(struct k_work *work) +{ + BT_DBG("Failed Signal_id = %d", (AVDTP_KWORK(work))->req.signal_id); + + /* Gracefully Disconnect the Signalling and streaming L2cap chann*/ + +} + /* L2CAP Interface callbacks */ void bt_avdtp_l2cap_connected(struct bt_l2cap_chan *chan) { + struct bt_avdtp *session; + if (!chan) { BT_ERR("Invalid AVDTP chan"); return; } - BT_DBG("chan %p session %p", chan, AVDTP_CHAN(chan)); + session = AVDTP_CHAN(chan); + BT_DBG("chan %p session %p", chan, session); + + /* Init the timer */ + k_delayed_work_init(&session->req.timeout_work, avdtp_timeout); + } void bt_avdtp_l2cap_disconnected(struct bt_l2cap_chan *chan)