1 /* 2 * l2cap.h 3 * 4 * Logical Link Control and Adaption Protocl (L2CAP) 5 * 6 * Created by Matthias Ringwald on 5/16/09. 7 */ 8 9 #pragma once 10 11 #include "hci.h" 12 #include "l2cap_signaling.h" 13 #include "utils.h" 14 #include "socket_connection.h" 15 16 #define L2CAP_SIG_ID_INVALID 0 17 18 typedef enum { 19 L2CAP_STATE_CLOSED, // no baseband 20 L2CAP_STATE_WAIT_CONNECT, // from application 21 L2CAP_STATE_WAIT_CONNECT_RSP, // from peer 22 L2CAP_STATE_WAIT_CONFIG_REQ_RSP, 23 L2CAP_STATE_WAIT_CONFIG_REQ, 24 L2CAP_STATE_OPEN, 25 L2CAP_STATE_WAIT_DISCONNECT, // from application 26 } L2CAP_STATE; 27 28 typedef struct { 29 // linked list - assert: first field 30 linked_item_t item; 31 32 L2CAP_STATE state; 33 uint8_t sig_id; 34 uint16_t source_cid; 35 uint16_t dest_cid; 36 bd_addr_t address; 37 uint16_t psm; 38 hci_con_handle_t handle; 39 connection_t *connection; 40 // uint16_t mtu_incoming; 41 // uint16_t mtu_outgoing; 42 // uint16_t flush_timeout_incoming; 43 // uint16_t flush_timeout_outgoing; 44 } l2cap_channel_t; 45 46 typedef struct { 47 48 } l2cap_service_t; 49 50 void l2cap_init(); 51 void l2cap_create_channel_internal(connection_t * connection, bd_addr_t address, uint16_t psm); 52 void l2cap_disconnect_internal(uint16_t source_cid, uint8_t reason); 53 void l2cap_send_internal(uint16_t source_cid, uint8_t *data, uint16_t len); 54 void l2cap_acl_handler( uint8_t *packet, uint16_t size ); 55 void l2cap_event_handler( uint8_t *packet, uint16_t size ); 56 57 58 void l2cap_emit_channel_opened(l2cap_channel_t *channel); 59 void l2cap_emit_channel_closed(l2cap_channel_t *channel); 60