1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 /* 39 * l2cap.h 40 * 41 * Logical Link Control and Adaption Protocol (L2CAP) 42 * 43 * Created by Matthias Ringwald on 5/16/09. 44 */ 45 46 #ifndef __L2CAP_H 47 #define __L2CAP_H 48 49 #include "hci.h" 50 #include "l2cap_signaling.h" 51 #include "btstack_util.h" 52 #include "bluetooth.h" 53 54 #if defined __cplusplus 55 extern "C" { 56 #endif 57 58 // check L2CAP MTU 59 #ifdef ENABLE_CLASSIC 60 #if (L2CAP_HEADER_SIZE + L2CAP_MINIMAL_MTU) > HCI_ACL_PAYLOAD_SIZE 61 #error "HCI_ACL_PAYLOAD_SIZE too small for minimal L2CAP MTU of 48 bytes" 62 #endif 63 #endif 64 #ifdef ENABLE_BLE 65 #if (L2CAP_HEADER_SIZE + L2CAP_LE_DEFAULT_MTU) > HCI_ACL_PAYLOAD_SIZE 66 #error "HCI_ACL_PAYLOAD_SIZE too small for minimal L2CAP LE MTU of 23 bytes" 67 #endif 68 #endif 69 70 #define L2CAP_LE_AUTOMATIC_CREDITS 0xffff 71 72 // private structs 73 typedef enum { 74 L2CAP_STATE_CLOSED = 1, // no baseband 75 L2CAP_STATE_WILL_SEND_CREATE_CONNECTION, 76 L2CAP_STATE_WAIT_CONNECTION_COMPLETE, 77 L2CAP_STATE_WAIT_REMOTE_SUPPORTED_FEATURES, 78 L2CAP_STATE_WAIT_INCOMING_SECURITY_LEVEL_UPDATE, 79 L2CAP_STATE_WAIT_OUTGOING_SECURITY_LEVEL_UPDATE, 80 L2CAP_STATE_WAIT_INCOMING_EXTENDED_FEATURES, // only for Enhanced Retransmission Mode 81 L2CAP_STATE_WAIT_OUTGOING_EXTENDED_FEATURES, // only for Enhanced Retransmission Mode 82 L2CAP_STATE_WAIT_CLIENT_ACCEPT_OR_REJECT, 83 L2CAP_STATE_WAIT_CONNECT_RSP, // from peer 84 L2CAP_STATE_CONFIG, 85 L2CAP_STATE_OPEN, 86 L2CAP_STATE_WAIT_DISCONNECT, // from application 87 L2CAP_STATE_WILL_SEND_CONNECTION_REQUEST, 88 L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_INSUFFICIENT_SECURITY, 89 L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_DECLINE, 90 L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_ACCEPT, 91 L2CAP_STATE_WILL_SEND_DISCONNECT_REQUEST, 92 L2CAP_STATE_WILL_SEND_DISCONNECT_RESPONSE, 93 L2CAP_STATE_WILL_SEND_LE_CONNECTION_REQUEST, 94 L2CAP_STATE_WILL_SEND_LE_CONNECTION_RESPONSE_DECLINE, 95 L2CAP_STATE_WILL_SEND_LE_CONNECTION_RESPONSE_ACCEPT, 96 L2CAP_STATE_WAIT_LE_CONNECTION_RESPONSE, 97 L2CAP_STATE_EMIT_OPEN_FAILED_AND_DISCARD, 98 L2CAP_STATE_INVALID, 99 } L2CAP_STATE; 100 101 typedef enum { 102 L2CAP_CHANNEL_STATE_VAR_NONE = 0, 103 L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_REQ = 1 << 0, 104 L2CAP_CHANNEL_STATE_VAR_RCVD_CONF_RSP = 1 << 1, 105 L2CAP_CHANNEL_STATE_VAR_SEND_CONF_REQ = 1 << 2, 106 L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP = 1 << 3, 107 L2CAP_CHANNEL_STATE_VAR_SENT_CONF_REQ = 1 << 4, 108 L2CAP_CHANNEL_STATE_VAR_SENT_CONF_RSP = 1 << 5, 109 L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU = 1 << 6, // in CONF RSP, add MTU field 110 L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_CONT = 1 << 7, // in CONF RSP, set CONTINUE flag 111 L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_INVALID = 1 << 8, // in CONF RSP, send UNKNOWN OPTIONS 112 L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_REJECTED = 1 << 9, // in CONF RSP, send Unacceptable Parameters (ERTM) 113 L2CAP_CHANNEL_STATE_VAR_BASIC_FALLBACK_TRIED = 1 << 10, // set when ERTM was requested but we want only Basic mode (ERM) 114 L2CAP_CHANNEL_STATE_VAR_SEND_CMD_REJ_UNKNOWN = 1 << 11, // send CMD_REJ with reason unknown 115 L2CAP_CHANNEL_STATE_VAR_SEND_CONN_RESP_PEND = 1 << 12, // send Connection Respond with pending 116 L2CAP_CHANNEL_STATE_VAR_INCOMING = 1 << 15, // channel is incoming 117 } L2CAP_CHANNEL_STATE_VAR; 118 119 typedef struct { 120 l2cap_segmentation_and_reassembly_t sar; 121 uint16_t len; 122 uint8_t valid; 123 } l2cap_ertm_rx_packet_state_t; 124 125 typedef struct { 126 l2cap_segmentation_and_reassembly_t sar; 127 uint16_t len; 128 uint8_t tx_seq; 129 uint8_t retry_count; 130 uint8_t retransmission_requested; 131 } l2cap_ertm_tx_packet_state_t; 132 133 typedef struct { 134 // If not mandatory, the use of ERTM can be decided by the remote 135 uint8_t ertm_mandatory; 136 137 // Number of retransmissions that L2CAP is allowed to try before accepting that a packet and the channel is lost. 138 uint8_t max_transmit; 139 140 // time before retransmission of i-frame / Recommended : 2000 ms (ACL Flush timeout not used) 141 uint16_t retransmission_timeout_ms; 142 143 // time after withc s-frames are sent / Recommended: 12000 ms (ACL Flush timeout not used) 144 uint16_t monitor_timeout_ms; 145 146 // MTU for incoming SDUs 147 uint16_t local_mtu; 148 149 // Number of buffers for outgoing data 150 uint8_t num_tx_buffers; 151 152 // Number of packets that can be received out of order (-> our tx_window size) 153 uint8_t num_rx_buffers; 154 155 } l2cap_ertm_config_t; 156 157 // info regarding an actual connection 158 typedef struct { 159 // linked list - assert: first field 160 btstack_linked_item_t item; 161 162 // packet handler 163 btstack_packet_handler_t packet_handler; 164 165 // timer 166 btstack_timer_source_t rtx; // also used for ertx 167 168 L2CAP_STATE state; 169 L2CAP_CHANNEL_STATE_VAR state_var; 170 171 // info 172 hci_con_handle_t con_handle; 173 174 bd_addr_t address; 175 bd_addr_type_t address_type; 176 177 uint8_t remote_sig_id; // used by other side, needed for delayed response 178 uint8_t local_sig_id; // own signaling identifier 179 180 uint16_t local_cid; 181 uint16_t remote_cid; 182 183 uint16_t local_mtu; 184 uint16_t remote_mtu; 185 186 uint16_t flush_timeout; // default 0xffff 187 188 uint16_t psm; 189 190 gap_security_level_t required_security_level; 191 192 uint8_t reason; // used in decline internal 193 uint8_t waiting_for_can_send_now; 194 195 // LE Data Channels 196 197 // incoming SDU 198 uint8_t * receive_sdu_buffer; 199 uint16_t receive_sdu_len; 200 uint16_t receive_sdu_pos; 201 202 // outgoing SDU 203 uint8_t * send_sdu_buffer; 204 uint16_t send_sdu_len; 205 uint16_t send_sdu_pos; 206 207 // max PDU size 208 uint16_t remote_mps; 209 210 // credits for outgoing traffic 211 uint16_t credits_outgoing; 212 213 // number of packets remote will be granted 214 uint16_t new_credits_incoming; 215 216 // credits for incoming traffic 217 uint16_t credits_incoming; 218 219 // automatic credits incoming 220 uint16_t automatic_credits; 221 222 #ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE 223 224 // l2cap channel mode: basic or enhanced retransmission mode 225 l2cap_channel_mode_t mode; 226 227 // local mps = size of rx/tx buffers 228 uint16_t local_mps; 229 230 // retransmission timer 231 btstack_timer_source_t retransmission_timer; 232 233 // monitor timer 234 btstack_timer_source_t monitor_timer; 235 236 // local/remote config options 237 uint16_t local_retransmission_timeout_ms; 238 uint16_t local_monitor_timeout_ms; 239 240 uint16_t remote_retransmission_timeout_ms; 241 uint16_t remote_monitor_timeout_ms; 242 243 uint8_t remote_tx_window_size; 244 245 uint8_t local_max_transmit; 246 uint8_t remote_max_transmit; 247 248 // if ertm is not mandatory, allow fallback to L2CAP Basic Mode - flag 249 uint8_t ertm_mandatory; 250 251 // Frame Chech Sequence (crc16) is present in both directions 252 uint8_t fcs_option; 253 254 // sender: max num of stored outgoing frames 255 uint8_t num_tx_buffers; 256 257 // sender: number of unacknowledeged I-Frames - frames have been sent, but not acknowledged yet 258 uint8_t unacked_frames; 259 260 // sender: buffer index of oldest packet 261 uint8_t tx_read_index; 262 263 // sender: buffer index to store next tx packet 264 uint8_t tx_write_index; 265 266 // sender: buffer index of packet to send next 267 uint8_t tx_send_index; 268 269 // sender: next seq nr used for sending 270 uint8_t next_tx_seq; 271 272 // sender: selective retransmission requested 273 uint8_t srej_active; 274 275 276 // receiver: max num out-of-order packets // tx_window 277 uint8_t num_rx_buffers; 278 279 // receiver: buffer index of to store packet with delta = 1 280 uint8_t rx_store_index; 281 282 // receiver: value of tx_seq in next expected i-frame 283 uint8_t expected_tx_seq; 284 285 // receiver: request transmission with tx_seq = req_seq and ack up to and including req_seq 286 uint8_t req_seq; 287 288 // receiver: local busy condition 289 uint8_t local_busy; 290 291 // receiver: send RR frame with optional final flag set - flag 292 uint8_t send_supervisor_frame_receiver_ready; 293 294 // receiver: send RR frame with poll bit set 295 uint8_t send_supervisor_frame_receiver_ready_poll; 296 297 // receiver: send RNR frame - flag 298 uint8_t send_supervisor_frame_receiver_not_ready; 299 300 // receiver: send REJ frame - flag 301 uint8_t send_supervisor_frame_reject; 302 303 // receiver: send SREJ frame - flag 304 uint8_t send_supervisor_frame_selective_reject; 305 306 // set final bit after poll packet with poll bit was received 307 uint8_t set_final_bit_after_packet_with_poll_bit_set; 308 309 // receiver: meta data for out-of-order frames 310 l2cap_ertm_rx_packet_state_t * rx_packets_state; 311 312 // sender: retransmission state 313 l2cap_ertm_tx_packet_state_t * tx_packets_state; 314 315 // receiver: reassemly pos 316 uint16_t reassembly_pos; 317 318 // receiver: reassemly sdu length 319 uint16_t reassembly_sdu_length; 320 321 // receiver: eassembly buffer 322 uint8_t * reassembly_buffer; 323 324 // receiver: num_rx_buffers of size local_mps 325 uint8_t * rx_packets_data; 326 327 // sender: num_tx_buffers of size local_mps 328 uint8_t * tx_packets_data; 329 330 #endif 331 } l2cap_channel_t; 332 333 // info regarding potential connections 334 typedef struct { 335 // linked list - assert: first field 336 btstack_linked_item_t item; 337 338 // service id 339 uint16_t psm; 340 341 // incoming MTU 342 uint16_t mtu; 343 344 // internal connection 345 btstack_packet_handler_t packet_handler; 346 347 // required security level 348 gap_security_level_t required_security_level; 349 350 } l2cap_service_t; 351 352 353 typedef struct l2cap_signaling_response { 354 hci_con_handle_t handle; 355 uint8_t sig_id; 356 uint8_t code; 357 uint16_t cid; // source cid for CONNECTION REQUEST 358 uint16_t data; // infoType for INFORMATION REQUEST, result for CONNECTION REQUEST and COMMAND UNKNOWN 359 } l2cap_signaling_response_t; 360 361 362 void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint16_t channel_id); 363 int l2cap_can_send_fixed_channel_packet_now(hci_con_handle_t con_handle, uint16_t channel_id); 364 void l2cap_request_can_send_fix_channel_now_event(hci_con_handle_t con_handle, uint16_t channel_id); 365 int l2cap_send_connectionless(hci_con_handle_t con_handle, uint16_t cid, uint8_t *data, uint16_t len); 366 int l2cap_send_prepared_connectionless(hci_con_handle_t con_handle, uint16_t cid, uint16_t len); 367 368 // PTS Testing 369 int l2cap_send_echo_request(hci_con_handle_t con_handle, uint8_t *data, uint16_t len); 370 void l2cap_require_security_level_2_for_outgoing_sdp(void); 371 372 // Used by RFCOMM - similar to l2cap_can-send_packet_now but does not check if outgoing buffer is reserved 373 int l2cap_can_send_prepared_packet_now(uint16_t local_cid); 374 375 /* API_START */ 376 377 /** 378 * @brief Set up L2CAP and register L2CAP with HCI layer. 379 */ 380 void l2cap_init(void); 381 382 /** 383 * @brief Registers packet handler for LE Connection Parameter Update events 384 */ 385 void l2cap_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)); 386 387 /** 388 * @brief Get max MTU for Classic connections based on btstack configuration 389 */ 390 uint16_t l2cap_max_mtu(void); 391 392 /** 393 * @brief Get max MTU for LE connections based on btstack configuration 394 */ 395 uint16_t l2cap_max_le_mtu(void); 396 397 /** 398 * @brief Creates L2CAP channel to the PSM of a remote device with baseband address. A new baseband connection will be initiated if necessary. 399 * @param packet_handler 400 * @param address 401 * @param psm 402 * @param mtu 403 * @param local_cid 404 * @return status 405 */ 406 uint8_t l2cap_create_channel(btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, uint16_t mtu, uint16_t * out_local_cid); 407 408 /** 409 * @brief Creates L2CAP channel to the PSM of a remote device with baseband address using Enhanced Retransmission Mode. 410 * A new baseband connection will be initiated if necessary. 411 * @param packet_handler 412 * @param address 413 * @param psm 414 * @param ertm_config 415 * @param buffer to store reassembled rx packet, out-of-order packets and unacknowledged outgoing packets with their tretransmission timers 416 * @param size of buffer 417 * @param local_cid 418 * @return status 419 */ 420 uint8_t l2cap_create_ertm_channel(btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, 421 l2cap_ertm_config_t * ertm_contig, uint8_t * buffer, uint32_t size, uint16_t * out_local_cid); 422 423 /** 424 * @brief Disconnects L2CAP channel with given identifier. 425 */ 426 void l2cap_disconnect(uint16_t local_cid, uint8_t reason); 427 428 /** 429 * @brief Queries the maximal transfer unit (MTU) for L2CAP channel with given identifier. 430 */ 431 uint16_t l2cap_get_remote_mtu_for_local_cid(uint16_t local_cid); 432 433 /** 434 * @brief Sends L2CAP data packet to the channel with given identifier. 435 */ 436 int l2cap_send(uint16_t local_cid, uint8_t *data, uint16_t len); 437 438 /** 439 * @brief Registers L2CAP service with given PSM and MTU, and assigns a packet handler. 440 */ 441 uint8_t l2cap_register_service(btstack_packet_handler_t packet_handler, uint16_t psm, uint16_t mtu, gap_security_level_t security_level); 442 443 /** 444 * @brief Unregisters L2CAP service with given PSM. 445 */ 446 uint8_t l2cap_unregister_service(uint16_t psm); 447 448 /** 449 * @brief Accepts incoming L2CAP connection. 450 */ 451 void l2cap_accept_connection(uint16_t local_cid); 452 453 /** 454 * @brief Accepts incoming L2CAP connection for Enhanced Retransmission Mode 455 * @param local_cid 456 * @param ertm_config 457 * @param buffer to store reassembled rx packet, out-of-order packets and unacknowledged outgoing packets with their tretransmission timers 458 * @param size of buffer 459 * @return status 460 */ 461 uint8_t l2cap_accept_ertm_connection(uint16_t local_cid, l2cap_ertm_config_t * ertm_contig, uint8_t * buffer, uint32_t size); 462 463 /** 464 * @brief Deny incoming L2CAP connection. 465 */ 466 void l2cap_decline_connection(uint16_t local_cid); 467 468 /** 469 * @brief Check if outgoing buffer is available and that there's space on the Bluetooth module 470 */ 471 int l2cap_can_send_packet_now(uint16_t local_cid); 472 473 /** 474 * @brief Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible 475 * @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function 476 * so packet handler should be ready to handle it 477 * @param local_cid 478 */ 479 void l2cap_request_can_send_now_event(uint16_t local_cid); 480 481 /** 482 * @brief Reserve outgoing buffer 483 */ 484 int l2cap_reserve_packet_buffer(void); 485 486 /** 487 * @brief Get outgoing buffer and prepare data. 488 */ 489 uint8_t *l2cap_get_outgoing_buffer(void); 490 491 /** 492 * @brief Send L2CAP packet prepared in outgoing buffer to channel 493 */ 494 int l2cap_send_prepared(uint16_t local_cid, uint16_t len); 495 496 /** 497 * @brief Release outgoing buffer (only needed if l2cap_send_prepared is not called) 498 */ 499 void l2cap_release_packet_buffer(void); 500 501 502 // 503 // LE Connection Oriented Channels feature with the LE Credit Based Flow Control Mode == LE Data Channel 504 // 505 506 507 /** 508 * @brief Register L2CAP LE Data Channel service 509 * @note MTU and initial credits are specified in l2cap_le_accept_connection(..) call 510 * @param packet_handler 511 * @param psm 512 * @param security_level 513 */ 514 uint8_t l2cap_le_register_service(btstack_packet_handler_t packet_handler, uint16_t psm, gap_security_level_t security_level); 515 516 /** 517 * @brief Unregister L2CAP LE Data Channel service 518 * @param psm 519 */ 520 521 uint8_t l2cap_le_unregister_service(uint16_t psm); 522 523 /* 524 * @brief Accept incoming LE Data Channel connection 525 * @param local_cid L2CAP LE Data Channel Identifier 526 * @param receive_buffer buffer used for reassembly of L2CAP LE Information Frames into service data unit (SDU) with given MTU 527 * @param receive_buffer_size buffer size equals MTU 528 * @param initial_credits Number of initial credits provided to peer or L2CAP_LE_AUTOMATIC_CREDITS to enable automatic credits 529 */ 530 531 uint8_t l2cap_le_accept_connection(uint16_t local_cid, uint8_t * receive_sdu_buffer, uint16_t mtu, uint16_t initial_credits); 532 533 /** 534 * @brief Deny incoming LE Data Channel connection due to resource constraints 535 * @param local_cid L2CAP LE Data Channel Identifier 536 */ 537 538 uint8_t l2cap_le_decline_connection(uint16_t local_cid); 539 540 /** 541 * @brief Create LE Data Channel 542 * @param packet_handler Packet handler for this connection 543 * @param con_handle ACL-LE HCI Connction Handle 544 * @param psm Service PSM to connect to 545 * @param receive_buffer buffer used for reassembly of L2CAP LE Information Frames into service data unit (SDU) with given MTU 546 * @param receive_buffer_size buffer size equals MTU 547 * @param initial_credits Number of initial credits provided to peer or L2CAP_LE_AUTOMATIC_CREDITS to enable automatic credits 548 * @param security_level Minimum required security level 549 * @param out_local_cid L2CAP LE Channel Identifier is stored here 550 */ 551 uint8_t l2cap_le_create_channel(btstack_packet_handler_t packet_handler, hci_con_handle_t con_handle, 552 uint16_t psm, uint8_t * receive_sdu_buffer, uint16_t mtu, uint16_t initial_credits, gap_security_level_t security_level, 553 uint16_t * out_local_cid); 554 555 /** 556 * @brief Provide credtis for LE Data Channel 557 * @param local_cid L2CAP LE Data Channel Identifier 558 * @param credits Number additional credits for peer 559 */ 560 uint8_t l2cap_le_provide_credits(uint16_t cid, uint16_t credits); 561 562 /** 563 * @brief Check if packet can be scheduled for transmission 564 * @param local_cid L2CAP LE Data Channel Identifier 565 */ 566 int l2cap_le_can_send_now(uint16_t cid); 567 568 /** 569 * @brief Request emission of L2CAP_EVENT_LE_CAN_SEND_NOW as soon as possible 570 * @note L2CAP_EVENT_CAN_SEND_NOW might be emitted during call to this function 571 * so packet handler should be ready to handle it 572 * @param local_cid L2CAP LE Data Channel Identifier 573 */ 574 uint8_t l2cap_le_request_can_send_now_event(uint16_t cid); 575 576 /** 577 * @brief Send data via LE Data Channel 578 * @note Since data larger then the maximum PDU needs to be segmented into multiple PDUs, data needs to stay valid until ... event 579 * @param local_cid L2CAP LE Data Channel Identifier 580 * @param data data to send 581 * @param size data size 582 */ 583 uint8_t l2cap_le_send_data(uint16_t cid, uint8_t * data, uint16_t size); 584 585 /** 586 * @brief Disconnect from LE Data Channel 587 * @param local_cid L2CAP LE Data Channel Identifier 588 */ 589 uint8_t l2cap_le_disconnect(uint16_t cid); 590 591 /* API_END */ 592 593 /** 594 * @brief ERTM Set channel as busy. 595 * @note Can be cleared by l2cap_ertm_set_ready 596 * @param local_cid 597 */ 598 uint8_t l2cap_ertm_set_busy(uint16_t local_cid); 599 600 /** 601 * @brief ERTM Set channel as ready 602 * @note Used after l2cap_ertm_set_busy 603 * @param local_cid 604 */ 605 uint8_t l2cap_ertm_set_ready(uint16_t local_cid); 606 607 #if defined __cplusplus 608 } 609 #endif 610 611 #endif // __L2CAP_H 612