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