diff options
author | Kim Schulz <k.schulz@samsung.com> | 2015-03-25 10:39:40 +0100 |
---|---|---|
committer | Andre Eisenbach <eisenbach@google.com> | 2015-04-10 16:49:17 -0700 |
commit | 8372aa5fa535ee4f09c09981b6125b54ace31fe2 (patch) | |
tree | 7dcba062c3e78e4475cd925706fc08201444118d /stack/l2cap | |
parent | fd422a772fb3d28d462a2b8020ff4a2bdc5e954a (diff) | |
download | android_system_bt-8372aa5fa535ee4f09c09981b6125b54ace31fe2.tar.gz android_system_bt-8372aa5fa535ee4f09c09981b6125b54ace31fe2.tar.bz2 android_system_bt-8372aa5fa535ee4f09c09981b6125b54ace31fe2.zip |
L2CAP and SDP Search API for BT profiles (2/2)
Added support for exposing L2CAP to Java such that OBEX over L2CAP
is made possible.
Added support to create SDP records as a seperate step.(as opposed to
creating a SDP record when a BluetoothSocket is created).
This allows both a RFCOMM channel and a L2CAP PSM to be included in a
SDP record. (Additionally the content of the SDP record is set by the
profile in Java, in stead of beeing hardcoded in the socket layer.)
This completes the L2CAP channel exposure to Java.
Change-Id: Iaf68a07d910145cdd33e940d73cd680f79164100
Diffstat (limited to 'stack/l2cap')
-rw-r--r-- | stack/l2cap/l2c_api.c | 4 | ||||
-rw-r--r-- | stack/l2cap/l2c_ble.c | 18 | ||||
-rw-r--r-- | stack/l2cap/l2c_csm.c | 13 | ||||
-rw-r--r-- | stack/l2cap/l2c_fcr.c | 3 | ||||
-rw-r--r-- | stack/l2cap/l2c_link.c | 8 | ||||
-rw-r--r-- | stack/l2cap/l2c_main.c | 3 | ||||
-rw-r--r-- | stack/l2cap/l2c_utils.c | 38 |
7 files changed, 62 insertions, 25 deletions
diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.c index 959f4d254..839ad1b5e 100644 --- a/stack/l2cap/l2c_api.c +++ b/stack/l2cap/l2c_api.c @@ -1445,10 +1445,10 @@ BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda) #if BLE_INCLUDED == TRUE (*l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedConn_Cb) - (p_lcb->remote_bd_addr, TRUE, 0, p_lcb->transport); + (fixed_cid,p_lcb->remote_bd_addr, TRUE, 0, p_lcb->transport); #else (*l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedConn_Cb) - (p_lcb->remote_bd_addr, TRUE, 0, BT_TRANSPORT_BR_EDR); + (fixed_cid, p_lcb->remote_bd_addr, TRUE, 0, BT_TRANSPORT_BR_EDR); #endif return TRUE; } diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.c index 65ac7ce08..a2b0a75c9 100644 --- a/stack/l2cap/l2c_ble.c +++ b/stack/l2cap/l2c_ble.c @@ -264,6 +264,7 @@ void l2cble_notify_le_connection (BD_ADDR bda) void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout) { + int i; tL2C_LCB *p_lcb; tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (bda); @@ -352,6 +353,14 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, p_lcb->peer_chnl_mask[0] = L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT; btm_ble_set_conn_st(BLE_CONN_IDLE); + /* + * This is wrong. However, querying the other side is wrong too, since as per spec they + * cannot really tell us when they have fixed channels open. Yes, bluedroid breaks the + * spec in EDR mode in that respect, but that it a whole new story. + */ + for(i = 0; i < L2CAP_FIXED_CHNL_ARRAY_SIZE; i++) + p_lcb->peer_chnl_mask[i] = 0xFF; + l2cu_process_fixed_chnl_resp (p_lcb); } @@ -368,6 +377,7 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, UINT16 conn_interval, UINT16 conn_latency, UINT16 conn_timeout) { + int i; tL2C_LCB *p_lcb; tBTM_SEC_DEV_REC *p_dev_rec; UNUSED(type); @@ -430,6 +440,14 @@ void l2cble_advertiser_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE typ { L2CA_CancelBleConnectReq(bda); } + /* + * This is wrong. However, querying the other side is wrong too, since as per spec they + * cannot really tell us when they have fixed channels open. Yes, bluedroid breaks the + * spec in EDR mode in that respect, but that it a whole new story. + */ + for(i = 0; i < L2CAP_FIXED_CHNL_ARRAY_SIZE; i++) + p_lcb->peer_chnl_mask[i] = 0xFF; + l2cu_process_fixed_chnl_resp (p_lcb); } /******************************************************************************* diff --git a/stack/l2cap/l2c_csm.c b/stack/l2cap/l2c_csm.c index 325f72039..97372ba4d 100644 --- a/stack/l2cap/l2c_csm.c +++ b/stack/l2cap/l2c_csm.c @@ -103,6 +103,7 @@ void l2c_csm_execute (tL2C_CCB *p_ccb, UINT16 event, void *p_data) break; default: + L2CAP_TRACE_DEBUG("Unhandled event! event = %d",event); break; } } @@ -890,7 +891,8 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data) if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) { if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) - (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)(p_ccb->p_lcb->remote_bd_addr,(BT_HDR *)p_data); + (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) + (p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr,(BT_HDR *)p_data); else GKI_freebuf (p_data); break; @@ -909,7 +911,8 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data) case L2CEVT_TIMEOUT: l2cu_send_peer_disc_req (p_ccb); - L2CAP_TRACE_API ("L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x No Conf Needed", p_ccb->local_cid); + L2CAP_TRACE_API ("L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x No Conf Needed", + p_ccb->local_cid); l2cu_release_ccb (p_ccb); (*disconnect_ind)(local_cid, FALSE); break; @@ -936,7 +939,8 @@ static void l2c_csm_open (tL2C_CCB *p_ccb, UINT16 event, void *p_data) UINT8 cfg_result; #if (BT_TRACE_VERBOSE == TRUE) - L2CAP_TRACE_EVENT ("L2CAP - LCID: 0x%04x st: OPEN evt: %s", p_ccb->local_cid, l2c_csm_get_event_name (event)); + L2CAP_TRACE_EVENT ("L2CAP - LCID: 0x%04x st: OPEN evt: %s", + p_ccb->local_cid, l2c_csm_get_event_name (event)); #else L2CAP_TRACE_EVENT ("L2CAP - st: OPEN evt: %d", event); #endif @@ -956,7 +960,8 @@ static void l2c_csm_open (tL2C_CCB *p_ccb, UINT16 event, void *p_data) switch (event) { case L2CEVT_LP_DISCONNECT_IND: /* Link was disconnected */ - L2CAP_TRACE_API ("L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x No Conf Needed", p_ccb->local_cid); + L2CAP_TRACE_API ("L2CAP - Calling Disconnect_Ind_Cb(), CID: 0x%04x No Conf Needed", + p_ccb->local_cid); l2cu_release_ccb (p_ccb); if (p_ccb->p_rcb) (*p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb)(local_cid, FALSE); diff --git a/stack/l2cap/l2c_fcr.c b/stack/l2cap/l2c_fcr.c index ec9a4ef88..3df5cba7e 100644 --- a/stack/l2cap/l2c_fcr.c +++ b/stack/l2cap/l2c_fcr.c @@ -1477,7 +1477,8 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL && p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL)) { if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) - (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)(p_ccb->p_lcb->remote_bd_addr, p_buf); + (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) + (p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, p_buf); } else #endif diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.c index 615e9a705..836f4ba54 100644 --- a/stack/l2cap/l2c_link.c +++ b/stack/l2cap/l2c_link.c @@ -442,11 +442,11 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason) if (p_lcb->p_fixed_ccbs[xx] && p_lcb->p_fixed_ccbs[xx] != p_lcb->p_pending_ccb) { #if BLE_INCLUDED == TRUE - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, - p_lcb->disc_reason, p_lcb->transport); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); #else - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, - p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); #endif l2cu_release_ccb (p_lcb->p_fixed_ccbs[xx]); diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c index 5f541b5e3..ef8f4bc83 100644 --- a/stack/l2cap/l2c_main.c +++ b/stack/l2cap/l2c_main.c @@ -274,7 +274,8 @@ void l2c_rcv_acl_data (BT_HDR *p_msg) if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) l2c_fcr_proc_pdu (p_ccb, p_msg); else - (*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)(p_lcb->remote_bd_addr, p_msg); + (*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) + (rcv_cid, p_lcb->remote_bd_addr, p_msg); } else GKI_freebuf (p_msg); diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c index ef155ff8b..00ff2e7b5 100644 --- a/stack/l2cap/l2c_utils.c +++ b/stack/l2cap/l2c_utils.c @@ -1216,7 +1216,7 @@ void l2cu_send_peer_info_rsp (tL2C_LCB *p_lcb, UINT8 remote_id, UINT16 info_type for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++) if (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) - p[0] |= 1 << (xx + L2CAP_FIRST_FIXED_CHNL); + p[(xx + L2CAP_FIRST_FIXED_CHNL) / 8] |= 1 << ((xx + L2CAP_FIRST_FIXED_CHNL) % 8); } #endif } @@ -2836,22 +2836,27 @@ void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb) #endif if (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) { - if (p_lcb->peer_chnl_mask[0] & (1 << (xx + L2CAP_FIRST_FIXED_CHNL))) + if (p_lcb->peer_chnl_mask[(xx + L2CAP_FIRST_FIXED_CHNL) / 8] + & (1 << ((xx + L2CAP_FIRST_FIXED_CHNL) % 8))) { if (p_lcb->p_fixed_ccbs[xx]) p_lcb->p_fixed_ccbs[xx]->chnl_state = CST_OPEN; #if BLE_INCLUDED == TRUE - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, TRUE, 0, p_lcb->transport); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, TRUE, 0, p_lcb->transport); #else - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, TRUE, 0, BT_TRANSPORT_BR_EDR); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, TRUE, 0, BT_TRANSPORT_BR_EDR); #endif } else { #if BLE_INCLUDED == TRUE - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); #else - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); #endif if (p_lcb->p_fixed_ccbs[xx]) @@ -2898,18 +2903,22 @@ void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb) p_lcb->p_fixed_ccbs[xx] = NULL; l2cu_release_ccb(p_l2c_chnl_ctrl_block); #if BLE_INCLUDED == TRUE - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); #else - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); #endif } } else if ( (peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL))) && (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) ) #if BLE_INCLUDED == TRUE - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); #else - (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); + (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, + p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); #endif } #endif @@ -2926,7 +2935,8 @@ void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb) ** Returns void ** *******************************************************************************/ -void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout) +void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int, + UINT16 latency, UINT16 timeout) { BT_HDR *p_buf; UINT8 *p; @@ -2935,7 +2945,8 @@ void l2cu_send_peer_ble_par_req (tL2C_LCB *p_lcb, UINT16 min_int, UINT16 max_int p_lcb->id++; l2cu_adj_id (p_lcb, L2CAP_ADJ_ID); - if ((p_buf = l2cu_build_header (p_lcb, L2CAP_CMD_BLE_UPD_REQ_LEN, L2CAP_CMD_BLE_UPDATE_REQ, p_lcb->id)) == NULL ) + if ((p_buf = l2cu_build_header (p_lcb, L2CAP_CMD_BLE_UPD_REQ_LEN, + L2CAP_CMD_BLE_UPDATE_REQ, p_lcb->id)) == NULL ) { L2CAP_TRACE_WARNING ("l2cu_send_peer_ble_par_req - no buffer"); return; @@ -2967,7 +2978,8 @@ void l2cu_send_peer_ble_par_rsp (tL2C_LCB *p_lcb, UINT16 reason, UINT8 rem_id) BT_HDR *p_buf; UINT8 *p; - if ((p_buf = l2cu_build_header (p_lcb, L2CAP_CMD_BLE_UPD_RSP_LEN, L2CAP_CMD_BLE_UPDATE_RSP, rem_id)) == NULL ) + if ((p_buf = l2cu_build_header (p_lcb, L2CAP_CMD_BLE_UPD_RSP_LEN, + L2CAP_CMD_BLE_UPDATE_RSP, rem_id)) == NULL ) { L2CAP_TRACE_WARNING ("l2cu_send_peer_ble_par_rsp - no buffer"); return; |