Bluetooth: AVDTP:Add Accept Incoming connection cb

Added Accept Incoming connection callbacks for the A2DP layer

Change-Id: I8aee32a97916ed9fc9c4050151e7395e288c404c
Signed-off-by: Arun Jagadish <arun.jagadish@intel.com>
This commit is contained in:
Arun Jagadish 2016-12-21 15:11:54 +05:30 committed by Luiz Augusto von Dentz
commit 231050a966
2 changed files with 25 additions and 50 deletions

View file

@ -47,8 +47,6 @@ NET_BUF_POOL_DEFINE(avdtp_sig_pool, CONFIG_BLUETOOTH_AVDTP_CONN,
BT_BUF_USER_DATA_MIN, NULL); BT_BUF_USER_DATA_MIN, NULL);
*/ */
static struct bt_avdtp bt_avdtp_pool[CONFIG_BLUETOOTH_AVDTP_CONN];
static struct bt_avdtp_event_cb *event_cb; static struct bt_avdtp_event_cb *event_cb;
static struct bt_avdtp_seid_lsep *lseps; static struct bt_avdtp_seid_lsep *lseps;
@ -81,7 +79,6 @@ void bt_avdtp_l2cap_connected(struct bt_l2cap_chan *chan)
session = AVDTP_CHAN(chan); session = AVDTP_CHAN(chan);
BT_DBG("chan %p session %p", chan, session); BT_DBG("chan %p session %p", chan, session);
/* Init the timer */ /* Init the timer */
k_delayed_work_init(&session->req.timeout_work, avdtp_timeout); k_delayed_work_init(&session->req.timeout_work, avdtp_timeout);
@ -89,12 +86,11 @@ void bt_avdtp_l2cap_connected(struct bt_l2cap_chan *chan)
void bt_avdtp_l2cap_disconnected(struct bt_l2cap_chan *chan) void bt_avdtp_l2cap_disconnected(struct bt_l2cap_chan *chan)
{ {
if (!chan) { struct bt_avdtp *session = AVDTP_CHAN(chan);
BT_ERR("Invalid AVDTP chan");
return;
}
BT_DBG("chan %p session %p", chan, AVDTP_CHAN(chan)); BT_DBG("chan %p session %p", chan, session);
session->br_chan.chan.conn = NULL;
/* Clear the Pending req if set*/
} }
void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, uint8_t status) void bt_avdtp_l2cap_encrypt_changed(struct bt_l2cap_chan *chan, uint8_t status)
@ -141,7 +137,8 @@ int bt_avdtp_disconnect(struct bt_avdtp *session)
int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan) int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
{ {
int i; struct bt_avdtp *session = NULL;
int result;
static struct bt_l2cap_chan_ops ops = { static struct bt_l2cap_chan_ops ops = {
.connected = bt_avdtp_l2cap_connected, .connected = bt_avdtp_l2cap_connected,
.disconnected = bt_avdtp_l2cap_disconnected, .disconnected = bt_avdtp_l2cap_disconnected,
@ -149,21 +146,15 @@ int bt_avdtp_l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
}; };
BT_DBG("conn %p", conn); BT_DBG("conn %p", conn);
/* Get the AVDTP session from upper layer */
for (i = 0; i < ARRAY_SIZE(bt_avdtp_pool); i++) { result = event_cb->accept(conn, &session);
struct bt_avdtp *avdtp = &bt_avdtp_pool[i]; if (result < 0) {
return result;
if (avdtp->br_chan.chan.conn) {
continue;
}
avdtp->br_chan.chan.ops = &ops;
avdtp->br_chan.rx.mtu = BT_AVDTP_MAX_MTU;
*chan = &avdtp->br_chan.chan;
return 0;
} }
session->br_chan.chan.ops = &ops;
return -ENOMEM; session->br_chan.rx.mtu = BT_AVDTP_MAX_MTU;
*chan = &session->br_chan.chan;
return 0;
} }
/* Application will register its callback */ /* Application will register its callback */

View file

@ -55,16 +55,12 @@
#define BT_AVDTP_GET_ALL_CAPABILITIES 0x0c #define BT_AVDTP_GET_ALL_CAPABILITIES 0x0c
#define BT_AVDTP_DELAYREPORT 0x0d #define BT_AVDTP_DELAYREPORT 0x0d
/* @brief AVDTP STATE */ /* @brief AVDTP STREAM STATE */
#define BT_AVDTP_STATE_IDLE 0x01 #define BT_AVDTP_STREAM_STATE_IDLE 0x01
#define BT_AVDTP_STATE_CONFIGURED 0x02 #define BT_AVDTP_STREAM_STATE_CONFIGURED 0x02
#define BT_AVDTP_STATE_OPEN 0x03 #define BT_AVDTP_STREAM_STATE_OPEN 0x03
#define BT_AVDTP_STATE_STREAMING 0x04 #define BT_AVDTP_STREAM_STATE_STREAMING 0x04
#define BT_AVDTP_STATE_CLOSING 0x05 #define BT_AVDTP_STREAM_STATE_CLOSING 0x05
#define BT_AVDTP_STATE_ABORT 0x06
#define BT_AVDTP_STATE_SIG_CONNECTED 0x07
#define BT_AVDTP_STATE_SIG_DISCONNECTED 0x08
#define BT_AVDTP_STATE_INVALID 0x00
/* @brief AVDTP Media TYPE */ /* @brief AVDTP Media TYPE */
#define BT_AVDTP_SERVICE_CAT_MEDIA_TRANSPORT 0x01 #define BT_AVDTP_SERVICE_CAT_MEDIA_TRANSPORT 0x01
@ -115,18 +111,6 @@ struct bt_avdtp_single_sig_hdr {
#define BT_AVDTP_SIG_HDR_LEN sizeof(struct bt_avdtp_single_sig_hdr) #define BT_AVDTP_SIG_HDR_LEN sizeof(struct bt_avdtp_single_sig_hdr)
struct bt_avdtp_cfm_cb {
/*
* Discovery_cfm;
* get_capabilities_cfm;
* set_configuration_cfm;
* open_cfm;
* start_cfm;
* suspend_cfm;
* close_cfm;
*/
};
struct bt_avdtp_ind_cb { struct bt_avdtp_ind_cb {
/* /*
* discovery_ind; * discovery_ind;
@ -139,11 +123,6 @@ struct bt_avdtp_ind_cb {
*/ */
}; };
struct bt_avdtp_event_cb {
struct bt_avdtp_ind_cb *ind;
struct bt_avdtp_cfm_cb *cfm;
};
struct bt_pending_req { struct bt_pending_req {
uint8_t signal_id; uint8_t signal_id;
uint8_t transaction_id; uint8_t transaction_id;
@ -157,6 +136,11 @@ struct bt_avdtp {
struct bt_pending_req req; struct bt_pending_req req;
}; };
struct bt_avdtp_event_cb {
struct bt_avdtp_ind_cb *ind;
int (*accept)(struct bt_conn *conn, struct bt_avdtp **session);
};
/* Initialize AVDTP layer*/ /* Initialize AVDTP layer*/
int bt_avdtp_init(void); int bt_avdtp_init(void);