1 /* l2cap.h - Bluetooth tester headers */ 2 3 /* 4 * Copyright (c) 2015-2016 Intel Corporation 5 * Copyright (c) 2022 Codecoup 6 * 7 * SPDX-License-Identifier: Apache-2.0 8 */ 9 10 #include <stdint.h> 11 12 #include <zephyr/bluetooth/addr.h> 13 14 /* L2CAP Service */ 15 /* commands */ 16 #define BTP_L2CAP_READ_SUPPORTED_COMMANDS 0x01 17 struct btp_l2cap_read_supported_commands_rp { 18 uint8_t data[0]; 19 } __packed; 20 21 #define BTP_L2CAP_CONNECT_OPT_ECFC 0x01 22 #define BTP_L2CAP_CONNECT_OPT_HOLD_CREDIT 0x02 23 24 #define BTP_L2CAP_CONNECT 0x02 25 struct btp_l2cap_connect_cmd { 26 bt_addr_le_t address; 27 uint16_t psm; 28 uint16_t mtu; 29 uint8_t num; 30 uint8_t options; 31 } __packed; 32 struct btp_l2cap_connect_rp { 33 uint8_t num; 34 uint8_t chan_id[]; 35 } __packed; 36 37 #define BTP_L2CAP_DISCONNECT 0x03 38 struct btp_l2cap_disconnect_cmd { 39 uint8_t chan_id; 40 } __packed; 41 42 #define BTP_L2CAP_SEND_DATA 0x04 43 struct btp_l2cap_send_data_cmd { 44 uint8_t chan_id; 45 uint16_t data_len; 46 uint8_t data[]; 47 } __packed; 48 49 #define BTP_L2CAP_TRANSPORT_BREDR 0x00 50 #define BTP_L2CAP_TRANSPORT_LE 0x01 51 52 #define BTP_L2CAP_CONNECTION_RESPONSE_SUCCESS 0x00 53 #define BTP_L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHEN 0x01 54 #define BTP_L2CAP_CONNECTION_RESPONSE_INSUFF_AUTHOR 0x02 55 #define BTP_L2CAP_CONNECTION_RESPONSE_INSUFF_ENC_KEY 0x03 56 #define BTP_L2CAP_CONNECTION_RESPONSE_INSUFF_ENCRYPTION 0x04 57 #define BTP_L2CAP_CONNECTION_RESPONSE_INSUFF_SEC_AUTHEN 0x05 58 59 #define BTP_L2CAP_LISTEN 0x05 60 struct btp_l2cap_listen_cmd { 61 uint16_t psm; 62 uint8_t transport; 63 uint16_t mtu; 64 uint16_t response; 65 } __packed; 66 67 #define BTP_L2CAP_ACCEPT_CONNECTION 0x06 68 struct btp_l2cap_accept_connection_cmd { 69 uint8_t chan_id; 70 uint16_t result; 71 } __packed; 72 73 #define BTP_L2CAP_RECONFIGURE 0x07 74 struct btp_l2cap_reconfigure_cmd { 75 bt_addr_le_t address; 76 uint16_t mtu; 77 uint8_t num; 78 uint8_t chan_id[]; 79 } __packed; 80 81 #define BTP_L2CAP_CREDITS 0x08 82 struct btp_l2cap_credits_cmd { 83 uint8_t chan_id; 84 } __packed; 85 86 #define BTP_L2CAP_DISCONNECT_EATT_CHANS 0x09 87 struct btp_l2cap_disconnect_eatt_chans_cmd { 88 bt_addr_le_t address; 89 uint8_t count; 90 } __packed; 91 92 /* events */ 93 #define BTP_L2CAP_EV_CONNECTION_REQ 0x80 94 struct btp_l2cap_connection_req_ev { 95 uint8_t chan_id; 96 uint16_t psm; 97 bt_addr_le_t address; 98 } __packed; 99 100 #define BTP_L2CAP_EV_CONNECTED 0x81 101 struct btp_l2cap_connected_ev { 102 uint8_t chan_id; 103 uint16_t psm; 104 uint16_t mtu_remote; 105 uint16_t mps_remote; 106 uint16_t mtu_local; 107 uint16_t mps_local; 108 bt_addr_le_t address; 109 } __packed; 110 111 #define BTP_L2CAP_EV_DISCONNECTED 0x82 112 struct btp_l2cap_disconnected_ev { 113 uint16_t result; 114 uint8_t chan_id; 115 uint16_t psm; 116 bt_addr_le_t address; 117 } __packed; 118 119 #define BTP_L2CAP_EV_DATA_RECEIVED 0x83 120 struct btp_l2cap_data_received_ev { 121 uint8_t chan_id; 122 uint16_t data_length; 123 uint8_t data[]; 124 } __packed; 125 126 #define BTP_L2CAP_EV_RECONFIGURED 0x84 127 struct btp_l2cap_reconfigured_ev { 128 uint8_t chan_id; 129 uint16_t mtu_remote; 130 uint16_t mps_remote; 131 uint16_t mtu_local; 132 uint16_t mps_local; 133 } __packed; 134