1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,77 @@ |
1 |
+#ifndef _BT_L2CAP_H |
|
2 |
+#define _BT_L2CAP_H |
|
3 |
+ |
|
4 |
+ |
|
5 |
+#define L2CAP_CID_SIGNALING 0x0001 |
|
6 |
+#define L2CAP_CID_CONNECTIONLESS_CHANNEL 0x0002 |
|
7 |
+#define L2CAP_CID_ATTRIBUTE_PROTOCOL 0x0004 |
|
8 |
+#define L2CAP_CID_SIGNALING_LE 0x0005 |
|
9 |
+#define L2CAP_CID_SECURITY_MANAGER_PROTOCOL 0x0006 |
|
10 |
+ |
|
11 |
+typedef enum { |
|
12 |
+ COMMAND_REJECT = 1, |
|
13 |
+ CONNECTION_REQUEST, |
|
14 |
+ CONNECTION_RESPONSE, |
|
15 |
+ CONFIGURE_REQUEST, |
|
16 |
+ CONFIGURE_RESPONSE, |
|
17 |
+ DISCONNECTION_REQUEST, |
|
18 |
+ DISCONNECTION_RESPONSE, |
|
19 |
+ ECHO_REQUEST, |
|
20 |
+ ECHO_RESPONSE, |
|
21 |
+ INFORMATION_REQUEST, |
|
22 |
+ INFORMATION_RESPONSE |
|
23 |
+} L2CAP_SIGNALING_COMMANDS; |
|
24 |
+ |
|
25 |
+typedef enum { |
|
26 |
+ PB_FIRST_NON_FLUSH = 0, |
|
27 |
+ PB_CONTINUE_FRAGMENT, |
|
28 |
+ PB_FIRST_FLUSHABLE, |
|
29 |
+ PB_COMPLETE_PDU |
|
30 |
+} L2CAP_PB_FLAG; |
|
31 |
+ |
|
32 |
+typedef enum { |
|
33 |
+ BC_NO_BROADCAST = 0, |
|
34 |
+ BC_ACTIVE_SLAVE, |
|
35 |
+ BC_PARKED_SLAVE, |
|
36 |
+ BC_RESERVED |
|
37 |
+} L2CAP_BC_FLAG; |
|
38 |
+ |
|
39 |
+// Connection result values |
|
40 |
+#define BT_L2CAP_CON_RES_SUCCESS 0x0000 |
|
41 |
+#define BT_L2CAP_CON_RES_PENDING 0x0001 |
|
42 |
+#define BT_L2CAP_CON_RES_REFUSED_PSM 0x0002 |
|
43 |
+#define BT_L2CAP_CON_RES_REFUSED_SECURITY 0x0003 |
|
44 |
+#define BT_L2CAP_CON_RES_REFUSED_RSRC 0x0004 |
|
45 |
+ |
|
46 |
+#define BT_L2CAP_CON_STAT_NOINFO 0x0000 |
|
47 |
+#define BT_L2CAP_CON_STAT_AUTHEN_PENDING 0x0001 |
|
48 |
+#define BT_L2CAP_CON_STAT_AUTHOR_PENDING 0x0002 |
|
49 |
+ |
|
50 |
+typedef enum { |
|
51 |
+ BT_L2CAP_CON_IDLE = 0, |
|
52 |
+ BT_L2CAP_CON_CONNECTED |
|
53 |
+} bt_l2cap_con_state_t; |
|
54 |
+ |
|
55 |
+// describes the L2CAP connection |
|
56 |
+typedef struct { |
|
57 |
+ bt_l2cap_con_state_t cstate; |
|
58 |
+ |
|
59 |
+ uint16_t hci_handle; |
|
60 |
+ uint16_t PSM; // PSM of this connection |
|
61 |
+ |
|
62 |
+ uint16_t locCID; // our local CID |
|
63 |
+ uint16_t remCID; // remote host CID |
|
64 |
+ |
|
65 |
+ uint16_t locMTU; |
|
66 |
+ uint16_t remMTU; |
|
67 |
+} bt_l2cap_con_t; |
|
68 |
+ |
|
69 |
+void init_l2cap(void); |
|
70 |
+void bt_l2cap_proc_dyn_channel(const uint16_t channel, const uint16_t handle, const void *mdat, uint16_t mlen); |
|
71 |
+uint8_t bt_l2cap_get_connected(const uint16_t channel); |
|
72 |
+void bt_l2cap_send_channel(const uint16_t channel, const void *mdat, uint16_t mlen); |
|
73 |
+void bt_l2cap_proc_signalling(const uint16_t handle, unsigned char *mdat, uint16_t mlen); |
|
74 |
+void bt_l2cap_handle_connection_request(const uint16_t handle, const uint8_t ident, const uint16_t PSM, const uint16_t src_CID); |
|
75 |
+ |
|
76 |
+#endif |
|
77 |
+ |