ble_l2cap.h
Go to the documentation of this file.
1
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
61 typedef enum
62 {
63 REMOTE_USER_TERM_CON = 0x00,
64 LOCAL_USER_TERM_CON = 0x01,
65 } lecb_disconnect_reason_t;
66
79 typedef struct
80 {
81 uint16_t le_psm;
82 uint16_t local_cid;
83 uint16_t local_credits;
84 uint16_t mtu;
85 uint16_t mps;
86 } lecb_conn_req_t;
87
97 typedef struct
98 {
99 bool accept;
100 uint16_t peer_cid;
101 uint16_t local_cid;
102 uint16_t local_credits;
103 uint16_t mtu;
105 uint16_t mps;
107 } lecb_cfm_conn_t;
108
110 typedef struct
111 {
112 uint16_t local_cid;
113 uint16_t credits;
114 } lecb_add_credits_t;
115
122 typedef struct
123 {
124 uint16_t cid;
125 uint16_t credits;
126 uint16_t length;
127 uint8_t data[__ARRAY_EMPTY];
128 } lecb_sdu_t;
129
131 typedef struct
132 {
133 uint16_t le_psm;
134 uint16_t peer_cid;
135 uint16_t peer_mtu;
137 uint16_t peer_mps;
139 } lecb_conn_req_ind_t;
140
142 typedef struct
143 {
144 uint16_t le_psm;
145 uint16_t local_cid;
146 uint16_t local_credits;
147 uint16_t peer_credits;
148 uint16_t peer_mtu;
150 uint16_t peer_mps;
152 } lecb_conn_ind_t;
153
155 typedef struct
156 {
157 uint16_t local_cid;
158 uint8_t reason;
159 } lecb_disconn_ind_t;
160
162 typedef struct
163 {
164 uint16_t local_cid;
165 uint16_t peer_added_credits;
166 } lecb_add_credits_ind_t;
167
169 typedef struct
170 {
171 uint16_t cid;
172 uint16_t credits;
173 }lecb_sdu_send_evt_t;
174
176 typedef struct
177 {
178 void (*app_l2cap_lecb_conn_req_cb)(uint8_t conn_idx, lecb_conn_req_ind_t *p_conn_req);
179 void (*app_l2cap_lecb_conn_cb)(uint8_t conn_idx, uint8_t status, lecb_conn_ind_t *p_conn_ind);
180 void (*app_l2cap_lecb_add_credits_ind_cb)(uint8_t conn_idx, lecb_add_credits_ind_t *p_add_credits_ind);
181 void (*app_l2cap_lecb_disconn_cb)(uint8_t conn_idx, uint8_t status, lecb_disconn_ind_t *p_disconn_ind);
182 void (*app_l2cap_lecb_sdu_recv_cb)(uint8_t conn_idx, lecb_sdu_t *p_sdu);
183 void (*app_l2cap_lecb_sdu_send_cb)(uint8_t conn_idx, uint8_t status, lecb_sdu_send_evt_t *p_sdu_send_evt);
184 void (*app_l2cap_lecb_credit_add_cmp_cb)(uint8_t conn_idx, uint8_t status, uint16_t local_cid);
185 } l2cap_lecb_cb_fun_t;
186
187
206 uint16_t ble_l2cap_lecb_conn_create(uint8_t conn_idx, const lecb_conn_req_t *p_conn_req);
207
223 uint16_t ble_l2cap_lecb_conn_cfm(uint8_t conn_idx, const lecb_cfm_conn_t *p_cfm_conn);
224
238 uint16_t ble_l2cap_lecb_disconnect(uint8_t conn_idx, uint16_t local_cid);
239
253 uint16_t ble_l2cap_lecb_credits_add(uint8_t conn_idx, const lecb_add_credits_t *p_add_credits);
254
268 uint16_t ble_l2cap_lecb_sdu_send(uint8_t conn_idx, const lecb_sdu_t *p_sdu);
269
282 uint16_t ble_l2cap_lecb_cb_register(uint16_t le_psm, const l2cap_lecb_cb_fun_t *p_cb);
283
286 #endif
287
LOCAL_USER_TERM_CON
@ LOCAL_USER_TERM_CON
Definition: ble_l2cap.h:64
lecb_conn_req_ind_t::peer_cid
uint16_t peer_cid
Definition: ble_l2cap.h:134
lecb_add_credits_ind_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:164
__ARRAY_EMPTY
#define __ARRAY_EMPTY
Definition: gr55xx_sys_cfg.h:57
lecb_cfm_conn_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:102
lecb_cfm_conn_t::peer_cid
uint16_t peer_cid
Definition: ble_l2cap.h:100
lecb_conn_req_t::mps
uint16_t mps
Definition: ble_l2cap.h:85
lecb_add_credits_ind_t
LE credit based connection addition indication.
Definition: ble_l2cap.h:163
lecb_cfm_conn_t::mtu
uint16_t mtu
Definition: ble_l2cap.h:103
lecb_cfm_conn_t
LE credit based connection confirm parameter.
Definition: ble_l2cap.h:98
lecb_add_credits_t::credits
uint16_t credits
Definition: ble_l2cap.h:113
lecb_conn_req_t::mtu
uint16_t mtu
Definition: ble_l2cap.h:84
ble_l2cap_lecb_disconnect
uint16_t ble_l2cap_lecb_disconnect(uint8_t conn_idx, uint16_t local_cid)
Disconnect the LE credit based connection.
lecb_sdu_t
SDU packet parameter.
Definition: ble_l2cap.h:123
lecb_sdu_t::cid
uint16_t cid
Definition: ble_l2cap.h:124
lecb_cfm_conn_t::accept
bool accept
Definition: ble_l2cap.h:99
lecb_conn_ind_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:148
gr55xx_sys_cfg.h
Define the chip configuration.
lecb_conn_ind_t::peer_credits
uint16_t peer_credits
Definition: ble_l2cap.h:147
lecb_conn_req_ind_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:137
lecb_sdu_t::credits
uint16_t credits
Definition: ble_l2cap.h:125
REMOTE_USER_TERM_CON
@ REMOTE_USER_TERM_CON
Definition: ble_l2cap.h:63
lecb_conn_req_ind_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:133
lecb_disconn_ind_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:157
ble_error.h
File that contains error codes.
ble_l2cap_lecb_sdu_send
uint16_t ble_l2cap_lecb_sdu_send(uint8_t conn_idx, const lecb_sdu_t *p_sdu)
Send an SDU packet to the peer device.
lecb_conn_req_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:83
lecb_disconn_ind_t::reason
uint8_t reason
Definition: ble_l2cap.h:158
lecb_disconn_ind_t
LE credit based disconnect indication.
Definition: ble_l2cap.h:156
ble_l2cap_lecb_credits_add
uint16_t ble_l2cap_lecb_credits_add(uint8_t conn_idx, const 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...
lecb_add_credits_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:112
lecb_sdu_t::length
uint16_t length
Definition: ble_l2cap.h:126
lecb_conn_ind_t
LE credit based connection created indication.
Definition: ble_l2cap.h:143
lecb_add_credits_ind_t::peer_added_credits
uint16_t peer_added_credits
Definition: ble_l2cap.h:165
lecb_conn_ind_t::peer_mps
uint16_t peer_mps
Definition: ble_l2cap.h:150
lecb_conn_ind_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:144
lecb_sdu_send_evt_t::cid
uint16_t cid
Definition: ble_l2cap.h:171
lecb_conn_req_ind_t
Receive LE credit based connection request packet indication.
Definition: ble_l2cap.h:132
ble_l2cap_lecb_conn_cfm
uint16_t ble_l2cap_lecb_conn_cfm(uint8_t conn_idx, const 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_lecb_conn_create
uint16_t ble_l2cap_lecb_conn_create(uint8_t conn_idx, const lecb_conn_req_t *p_conn_req)
Create the LE credit based connection.
lecb_conn_ind_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:145
lecb_add_credits_t
LE flow control credit packet parameter.
Definition: ble_l2cap.h:111
ble_l2cap_lecb_cb_register
uint16_t ble_l2cap_lecb_cb_register(uint16_t le_psm, const l2cap_lecb_cb_fun_t *p_cb)
Register the callback for the PSM.
lecb_conn_req_t::le_psm
uint16_t le_psm
Definition: ble_l2cap.h:81
lecb_cfm_conn_t::mps
uint16_t mps
Definition: ble_l2cap.h:105
lecb_conn_ind_t::local_credits
uint16_t local_credits
Definition: ble_l2cap.h:146
l2cap_lecb_cb_fun_t
Callback registered by APP.
Definition: ble_l2cap.h:177
lecb_cfm_conn_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:101
lecb_sdu_send_evt_t
LE credit based SDU sending complete event.
Definition: ble_l2cap.h:170
lecb_disconnect_reason_t
lecb_disconnect_reason_t
LE credit based disconnection reasons.
Definition: ble_l2cap.h:62
lecb_sdu_send_evt_t::credits
uint16_t credits
Definition: ble_l2cap.h:172
lecb_conn_req_t
The parameter of LE credit based connection request packet sending.
Definition: ble_l2cap.h:80
lecb_conn_req_ind_t::peer_mtu
uint16_t peer_mtu
Definition: ble_l2cap.h:135
lecb_conn_req_t::local_cid
uint16_t local_cid
Definition: ble_l2cap.h:82