dragoon  4383
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ble_l2cap.h
1 /*
2  * Copyright (c) 2011 - 2017, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form, except as embedded into a Nordic
12  * Semiconductor ASA integrated circuit in a product or a software update for
13  * such product, must reproduce the above copyright notice, this list of
14  * conditions and the following disclaimer in the documentation and/or other
15  * materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * 4. This software, with or without modification, must only be used with a
22  * Nordic Semiconductor ASA integrated circuit.
23  *
24  * 5. Any software provided in binary form under this license must not be reverse
25  * engineered, decompiled, modified and/or disassembled.
26  *
27  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
28  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
30  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
33  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
45 #ifndef BLE_L2CAP_H__
46 #define BLE_L2CAP_H__
47 
48 #include "ble_types.h"
49 #include "ble_ranges.h"
50 #include "ble_err.h"
51 #include "nrf_svc.h"
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
84 {
90 };
91 
94 {
111 };
112 
119 #define BLE_L2CAP_CH_COUNT_MAX (64)
120 
122 #define BLE_L2CAP_MTU_MIN (23)
123 
125 #define BLE_L2CAP_MPS_MIN (23)
126 
128 #define BLE_L2CAP_CID_INVALID (0x0000)
129 
131 #define BLE_L2CAP_CREDITS_DEFAULT (1)
132 
135 #define BLE_L2CAP_CH_SETUP_REFUSED_SRC_LOCAL (0x01)
136 #define BLE_L2CAP_CH_SETUP_REFUSED_SRC_REMOTE (0x02)
141 #define BLE_L2CAP_CH_STATUS_CODE_SUCCESS (0x0000)
142 #define BLE_L2CAP_CH_STATUS_CODE_LE_PSM_NOT_SUPPORTED (0x0002)
143 #define BLE_L2CAP_CH_STATUS_CODE_NO_RESOURCES (0x0004)
144 #define BLE_L2CAP_CH_STATUS_CODE_INSUFF_AUTHENTICATION (0x0005)
145 #define BLE_L2CAP_CH_STATUS_CODE_INSUFF_AUTHORIZATION (0x0006)
146 #define BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC_KEY_SIZE (0x0007)
147 #define BLE_L2CAP_CH_STATUS_CODE_INSUFF_ENC (0x0008)
148 #define BLE_L2CAP_CH_STATUS_CODE_INVALID_SCID (0x0009)
149 #define BLE_L2CAP_CH_STATUS_CODE_SCID_ALLOCATED (0x000A)
150 #define BLE_L2CAP_CH_STATUS_CODE_UNACCEPTABLE_PARAMS (0x000B)
151 #define BLE_L2CAP_CH_STATUS_CODE_NOT_UNDERSTOOD (0x8000)
152 #define BLE_L2CAP_CH_STATUS_CODE_TIMEOUT (0xC000)
168 typedef struct
169 {
170  uint16_t rx_mps;
173  uint16_t tx_mps;
176  uint8_t rx_queue_size;
178  uint8_t tx_queue_size;
180  uint8_t ch_count;
186 
188 typedef struct
189 {
190  uint16_t rx_mtu;
193  uint16_t rx_mps;
197  ble_data_t sdu_buf;
203 
205 typedef struct
206 {
208  uint16_t le_psm;
210  uint16_t status;
214 
216 typedef struct
217 {
218  uint16_t tx_mtu;
220  uint16_t peer_mps;
222  uint16_t tx_mps;
226  uint16_t credits;
228 
230 typedef struct
231 {
233  uint16_t le_psm;
235 
237 typedef struct
238 {
239  uint8_t source;
240  uint16_t status;
242 
244 typedef struct
245 {
248 
250 typedef struct
251 {
252  ble_data_t sdu_buf;
257 
259 typedef struct
260 {
261  uint16_t credits;
263 
265 typedef struct
266 {
267  uint16_t sdu_len;
268  ble_data_t sdu_buf;
273 
275 typedef struct
276 {
279 
281 typedef struct
282 {
283  uint16_t conn_handle;
284  uint16_t local_cid;
286  union
287  {
295  } params;
297 
345 SVCALL(SD_BLE_L2CAP_CH_SETUP, uint32_t, sd_ble_l2cap_ch_setup(uint16_t conn_handle, uint16_t local_cid, ble_l2cap_ch_setup_params_t const *p_params));
346 
368 SVCALL(SD_BLE_L2CAP_CH_RELEASE, uint32_t, sd_ble_l2cap_ch_release(uint16_t conn_handle, uint16_t local_cid));
369 
402 SVCALL(SD_BLE_L2CAP_CH_RX, uint32_t, sd_ble_l2cap_ch_rx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf));
403 
447 SVCALL(SD_BLE_L2CAP_CH_TX, uint32_t, sd_ble_l2cap_ch_tx(uint16_t conn_handle, uint16_t local_cid, ble_data_t const *p_sdu_buf));
448 
486 SVCALL(SD_BLE_L2CAP_CH_FLOW_CONTROL, uint32_t, sd_ble_l2cap_ch_flow_control(uint16_t conn_handle, uint16_t local_cid, uint16_t credits, uint16_t *p_credits));
487 
490 #ifdef __cplusplus
491 }
492 #endif
493 #endif // BLE_L2CAP_H__
494