Linux Audio
Check our new training course
Embedded Linux Audio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
/* att_internal.h - Attribute protocol handling */ /* * Copyright (c) 2015-2016 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #define BT_ATT_DEFAULT_LE_MTU 23 #if BT_L2CAP_RX_MTU < CONFIG_BT_L2CAP_TX_MTU #define BT_ATT_MTU BT_L2CAP_RX_MTU #else #define BT_ATT_MTU CONFIG_BT_L2CAP_TX_MTU #endif struct bt_att_hdr { u8_t code; } __packed; #define BT_ATT_OP_ERROR_RSP 0x01 struct bt_att_error_rsp { u8_t request; u16_t handle; u8_t error; } __packed; #define BT_ATT_OP_MTU_REQ 0x02 struct bt_att_exchange_mtu_req { u16_t mtu; } __packed; #define BT_ATT_OP_MTU_RSP 0x03 struct bt_att_exchange_mtu_rsp { u16_t mtu; } __packed; /* Find Information Request */ #define BT_ATT_OP_FIND_INFO_REQ 0x04 struct bt_att_find_info_req { u16_t start_handle; u16_t end_handle; } __packed; /* Format field values for BT_ATT_OP_FIND_INFO_RSP */ #define BT_ATT_INFO_16 0x01 #define BT_ATT_INFO_128 0x02 struct bt_att_info_16 { u16_t handle; u16_t uuid; } __packed; struct bt_att_info_128 { u16_t handle; u8_t uuid[16]; } __packed; /* Find Information Response */ #define BT_ATT_OP_FIND_INFO_RSP 0x05 struct bt_att_find_info_rsp { u8_t format; u8_t info[0]; } __packed; /* Find By Type Value Request */ #define BT_ATT_OP_FIND_TYPE_REQ 0x06 struct bt_att_find_type_req { u16_t start_handle; u16_t end_handle; u16_t type; u8_t value[0]; } __packed; struct bt_att_handle_group { u16_t start_handle; u16_t end_handle; } __packed; /* Find By Type Value Response */ #define BT_ATT_OP_FIND_TYPE_RSP 0x07 struct bt_att_find_type_rsp { struct bt_att_handle_group list[0]; } __packed; /* Read By Type Request */ #define BT_ATT_OP_READ_TYPE_REQ 0x08 struct bt_att_read_type_req { u16_t start_handle; u16_t end_handle; u8_t uuid[0]; } __packed; struct bt_att_data { u16_t handle; u8_t value[0]; } __packed; /* Read By Type Response */ #define BT_ATT_OP_READ_TYPE_RSP 0x09 struct bt_att_read_type_rsp { u8_t len; struct bt_att_data data[0]; } __packed; /* Read Request */ #define BT_ATT_OP_READ_REQ 0x0a struct bt_att_read_req { u16_t handle; } __packed; /* Read Response */ #define BT_ATT_OP_READ_RSP 0x0b struct bt_att_read_rsp { u8_t value[0]; } __packed; /* Read Blob Request */ #define BT_ATT_OP_READ_BLOB_REQ 0x0c struct bt_att_read_blob_req { u16_t handle; u16_t offset; } __packed; /* Read Blob Response */ #define BT_ATT_OP_READ_BLOB_RSP 0x0d struct bt_att_read_blob_rsp { u8_t value[0]; } __packed; /* Read Multiple Request */ #define BT_ATT_READ_MULT_MIN_LEN_REQ 0x04 #define BT_ATT_OP_READ_MULT_REQ 0x0e struct bt_att_read_mult_req { u16_t handles[0]; } __packed; /* Read Multiple Respose */ #define BT_ATT_OP_READ_MULT_RSP 0x0f struct bt_att_read_mult_rsp { u8_t value[0]; } __packed; /* Read by Group Type Request */ #define BT_ATT_OP_READ_GROUP_REQ 0x10 struct bt_att_read_group_req { u16_t start_handle; u16_t end_handle; u8_t uuid[0]; } __packed; struct bt_att_group_data { u16_t start_handle; u16_t end_handle; u8_t value[0]; } __packed; /* Read by Group Type Response */ #define BT_ATT_OP_READ_GROUP_RSP 0x11 struct bt_att_read_group_rsp { u8_t len; struct bt_att_group_data data[0]; } __packed; /* Write Request */ #define BT_ATT_OP_WRITE_REQ 0x12 struct bt_att_write_req { u16_t handle; u8_t value[0]; } __packed; /* Write Response */ #define BT_ATT_OP_WRITE_RSP 0x13 /* Prepare Write Request */ #define BT_ATT_OP_PREPARE_WRITE_REQ 0x16 struct bt_att_prepare_write_req { u16_t handle; u16_t offset; u8_t value[0]; } __packed; /* Prepare Write Respond */ #define BT_ATT_OP_PREPARE_WRITE_RSP 0x17 struct bt_att_prepare_write_rsp { u16_t handle; u16_t offset; u8_t value[0]; } __packed; /* Execute Write Request */ #define BT_ATT_FLAG_CANCEL 0x00 #define BT_ATT_FLAG_EXEC 0x01 #define BT_ATT_OP_EXEC_WRITE_REQ 0x18 struct bt_att_exec_write_req { u8_t flags; } __packed; /* Execute Write Response */ #define BT_ATT_OP_EXEC_WRITE_RSP 0x19 /* Handle Value Notification */ #define BT_ATT_OP_NOTIFY 0x1b struct bt_att_notify { u16_t handle; u8_t value[0]; } __packed; /* Handle Value Indication */ #define BT_ATT_OP_INDICATE 0x1d struct bt_att_indicate { u16_t handle; u8_t value[0]; } __packed; /* Handle Value Confirm */ #define BT_ATT_OP_CONFIRM 0x1e struct bt_att_signature { u8_t value[12]; } __packed; /* Write Command */ #define BT_ATT_OP_WRITE_CMD 0x52 struct bt_att_write_cmd { u16_t handle; u8_t value[0]; } __packed; /* Signed Write Command */ #define BT_ATT_OP_SIGNED_WRITE_CMD 0xd2 struct bt_att_signed_write_cmd { u16_t handle; u8_t value[0]; } __packed; void bt_att_init(void); u16_t bt_att_get_mtu(struct bt_conn *conn); struct net_buf *bt_att_create_pdu(struct bt_conn *conn, u8_t op, size_t len); /* Send ATT PDU over a connection */ int bt_att_send(struct bt_conn *conn, struct net_buf *buf); /* Send ATT Request over a connection */ int bt_att_req_send(struct bt_conn *conn, struct bt_att_req *req); /* Cancel ATT request */ void bt_att_req_cancel(struct bt_conn *conn, struct bt_att_req *req);