NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
ble_l2cap_coc_priv.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_L2CAP_COC_PRIV_
21#define H_L2CAP_COC_PRIV_
22
23#include <inttypes.h>
24#include "nimble/porting/nimble/include/syscfg/syscfg.h"
25#include "nimble/porting/nimble/include/os/queue.h"
26#include "nimble/porting/nimble/include/os/os_mbuf.h"
27#include "nimble/nimble/host/include/host/ble_l2cap.h"
28#include "ble_l2cap_sig_priv.h"
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#define BLE_L2CAP_COC_CID_START 0x0040
34#define BLE_L2CAP_COC_CID_END 0x007F
35
36struct ble_l2cap_chan;
37
38#define BLE_L2CAP_COC_FLAG_STALLED 0x01
39
40struct ble_l2cap_coc_endpoint {
41 struct os_mbuf *sdu;
42 uint16_t mtu;
43 uint16_t credits;
44 uint16_t data_offset;
45 uint8_t flags;
46};
47
48struct ble_l2cap_coc_srv {
49 STAILQ_ENTRY(ble_l2cap_coc_srv) next;
50 uint16_t psm;
51 uint16_t mtu;
52 ble_l2cap_event_fn *cb;
53 void *cb_arg;
54};
55
56#if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) != 0
57int ble_l2cap_coc_init(void);
58int ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu,
59 ble_l2cap_event_fn *cb, void *cb_arg);
60int ble_l2cap_coc_create_srv_chan(struct ble_hs_conn *conn, uint16_t psm,
61 struct ble_l2cap_chan **chan);
62struct ble_l2cap_chan * ble_l2cap_coc_chan_alloc(struct ble_hs_conn *conn,
63 uint16_t psm, uint16_t mtu,
64 struct os_mbuf *sdu_rx,
65 ble_l2cap_event_fn *cb,
66 void *cb_arg);
67void ble_l2cap_coc_cleanup_chan(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan);
68void ble_l2cap_coc_le_credits_update(uint16_t conn_handle, uint16_t dcid,
69 uint16_t credits);
70int ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan,
71 struct os_mbuf *sdu_rx);
72int ble_l2cap_coc_send(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_tx);
73void ble_l2cap_coc_set_new_mtu_mps(struct ble_l2cap_chan *chan, uint16_t mtu, uint16_t mps);
74#else
75static inline int
76ble_l2cap_coc_init(void) {
77 return 0;
78}
79
80static inline int
81ble_l2cap_coc_create_server(uint16_t psm, uint16_t mtu,
82 ble_l2cap_event_fn *cb, void *cb_arg) {
83 return BLE_HS_ENOTSUP;
84}
85
86static inline int
87ble_l2cap_coc_recv_ready(struct ble_l2cap_chan *chan,
88 struct os_mbuf *sdu_rx) {
89 return BLE_HS_ENOTSUP;
90}
91
92static inline void
93ble_l2cap_coc_cleanup_chan(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan) {
94}
95
96static inline int
97ble_l2cap_coc_send(struct ble_l2cap_chan *chan, struct os_mbuf *sdu_tx) {
98 return BLE_HS_ENOTSUP;
99}
100#endif
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* H_L2CAP_COC_PRIV_ */
Definition os_mbuf.h:86