• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * Copyright (c) 2022 Telink Semiconductor (Shanghai) Co., Ltd. ("TELINK")
3  * All rights reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************/
18 #ifndef L2CAP_H_
19 #define L2CAP_H_
20 
21 #define L2CAP_PSM_EATT 0x0027
22 #define L2CAP_PSM_ATT  0x001f
23 
24 typedef enum {
25     CONN_PARAM_UPDATE_ACCEPT = 0x0000,
26     CONN_PARAM_UPDATE_REJECT = 0x0001,
27 } conn_para_up_rsp;
28 
29 /**
30  * @brief		initialize l2cap buffer to reassembly link lay PDU to SDU in master
31  * @param[in]	*pMTU_m_rx_buff - the pointer of rx buffer in master
32  * @param[in]	mtu_m_rx_size   - the size of of rx buffer in master
33  * @param[in]	*pMTU_m_tx_buff - the pointer of tx buffer in master
34  * @param[in]	mtu_m_tx_size   - the size of of tx buffer in master
35  * @return		none.
36  */
37 void blc_l2cap_initAclConnMasterMtuBuffer(u8 *pMTU_m_rx_buff, u16 mtu_m_rx_size, u8 *pMTU_m_tx_buff,
38                                           u16 mtu_m_tx_size);
39 
40 /**
41  * @brief		initialize l2cap buffer to reassembly link lay PDU to SDU in master
42  * @param[in]	*pMTU_s_rx_buff - the pointer of rx buffer in slave
43  * @param[in]	mtu_s_rx_size   - the size of of rx buffer in slave
44  * @param[in]	*pMTU_s_tx_buff - the pointer of tx buffer in slave
45  * @param[in]	mtu_s_tx_size   - the size of of tx buffer in slave
46  * @return	none.
47  */
48 void blc_l2cap_initAclConnSlaveMtuBuffer(u8 *pMTU_s_rx_buff, u16 mtu_s_rx_size, u8 *pMTU_s_tx_buff, u16 mtu_s_tx_size);
49 
50 /**
51  * @brief		This function is used to set connect request parameter for updating connect parameter in slave
52  * @param[in]	connHandle - connection handle
53  * @param[in]	min_interval - connect interval minimum
54  * @param[in]	max_interval - connect interval maximum
55  * @param[in]	latency - connect latency
56  * @param[in]	timeout - connect timeout
57  * @return		0: success
58  * 				1: fail
59  */
60 u8 bls_l2cap_requestConnParamUpdate(u16 connHandle, u16 min_interval, u16 max_interval, u16 latency, u16 timeout);
61 
62 /**
63  * @brief		This function is used to send connect parameter update response in master
64  * @param[in]	connHandle - connection handle
65  * @param[in]	req_id - Request packet identifier
66  * @param[in]	result - connect parameter update result
67  * 				0x0001: CONN_PARAM_UPDATE_REJECT
68  * 				0x0000: CONN_PARAM_UPDATE_ACCEPT, need to call the API blm_l2cap_processConnParamUpdatePending() later
69  * @return		none.
70  */
71 void blc_l2cap_SendConnParamUpdateResponse(u16 connHandle, u8 req_id, conn_para_up_rsp result);
72 
73 /**
74  * @brief		This function is used to host set connect parameter process pending in master
75  * @param[in]	connHandle - connection handle
76  * @param[in]	min_interval - connect interval minimum
77  * @param[in]	max_interval - connect interval maximum
78  * @param[in]	latency - connect latency
79  * @param[in]	timeout - connect timeout
80  * @return		none.
81  */
82 void blm_l2cap_processConnParamUpdatePending(u16 connHandle, u16 min_interval, u16 max_interval, u16 latency,
83                                              u16 timeout);
84 
85 /**
86  * @brief		This function is used to set the minimal time for send connect parameter update request
87  *              after connect created
88  * @param[in]	connHandle - connection handle
89  * @param[in]	time_ms - the unit is millisecond
90  * @return		0: success
91  * 				1: fail
92  */
93 u8 bls_l2cap_setMinimalUpdateReqSendingTime_after_connCreate(u16 connHandle, int time_ms);
94 
95 /**
96  * @brief	This function is used to handler L2CAP data
97  * @param	connHandle - connection handle
98  * @param	*p - the pointer of l2cap data
99  * @return	0
100  */
101 int blc_l2cap_pktHandler(u16 connHandle, u8 *raw_pkt);
102 
103 #endif
104