ble_l2cap.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file ble_l2cap.h
5  *
6  * @brief BLE L2CAP API
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  *****************************************************************************************
36  */
37 
38  /**
39  * @addtogroup BLE
40  * @{
41  */
42 
43  /**
44  @addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
45  @{
46  @brief Definitions and prototypes for the L2CAP interface.
47  */
48 
49 #ifndef __BLE_L2CAP_H__
50 #define __BLE_L2CAP_H__
51 
52 #include "ble_error.h"
53 #include "gr55xx_sys_cfg.h"
54 #include <stdint.h>
55 #include <stdbool.h>
56 
57 /**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
58  * @{ */
59 
60 /**@brief LE credit based disconnection reasons. */
61 typedef enum
62 {
63  BLE_L2CAP_REMOTE_USER_TERM_CON = 0x00, /**< Remote user terminates the connection. */
64  BLE_L2CAP_LOCAL_USER_TERM_CON = 0x01, /**< Local user terminates the connection. */
66 
67 /** @} */
68 
69 /** @addtogroup BLE_L2CAP_STRUCTURES Structures
70  * @{ */
71 /** @brief The parameter of LE credit based connection request packet sending.
72  * @note The le_psm should be registered by the peer device, otherwise the peer device will reject this request with result of LE_PSM not supported.
73  * @note The local_cid should be 0x0040-0x007F. If the local_cid is set to 0, the stack will assign it dynamically.
74  * @note The local_credit is required to be sure that at least one SDU can be received, otherwise the stack will use the default value: (MTU + MPS + 1) /MPS + 1.
75  * @note The MTU range is [23~max_mtu].
76  * @note The MPS range is [23~max_mps].
77  * @note About max_mtu and max_mps config, please see @ref ble_gap_l2cap_params_set.
78 */
79 typedef struct
80 {
81  uint16_t le_psm; /**< The le_psm number. */
82  uint16_t local_cid; /**< The local CID. */
83  uint16_t local_credits; /**< The local credits indicate the number of LE-frames that the peer device can send to the L2CAP layer entity sending the LE Credit Based Connection Request. */
84  uint16_t mtu; /**< The MTU field specifies the maximum SDU size (in octets) that the L2CAP layer entity sending the LE Credit Based Connection Request can receive on this channel. */
85  uint16_t mps; /**< The MPS field specifies the maximum payload size (in octets) that the L2CAP layer entity sending the LE Credit Based Connection Request is capable of receiving on this channel. */
87 
88 /** @brief LE credit based connection confirm parameter.
89  * @note The accept flag indicates whether the App accepts the LE Credit Based connection request.
90  * @note The peer_cid represents the channel endpoint on the peer device.
91  * @note The local_cid should be 0x0040-0x007F. If the local_cid is set to 0, the stack will assign it dynamically.
92  * @note The local_credits required to be sure that at least one SDU can be received, otherwise the stack will use the default value: (MTU + MPS + 1) /MPS + 1.
93  * @note The MTU range is [23~max_mtu].
94  * @note The MPS range is [23~max_mps].
95  * @note About the max_mtu and max_mps config, please see @ref ble_gap_l2cap_params_set.
96 */
97 typedef struct
98 {
99  bool accept; /**< Whether to accept the connection request. */
100  uint16_t peer_cid; /**< It represents the channel endpoint on the device sending the request and receiving the response. */
101  uint16_t local_cid; /**< Local CID. */
102  uint16_t local_credits; /**< It indicates the number of LE-frames that the peer device can send to the L2CAP layer entity sending the LE Credit Based Connection Respone. */
103  uint16_t mtu; /**< The MTU field specifies the maximum SDU size (in octets) that the L2CAP layer entity sending
104  the LE Credit Based Connection Request can receive on this channel. */
105  uint16_t mps; /**< The MPS field specifies the maximum payload size (in octets) that the L2CAP layer entity sending
106  the LE Credit Based Connection Request is capable of receiving on this channel. */
108 
109 /** @brief LE flow control credit packet parameter. */
110 typedef struct
111 {
112  uint16_t local_cid; /**< The local source channel ID. */
113  uint16_t credits; /**< Number of credits that the receiving device can increment. */
115 
116 /** @brief SDU packet parameter.
117  * @note The length should be less than peer_mtu when sending sdu packet.
118  * @note The credits is 0 if this packet is being sent, or it represents the number of credits consumed by this sdu if this packet is received.
119  * @note When the application receives a sdu, it should firstly copy this sdu packet before handling it, because the stack will free it after invoking the callback function.
120  * @note Similarly, the application should free the packet if it is malloced after invoking the function to send sdu packet.
121 */
122 typedef struct
123 {
124  uint16_t cid; /**< The local source channel. */
125  uint16_t credits; /**< The credits is 0 if this packet is being sent, otherwise it represents the number of credits consumed by the sdu. */
126  uint16_t length; /**< The lenght of data. */
127  uint8_t *data; /**< The data of this sdu packet. */
129 
130 /** @brief The parameter of LE enhanced credit based connection request packet sending.
131  * @note The le_psm should be registered by the peer device, otherwise the peer device will reject this request with result of LE_PSM not supported.
132  * @note The local_cid should be 0x0040-0x007F. If the local_cid is set to 0, the stack will assign it dynamically.
133  * @note The local_credit is required to be sure that at least one SDU can be received, otherwise the stack will use the default value: (MTU + MPS + 1) /MPS + 1.
134  * @note The MTU range is [64~max_mtu].
135  * @note The MPS range is [64~max_mps].
136  * @note About max_mtu and max_mps config, please see @ref ble_gap_l2cap_params_set.
137 */
138 typedef struct
139 {
140  uint16_t le_psm; /**< The le_psm number. */
141  uint16_t mtu; /**< The MTU field specifies the maximum SDU size (in octets) that the L2CAP layer entity sending the enhanced LE Credit Based Connection Request can receive on each of these channels. */
142  uint16_t mps; /**< The MPS field specifies the maximum payload size (in octets) that the L2CAP layer entity sending the enhanced LE Credit Based Connection Request is capable of receiving on these channels. */
143  uint16_t local_credits; /**< The local credits, it indicates the number of F-frames that the peer device can send to the L2CAP layer entity sending the LE Credit Based Connection Request. */
144  uint16_t chl_num; /**< It specifies the number of channel need to reconfigure, it shall not greater than 5. */
145  uint16_t local_cid[5]; /**< The Source CID is an array of 5 two octet values and represents the channel endpoints on the device sending the request. */
147 
148 /** @brief LE enhanced credit based connection confirm parameter.
149  * @note The accept flag indicates whether the App accepts the LE enhanced credit based connection request.
150  * @note The MTU range is [64~max_mtu].
151  * @note The MPS range is [64~max_mps].
152  * @note About the max_mtu and max_mps config, please see @ref ble_gap_l2cap_params_set.
153  * @note The local_credits required to be sure that at least one SDU can be received, otherwise the stack will use the default value: (MTU + MPS + 1) / MPS + 1.
154  * @note The chl_num indicates the number of channel.
155  * @note The peer_cid represents the channel endpoint list on the peer device.
156  * @note The local_cid represents the channel endpoint list on the local device, the value should be 0x0040-0x007F.
157 */
158 typedef struct {
159  bool accept; /**< Whether to accept the enhanced lecb connection request. */
160  uint16_t mtu; /**< The MTU field specifies the maximum SDU size (in octets) that the L2CAP layer entity sending the response can receive on these channels. */
161  uint16_t mps; /**< The MPS field specifies the maximum payload size (in octets) that the L2CAP layer entity sending the response is capable of receiving on these channels. */
162  uint16_t local_credits; /**< The local_credits field specifies the number of F-frames that the peer device can send to the L2CAP layer entity sending respone. */
163  uint16_t chl_num; /**< The chl_num field specifies the number of channel created. */
164  uint16_t peer_cid[5]; /**< The peer_cid is an array of 5 two octet values and represents the channel endpoints on the device sending the resquest. */
165  uint16_t local_cid[5]; /**< The local_cid is an array of 5 two octet values and represents the channel endpoints on the device sending the response. */
167 
168 /** @brief Reconfig LE enhanced credit based connection parameter. */
169 typedef struct
170 {
171  uint16_t local_mtu; /**< It indicates the maximum SDU size (in octets) that the L2CAP layer entity of local device can receive on these channels.
172  The local_mtu shall be greater than or equal to the greatest current MTU size of the channels. */
173  uint16_t local_mps; /**< It indicates the maximum payload size (in octets) that the L2CAP layer entity of local device can receive on these channels.
174  The local_mps can be greater than or less than or equal to the current MPS size of any channel.*/
175  uint16_t chl_num; /**< It specifies the number of channel need to reconfigure, it shall not greater than 5. */
176  uint16_t local_cid[5]; /**< It represents the local channel endpoints need to reconfigure. */
178 
179 /** @brief L2cap Connect Request event for @ref BLE_L2CAP_EVT_ENH_CONN_REQ. */
180 typedef struct
181 {
182  uint16_t le_psm; /**< Le_psm number that should be registered by local device. */
183  uint16_t peer_cid; /**< It represents the channel endpoint on the device sending the request and receiving the response. */
184  uint16_t peer_mtu; /**< It indicates the maximum SDU size (in octets) that the L2CAP layer entity sending the LE Credit
185  Based Connection Request can receive on this channel. */
186  uint16_t peer_mps; /**< It indicates the maximum payload size (in octets) that the L2CAP layer entity sending the LE Credit
187  Based Connection Request is capable of receiving on this channe. */
189 
190 /** @brief L2cap Connected Indicate event for @ref BLE_L2CAP_EVT_CONN_IND. */
191 typedef struct
192 {
193  uint16_t le_psm; /**< Le_psm number. */
194  uint16_t local_cid; /**< The local source channel ID. */
195  uint16_t local_credits; /**< It indicates the number of LE-frames that the local device can receive. */
196  uint16_t peer_credits; /**< It indicates the number of LE-frames that the peer device can receive. */
197  uint16_t peer_mtu; /**< It indicates the maximum SDU size (in octets) that the L2CAP layer entity sending the LE Credit
198  Based Connection Request can receive on this channel. */
199  uint16_t peer_mps; /**< It indicates the maximum payload size (in octets) that the L2CAP layer entity sending the LE Credit
200  Based Connection Request is capable of receiving on this channe. */
202 
203 /** @brief L2cap Credits Add Indicate event for @ref BLE_L2CAP_EVT_ADD_CREDITS_IND. */
204 typedef struct
205 {
206  uint16_t local_cid; /**< The local source channel ID. */
207  uint16_t peer_added_credits; /**< Represent number of credits the receiving device can increment. */
209 
210 /** @brief L2cap disconnect event for @ref BLE_L2CAP_EVT_DISCONNECTED. */
211 typedef struct
212 {
213  uint16_t local_cid; /**< The local source channel ID. */
214  ble_l2cap_lecb_disconn_reason_t reason; /**< The reason for disconnection, see @ref ble_l2cap_lecb_disconn_reason_t . */
216 
217 /**@brief L2cap SDU Receive event for @ref BLE_L2CAP_EVT_SDU_RECV. */
218 typedef struct
219 {
220  uint16_t cid; /**< The local source channel. */
221  uint16_t credits; /**< The credits is 0 if this packet is being sent, otherwise it represents the number of credits consumed by the sdu. */
222  uint16_t length; /**< The lenght of data. */
223  uint8_t *data; /**< The data of this sdu packet. */
225 
226 /**@brief L2cap SDU Send event for @ref BLE_L2CAP_EVT_SDU_SEND. */
227 typedef struct
228 {
229  uint16_t cid; /**< Channel ID that is the local CID. */
230  uint16_t credits; /**< Number of peer credit used. */
232 
233 /**@brief L2cap Credits Add Completed event for @ref BLE_L2CAP_EVT_ADD_CREDITS_CPLT. */
234 typedef struct
235 {
236  uint16_t local_cid; /**< Channel ID that is the local CID. */
238 
239 /** @brief L2cap Enhanced Connect Request event for @ref BLE_L2CAP_EVT_ENH_CONN_REQ. */
240 typedef struct {
241  uint16_t le_psm; /**< Le_psm number, it should be registered by local device. */
242  uint16_t peer_mtu; /**< It indicates the maximum SDU size (in octets) that the L2CAP layer entity sending the enhanced LE Credit Based Connection Request can receive on these channels. */
243  uint16_t peer_mps; /**< It indicates the maximum payload size (in octets) that the L2CAP layer entity sending the enhanced LE Credit Based Connection Request is capable of receiving on these channels.*/
244  uint16_t chl_num; /**< It indicates the number of channel created. */
245  uint16_t peer_cid[5]; /**< It represents the channel endpoints on the device sending the request and receiving the response. */
247 
248 /** @brief L2cap Enhanced Connected Indicate event for @ref BLE_L2CAP_EVT_ENH_CONN_IND. */
249 typedef struct
250 {
251  uint8_t status; /**< 0 success, otherwise failed. */
252  uint16_t le_psm; /**< Le_psm number. */
253  uint16_t peer_credits; /**< It indicates the number of F-frames that the peer device can. */
254  uint16_t peer_mtu; /**< It indicates the maximum SDU size (in octets) that the peer device can receive. */
255  uint16_t peer_mps; /**< It indicates the maximum payload size (in octets)that the peer device can receive. */
256  uint16_t local_credits; /**< It indicates the number of LE-frames that the local device can receive. */
257  uint16_t chl_num; /**< The chl_num field specifies the number of channel created. */
258  uint16_t local_cid[5]; /**< The local source channel id. */
260 
261 /** @brief L2cap Reconfig Enhanced credit Indicate event for @ref BLE_L2CAP_EVT_ENH_RECONFIG_IND. */
262 typedef struct
263 {
264  uint16_t peer_mtu; /**< It indicates the maximum SDU size (in octets) that the L2CAP layer entity of peer device can receive on these channels. */
265  uint16_t peer_mps; /**< It indicates the maximum payload size (in octets) that the L2CAP layer entity of peer device can receive on these channels. */
266  uint16_t chl_num; /**< It specifies the number of channel need to reconfigure, it shall not greater than 5. */
267  uint16_t local_cid[5]; /**< It represents the local channel endpoints need to reconfigure. */
269 
270 /**@brief BLE L2CAP event structure. */
271 typedef struct
272 {
273  uint8_t index; /**< Index of connection. */
274  union
275  {
276  ble_l2cap_evt_conn_req_t conn_req; /**< Link Encrypte Request event. */
277  ble_l2cap_evt_conn_ind_t conn_ind; /**< Link Encrypted event. */
278  ble_l2cap_evt_add_credits_ind_t add_credits_ind; /**< Key Press Notify event. */
279  ble_l2cap_evt_disconnect_t disconnected; /**< Key Missing event. */
280  ble_l2cap_evt_sdu_recv_t sdu_recv; /**< Link Encrypte Request event. */
281  ble_l2cap_evt_sdu_send_t sdu_send; /**< Link Encrypted event. */
282  ble_l2cap_evt_add_credits_cplt_t add_credits_cplt; /**< Key Press Notify event. */
283  ble_l2cap_evt_enh_conn_req_t enh_conn_req; /**< Key Missing event. */
284  ble_l2cap_evt_enh_conn_ind_t enh_conn_ind; /**< Key Missing event. */
286  } params; /**< The Parameters of l2cap event. */
287 } ble_l2cap_evt_t; /**< Event Parameters. */
288 /** @} */
289 
290 /** @addtogroup BLE_L2CAP_FUNCTIONS Functions
291  * @{ */
292 /**
293  ****************************************************************************************
294  * @brief Create the LE credit based connection.
295  * @note After the COC created, the l2cap event @ref BLE_L2CAP_EVT_CONN_REQ will be triggered.
296  *
297  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0, and the index will be increased one by one.
298  * @param[in] p_conn_req: Pointer to the LE Credit Based Connection Request structure.
299  *
300  * @retval ::SDK_SUCCESS: The LE Credit Based connection request is successfully set to the BLE stack.
301  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
302  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
303  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
304  ****************************************************************************************
305  */
306 uint16_t ble_l2cap_lecb_conn_create(uint8_t conn_idx, const ble_l2cap_lecb_conn_req_t *p_conn_req);
307 
308 /**
309  ****************************************************************************************
310  * @brief Confirm the LE credit based connection after receiving the connection request packet from the peer device.
311  *
312  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
313  * @param[in] p_cfm_conn: Pointer to the LE Credit Based Connection Confirm structure.
314  *
315  * @retval ::SDK_SUCCESS: The LE Credit Based connection confirmation is successfully set to the BLE stack.
316  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
317  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
318  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
319  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
320  ****************************************************************************************
321  */
322 uint16_t ble_l2cap_lecb_conn_cfm(uint8_t conn_idx, const ble_l2cap_lecb_cfm_conn_t *p_cfm_conn);
323 
324 /**
325  ****************************************************************************************
326  * @brief Disconnect the LE credit based connection.
327  *
328  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
329  * @param[in] local_cid: The local source channel ID.
330  *
331  * @retval ::SDK_SUCCESS: LE Credit Based disconnection request is successfully set to the BLE stack.
332  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
333  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
334  ****************************************************************************************
335  */
336 uint16_t ble_l2cap_lecb_disconnect(uint8_t conn_idx, uint16_t local_cid);
337 
338 /**
339  ****************************************************************************************
340  * @brief Send a LE Flow Control Credit packet when the device is capable of receiving additional LE-frames (for example after the device has processed the sdu).
341  *
342  * @param[in] conn_idx: ACL connection index, the first ACL connection index is 0, and increased one by one.
343  * @param[in] p_add_credits: Pointer to the LE Flow Control Credit structure.
344  *
345  * @retval ::SDK_SUCCESS: LE Flow Control Credit packet is successfully set to the BLE stack.
346  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
347  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
348  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
349  ****************************************************************************************
350  */
351 uint16_t ble_l2cap_lecb_credits_add(uint8_t conn_idx, const ble_l2cap_lecb_add_credits_t *p_add_credits);
352 
353 /**
354  ****************************************************************************************
355  * @brief Send an SDU packet to the peer device.
356  *
357  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
358  * @param[in] p_sdu: Pointer to the sdu packet structure.
359  *
360  * @retval ::SDK_SUCCESS: The sdu packet is successfully set to the BLE stack.
361  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
362  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
363  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
364  ****************************************************************************************
365  */
366 uint16_t ble_l2cap_lecb_sdu_send(uint8_t conn_idx, const ble_l2cap_lecb_sdu_t *p_sdu);
367 
368 /**
369  ****************************************************************************************
370  * @brief Register PSM.
371  *
372  * @param[in] le_psm: The le_psm number.
373  *
374  * @retval ::SDK_SUCCESS: The callback is successfully registered to the BLE stack.
375  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
376  * @retval ::SDK_ERR_INVALID_PSM_EXCEEDED_MAX_PSM_NUM: The maximum PSM number limit is exceeded.
377  ****************************************************************************************
378  */
379 uint16_t ble_l2cap_lecb_psm_register(uint16_t le_psm);
380 
381 /**
382  ****************************************************************************************
383  * @brief Create the LE enhanced credit based connection.
384  * @note After the COC created, the l2cap event @ref BLE_L2CAP_EVT_ENH_CONN_REQ will be triggered.
385  *
386  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0, and the index will be increased one by one.
387  * @param[in] p_enh_conn_req: Pointer to the LE enhanced Credit Based Connection Request structure.
388  *
389  * @retval ::SDK_SUCCESS: The LE Credit Based connection request is successfully set to the BLE stack.
390  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
391  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
392  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
393  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
394  ****************************************************************************************
395  */
396 uint16_t ble_l2cap_enh_lecb_conn_create(uint8_t conn_idx, const ble_l2cap_enh_lecb_conn_req_t *p_enh_conn_req);
397 
398 /**
399  ****************************************************************************************
400  * @brief Confirm the LE enhanced credit based connection after receiving the connection request packet from the peer device.
401  * @note This function should be invoked in the event @ref BLE_L2CAP_EVT_ENH_CONN_REQ.
402  * And after the COC created, the event @ref BLE_L2CAP_EVT_ENH_CONN_IND should be triggered.
403  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
404  * @param[in] p_enh_cfm_conn: Pointer to the LE enhanced credit based connection confirm structure.
405  *
406  * @retval ::SDK_SUCCESS: The LE credit based connection confirmation is successfully set to the BLE stack.
407  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
408  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
409  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
410  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
411  ****************************************************************************************
412  */
413 uint16_t ble_l2cap_enh_lecb_conn_cfm(uint8_t conn_idx, const ble_l2cap_enh_lecb_cfm_conn_t *p_enh_cfm_conn);
414 
415 /**
416  ****************************************************************************************
417  * @brief Reconfig the mtu and mps for the indicated channels.
418  * @note After the reconfig complete, the event @ref BLE_L2CAP_EVT_ENH_RECONFIG_CPLT should be triggered.
419  * @param[in] conn_idx: ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
420  * @param[in] p_enh_reconfig: Pointer to the LE enhanced credit based connection reconfig structure.
421  *
422  * @retval ::SDK_SUCCESS: The LE credit based connection confirmation is successfully set to the BLE stack.
423  * @retval ::SDK_ERR_POINTER_NULL: Invalid pointer supplied.
424  * @retval ::SDK_ERR_INVALID_CONN_IDX: Invalid connection index supplied.
425  * @retval ::SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
426  * @retval ::SDK_ERR_NO_RESOURCES: Not enough resources.
427  ****************************************************************************************
428  */
429 uint16_t ble_l2cap_enh_lecb_reconfig(uint8_t conn_idx, const ble_l2cap_enh_lecb_reconfig_t *p_enh_reconfig);
430 
431 /** @} */
432 
433 #endif
434 
435 /**
436  @}
437 */
438 /** @} */
ble_l2cap_evt_conn_req_t::peer_cid
uint16_t peer_cid
Definition: ble_l2cap.h:183
ble_l2cap_evt_conn_req_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:184
ble_l2cap_enh_lecb_conn_req_t::mtu
uint16_t mtu
Definition: ble_l2cap.h:141
ble_l2cap_evt_add_credits_ind_t::peer_added_credits
uint16_t peer_added_credits
Definition: ble_l2cap.h:207
ble_l2cap_evt_t::index
uint8_t index
Definition: ble_l2cap.h:273
ble_l2cap_lecb_cfm_conn_t::mtu
uint16_t mtu
Definition: ble_l2cap.h:103
ble_l2cap_lecb_conn_req_t
The parameter of LE credit based connection request packet sending.
Definition: ble_l2cap.h:80
ble_l2cap_enh_lecb_reconfig_t::local_mps
uint16_t local_mps
Definition: ble_l2cap.h:173
ble_l2cap_enh_lecb_reconfig_t
Reconfig LE enhanced credit based connection parameter.
Definition: ble_l2cap.h:170
ble_l2cap_evt_conn_req_t
L2cap Connect Request event for BLE_L2CAP_EVT_ENH_CONN_REQ.
Definition: ble_l2cap.h:181
ble_l2cap_enh_lecb_conn_req_t::mps
uint16_t mps
Definition: ble_l2cap.h:142
ble_l2cap_evt_conn_ind_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:197
ble_l2cap_lecb_conn_req_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:81
ble_l2cap_lecb_add_credits_t
LE flow control credit packet parameter.
Definition: ble_l2cap.h:111
ble_l2cap_evt_add_credits_cplt_t
L2cap Credits Add Completed event for BLE_L2CAP_EVT_ADD_CREDITS_CPLT.
Definition: ble_l2cap.h:235
ble_l2cap_lecb_cfm_conn_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:101
ble_l2cap_evt_conn_ind_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:195
BLE_L2CAP_REMOTE_USER_TERM_CON
@ BLE_L2CAP_REMOTE_USER_TERM_CON
Definition: ble_l2cap.h:63
ble_l2cap_enh_lecb_cfm_conn_t::accept
bool accept
Definition: ble_l2cap.h:159
ble_l2cap_evt_enh_conn_ind_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:256
ble_l2cap_evt_t::enh_conn_ind
ble_l2cap_evt_enh_conn_ind_t enh_conn_ind
Definition: ble_l2cap.h:284
ble_l2cap_lecb_sdu_t::cid
uint16_t cid
Definition: ble_l2cap.h:124
ble_l2cap_evt_sdu_recv_t::length
uint16_t length
Definition: ble_l2cap.h:222
ble_l2cap_evt_enh_conn_ind_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:255
ble_l2cap_lecb_psm_register
uint16_t ble_l2cap_lecb_psm_register(uint16_t le_psm)
Register PSM.
ble_l2cap_evt_conn_req_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:182
ble_l2cap_evt_conn_ind_t::peer_credits
uint16_t peer_credits
Definition: ble_l2cap.h:196
ble_l2cap_evt_enh_conn_req_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:241
ble_l2cap_evt_t::disconnected
ble_l2cap_evt_disconnect_t disconnected
Definition: ble_l2cap.h:279
ble_l2cap_evt_t
BLE L2CAP event structure.
Definition: ble_l2cap.h:272
ble_l2cap_evt_add_credits_ind_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:206
ble_l2cap_enh_lecb_conn_req_t::chl_num
uint16_t chl_num
Definition: ble_l2cap.h:144
ble_l2cap_lecb_sdu_t::length
uint16_t length
Definition: ble_l2cap.h:126
ble_l2cap_lecb_sdu_send
uint16_t ble_l2cap_lecb_sdu_send(uint8_t conn_idx, const ble_l2cap_lecb_sdu_t *p_sdu)
Send an SDU packet to the peer device.
ble_l2cap_evt_enh_conn_req_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:242
ble_l2cap_lecb_disconnect
uint16_t ble_l2cap_lecb_disconnect(uint8_t conn_idx, uint16_t local_cid)
Disconnect the LE credit based connection.
ble_l2cap_evt_sdu_recv_t::credits
uint16_t credits
Definition: ble_l2cap.h:221
ble_l2cap_evt_conn_ind_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:193
ble_l2cap_enh_lecb_conn_req_t
The parameter of LE enhanced credit based connection request packet sending.
Definition: ble_l2cap.h:139
ble_l2cap_lecb_conn_req_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:82
gr55xx_sys_cfg.h
Define the chip configuration.
ble_l2cap_enh_lecb_cfm_conn_t::mtu
uint16_t mtu
Definition: ble_l2cap.h:160
ble_l2cap_evt_enh_reconfig_ind_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:264
ble_l2cap_evt_enh_reconfig_ind_t::chl_num
uint16_t chl_num
Definition: ble_l2cap.h:266
ble_l2cap_enh_lecb_cfm_conn_t
LE enhanced credit based connection confirm parameter.
Definition: ble_l2cap.h:158
ble_l2cap_lecb_add_credits_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:112
ble_l2cap_evt_enh_conn_ind_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:252
ble_l2cap_enh_lecb_reconfig_t::chl_num
uint16_t chl_num
Definition: ble_l2cap.h:175
ble_l2cap_evt_t::sdu_send
ble_l2cap_evt_sdu_send_t sdu_send
Definition: ble_l2cap.h:281
ble_l2cap_enh_lecb_conn_create
uint16_t ble_l2cap_enh_lecb_conn_create(uint8_t conn_idx, const ble_l2cap_enh_lecb_conn_req_t *p_enh_conn_req)
Create the LE enhanced credit based connection.
BLE_L2CAP_LOCAL_USER_TERM_CON
@ BLE_L2CAP_LOCAL_USER_TERM_CON
Definition: ble_l2cap.h:64
ble_l2cap_lecb_conn_create
uint16_t ble_l2cap_lecb_conn_create(uint8_t conn_idx, const ble_l2cap_lecb_conn_req_t *p_conn_req)
Create the LE credit based connection.
ble_l2cap_evt_conn_ind_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:194
ble_l2cap_evt_enh_conn_ind_t::chl_num
uint16_t chl_num
Definition: ble_l2cap.h:257
ble_l2cap_evt_t::add_credits_cplt
ble_l2cap_evt_add_credits_cplt_t add_credits_cplt
Definition: ble_l2cap.h:282
ble_l2cap_evt_t::sdu_recv
ble_l2cap_evt_sdu_recv_t sdu_recv
Definition: ble_l2cap.h:280
ble_error.h
File that contains error codes.
ble_l2cap_evt_sdu_send_t
L2cap SDU Send event for BLE_L2CAP_EVT_SDU_SEND.
Definition: ble_l2cap.h:228
ble_l2cap_lecb_add_credits_t::credits
uint16_t credits
Definition: ble_l2cap.h:113
ble_l2cap_evt_sdu_recv_t::cid
uint16_t cid
Definition: ble_l2cap.h:220
ble_l2cap_lecb_disconn_reason_t
ble_l2cap_lecb_disconn_reason_t
LE credit based disconnection reasons.
Definition: ble_l2cap.h:62
ble_l2cap_evt_enh_conn_ind_t
L2cap Enhanced Connected Indicate event for BLE_L2CAP_EVT_ENH_CONN_IND.
Definition: ble_l2cap.h:250
ble_l2cap_evt_t::enh_reconfig_ind
ble_l2cap_evt_enh_reconfig_ind_t enh_reconfig_ind
Definition: ble_l2cap.h:285
ble_l2cap_evt_enh_conn_ind_t::peer_credits
uint16_t peer_credits
Definition: ble_l2cap.h:253
ble_l2cap_evt_enh_reconfig_ind_t
L2cap Reconfig Enhanced credit Indicate event for BLE_L2CAP_EVT_ENH_RECONFIG_IND.
Definition: ble_l2cap.h:263
ble_l2cap_enh_lecb_cfm_conn_t::mps
uint16_t mps
Definition: ble_l2cap.h:161
ble_l2cap_evt_t::enh_conn_req
ble_l2cap_evt_enh_conn_req_t enh_conn_req
Definition: ble_l2cap.h:283
ble_l2cap_lecb_cfm_conn_t::accept
bool accept
Definition: ble_l2cap.h:99
ble_l2cap_evt_add_credits_ind_t
L2cap Credits Add Indicate event for BLE_L2CAP_EVT_ADD_CREDITS_IND.
Definition: ble_l2cap.h:205
ble_l2cap_enh_lecb_cfm_conn_t::chl_num
uint16_t chl_num
Definition: ble_l2cap.h:163
ble_l2cap_lecb_conn_cfm
uint16_t ble_l2cap_lecb_conn_cfm(uint8_t conn_idx, const ble_l2cap_lecb_cfm_conn_t *p_cfm_conn)
Confirm the LE credit based connection after receiving the connection request packet from the peer de...
ble_l2cap_evt_t::add_credits_ind
ble_l2cap_evt_add_credits_ind_t add_credits_ind
Definition: ble_l2cap.h:278
ble_l2cap_evt_add_credits_cplt_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:236
ble_l2cap_lecb_cfm_conn_t::peer_cid
uint16_t peer_cid
Definition: ble_l2cap.h:100
ble_l2cap_evt_enh_conn_ind_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:254
ble_l2cap_enh_lecb_reconfig
uint16_t ble_l2cap_enh_lecb_reconfig(uint8_t conn_idx, const ble_l2cap_enh_lecb_reconfig_t *p_enh_reconfig)
Reconfig the mtu and mps for the indicated channels.
ble_l2cap_evt_sdu_recv_t::data
uint8_t * data
Definition: ble_l2cap.h:223
ble_l2cap_evt_conn_ind_t
L2cap Connected Indicate event for BLE_L2CAP_EVT_CONN_IND.
Definition: ble_l2cap.h:192
ble_l2cap_evt_enh_conn_req_t
L2cap Enhanced Connect Request event for BLE_L2CAP_EVT_ENH_CONN_REQ.
Definition: ble_l2cap.h:240
ble_l2cap_lecb_sdu_t
SDU packet parameter.
Definition: ble_l2cap.h:123
ble_l2cap_enh_lecb_reconfig_t::local_mtu
uint16_t local_mtu
Definition: ble_l2cap.h:171
ble_l2cap_evt_t::conn_req
ble_l2cap_evt_conn_req_t conn_req
Definition: ble_l2cap.h:276
ble_l2cap_evt_t::conn_ind
ble_l2cap_evt_conn_ind_t conn_ind
Definition: ble_l2cap.h:277
ble_l2cap_enh_lecb_conn_req_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:140
ble_l2cap_lecb_credits_add
uint16_t ble_l2cap_lecb_credits_add(uint8_t conn_idx, const ble_l2cap_lecb_add_credits_t *p_add_credits)
Send a LE Flow Control Credit packet when the device is capable of receiving additional LE-frames (fo...
ble_l2cap_evt_enh_conn_req_t::chl_num
uint16_t chl_num
Definition: ble_l2cap.h:244
ble_l2cap_lecb_cfm_conn_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:102
ble_l2cap_evt_enh_reconfig_ind_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:265
ble_l2cap_lecb_sdu_t::credits
uint16_t credits
Definition: ble_l2cap.h:125
ble_l2cap_enh_lecb_conn_cfm
uint16_t ble_l2cap_enh_lecb_conn_cfm(uint8_t conn_idx, const ble_l2cap_enh_lecb_cfm_conn_t *p_enh_cfm_conn)
Confirm the LE enhanced credit based connection after receiving the connection request packet from th...
ble_l2cap_lecb_conn_req_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:83
ble_l2cap_lecb_cfm_conn_t::mps
uint16_t mps
Definition: ble_l2cap.h:105
ble_l2cap_evt_sdu_recv_t
L2cap SDU Receive event for BLE_L2CAP_EVT_SDU_RECV.
Definition: ble_l2cap.h:219
ble_l2cap_lecb_cfm_conn_t
LE credit based connection confirm parameter.
Definition: ble_l2cap.h:98
ble_l2cap_evt_enh_conn_req_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:243
ble_l2cap_lecb_conn_req_t::mtu
uint16_t mtu
Definition: ble_l2cap.h:84
ble_l2cap_evt_disconnect_t
L2cap disconnect event for BLE_L2CAP_EVT_DISCONNECTED.
Definition: ble_l2cap.h:212
ble_l2cap_lecb_conn_req_t::mps
uint16_t mps
Definition: ble_l2cap.h:85
ble_l2cap_evt_conn_ind_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:199
ble_l2cap_evt_disconnect_t::reason
ble_l2cap_lecb_disconn_reason_t reason
Definition: ble_l2cap.h:214
ble_l2cap_evt_disconnect_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:213
ble_l2cap_evt_sdu_send_t::cid
uint16_t cid
Definition: ble_l2cap.h:229
ble_l2cap_enh_lecb_cfm_conn_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:162
ble_l2cap_evt_sdu_send_t::credits
uint16_t credits
Definition: ble_l2cap.h:230
ble_l2cap_lecb_sdu_t::data
uint8_t * data
Definition: ble_l2cap.h:127
ble_l2cap_evt_enh_conn_ind_t::status
uint8_t status
Definition: ble_l2cap.h:251
ble_l2cap_enh_lecb_conn_req_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:143
ble_l2cap_evt_conn_req_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:186