circuitpython/devices/ble_hci/common-hal/_bleio/hci_include/att_internal.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

274 lines
6.2 KiB
C
Raw Normal View History

2020-07-23 18:54:26 -04:00
// CircuitPython: Adapted from Zephyr include file.
/* att_internal.h - Attribute protocol handling */
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
2020-07-23 18:54:26 -04:00
#include <stdbool.h>
// for __packed
#include <sys/cdefs.h>
2020-07-23 18:54:26 -04:00
2021-03-15 09:57:36 -04:00
#define BT_EATT_PSM 0x27
#define BT_ATT_DEFAULT_LE_MTU 23
#define BT_ATT_TIMEOUT K_SECONDS(30)
2020-07-23 18:54:26 -04:00
2021-03-15 09:57:36 -04:00
// FIX #if BT_L2CAP_RX_MTU < CONFIG_BT_L2CAP_TX_MTU
2020-07-23 18:54:26 -04:00
// #define BT_ATT_MTU BT_L2CAP_RX_MTU
// #else
// #define BT_ATT_MTU CONFIG_BT_L2CAP_TX_MTU
// #endif
struct bt_att_hdr {
2021-03-15 09:57:36 -04:00
uint8_t code;
2020-07-23 18:54:26 -04:00
} __packed;
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_ERROR_RSP 0x01
2020-07-23 18:54:26 -04:00
struct bt_att_error_rsp {
2021-03-15 09:57:36 -04:00
uint8_t request;
uint16_t handle;
uint8_t error;
2020-07-23 18:54:26 -04:00
} __packed;
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_MTU_REQ 0x02
2020-07-23 18:54:26 -04:00
struct bt_att_exchange_mtu_req {
2021-03-15 09:57:36 -04:00
uint16_t mtu;
2020-07-23 18:54:26 -04:00
} __packed;
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_MTU_RSP 0x03
2020-07-23 18:54:26 -04:00
struct bt_att_exchange_mtu_rsp {
2021-03-15 09:57:36 -04:00
uint16_t mtu;
2020-07-23 18:54:26 -04:00
} __packed;
/* Find Information Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_FIND_INFO_REQ 0x04
2020-07-23 18:54:26 -04:00
struct bt_att_find_info_req {
2021-03-15 09:57:36 -04:00
uint16_t start_handle;
uint16_t end_handle;
2020-07-23 18:54:26 -04:00
} __packed;
/* Format field values for BT_ATT_OP_FIND_INFO_RSP */
2021-03-15 09:57:36 -04:00
#define BT_ATT_INFO_16 0x01
#define BT_ATT_INFO_128 0x02
2020-07-23 18:54:26 -04:00
struct bt_att_info_16 {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint16_t uuid;
2020-07-23 18:54:26 -04:00
} __packed;
struct bt_att_info_128 {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t uuid[16];
2020-07-23 18:54:26 -04:00
} __packed;
/* Find Information Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_FIND_INFO_RSP 0x05
2020-07-23 18:54:26 -04:00
struct bt_att_find_info_rsp {
2021-03-15 09:57:36 -04:00
uint8_t format;
uint8_t info[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Find By Type Value Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_FIND_TYPE_REQ 0x06
2020-07-23 18:54:26 -04:00
struct bt_att_find_type_req {
2021-03-15 09:57:36 -04:00
uint16_t start_handle;
uint16_t end_handle;
uint16_t type;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
struct bt_att_handle_group {
2021-03-15 09:57:36 -04:00
uint16_t start_handle;
uint16_t end_handle;
2020-07-23 18:54:26 -04:00
} __packed;
/* Find By Type Value Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_FIND_TYPE_RSP 0x07
2020-07-23 18:54:26 -04:00
struct bt_att_find_type_rsp {
2021-03-15 09:57:36 -04:00
uint8_t _dummy[0];
struct bt_att_handle_group list[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read By Type Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_TYPE_REQ 0x08
2020-07-23 18:54:26 -04:00
struct bt_att_read_type_req {
2021-03-15 09:57:36 -04:00
uint16_t start_handle;
uint16_t end_handle;
uint8_t uuid[];
2020-07-23 18:54:26 -04:00
} __packed;
struct bt_att_data {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read By Type Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_TYPE_RSP 0x09
2020-07-23 18:54:26 -04:00
struct bt_att_read_type_rsp {
2021-03-15 09:57:36 -04:00
uint8_t len;
struct bt_att_data data[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_REQ 0x0a
2020-07-23 18:54:26 -04:00
struct bt_att_read_req {
2021-03-15 09:57:36 -04:00
uint16_t handle;
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_RSP 0x0b
2020-07-23 18:54:26 -04:00
struct bt_att_read_rsp {
2021-03-15 09:57:36 -04:00
uint8_t _dummy[0];
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Blob Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_BLOB_REQ 0x0c
2020-07-23 18:54:26 -04:00
struct bt_att_read_blob_req {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint16_t offset;
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Blob Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_BLOB_RSP 0x0d
2020-07-23 18:54:26 -04:00
struct bt_att_read_blob_rsp {
2021-03-15 09:57:36 -04:00
uint8_t _dummy[0];
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Multiple Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_READ_MULT_MIN_LEN_REQ 0x04
2020-07-23 18:54:26 -04:00
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_MULT_REQ 0x0e
2020-07-23 18:54:26 -04:00
struct bt_att_read_mult_req {
2021-03-15 09:57:36 -04:00
uint8_t _dummy[0];
uint16_t handles[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Multiple Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_MULT_RSP 0x0f
2020-07-23 18:54:26 -04:00
struct bt_att_read_mult_rsp {
2021-03-15 09:57:36 -04:00
uint8_t _dummy[0];
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read by Group Type Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_GROUP_REQ 0x10
2020-07-23 18:54:26 -04:00
struct bt_att_read_group_req {
2021-03-15 09:57:36 -04:00
uint16_t start_handle;
uint16_t end_handle;
uint8_t uuid[];
2020-07-23 18:54:26 -04:00
} __packed;
struct bt_att_group_data {
2021-03-15 09:57:36 -04:00
uint16_t start_handle;
uint16_t end_handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read by Group Type Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_GROUP_RSP 0x11
2020-07-23 18:54:26 -04:00
struct bt_att_read_group_rsp {
2021-03-15 09:57:36 -04:00
uint8_t len;
struct bt_att_group_data data[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Write Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_WRITE_REQ 0x12
2020-07-23 18:54:26 -04:00
struct bt_att_write_req {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Write Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_WRITE_RSP 0x13
2020-07-23 18:54:26 -04:00
/* Prepare Write Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_PREPARE_WRITE_REQ 0x16
2020-07-23 18:54:26 -04:00
struct bt_att_prepare_write_req {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint16_t offset;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Prepare Write Respond */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_PREPARE_WRITE_RSP 0x17
2020-07-23 18:54:26 -04:00
struct bt_att_prepare_write_rsp {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint16_t offset;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Execute Write Request */
2021-03-15 09:57:36 -04:00
#define BT_ATT_FLAG_CANCEL 0x00
#define BT_ATT_FLAG_EXEC 0x01
2020-07-23 18:54:26 -04:00
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_EXEC_WRITE_REQ 0x18
2020-07-23 18:54:26 -04:00
struct bt_att_exec_write_req {
2021-03-15 09:57:36 -04:00
uint8_t flags;
2020-07-23 18:54:26 -04:00
} __packed;
/* Execute Write Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_EXEC_WRITE_RSP 0x19
2020-07-23 18:54:26 -04:00
/* Handle Value Notification */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_NOTIFY 0x1b
2020-07-23 18:54:26 -04:00
struct bt_att_notify {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Handle Value Indication */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_INDICATE 0x1d
2020-07-23 18:54:26 -04:00
struct bt_att_indicate {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Handle Value Confirm */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_CONFIRM 0x1e
2020-07-23 18:54:26 -04:00
struct bt_att_signature {
2021-03-15 09:57:36 -04:00
uint8_t value[12];
2020-07-23 18:54:26 -04:00
} __packed;
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_MULT_VL_REQ 0x20
2020-07-23 18:54:26 -04:00
struct bt_att_read_mult_vl_req {
2021-03-15 09:57:36 -04:00
uint8_t _dummy[0];
uint16_t handles[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Read Multiple Response */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_READ_MULT_VL_RSP 0x21
2020-07-23 18:54:26 -04:00
struct bt_att_read_mult_vl_rsp {
2021-03-15 09:57:36 -04:00
uint16_t len;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Handle Multiple Value Notification */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_NOTIFY_MULT 0x23
2020-07-23 18:54:26 -04:00
struct bt_att_notify_mult {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint16_t len;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Write Command */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_WRITE_CMD 0x52
2020-07-23 18:54:26 -04:00
struct bt_att_write_cmd {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;
/* Signed Write Command */
2021-03-15 09:57:36 -04:00
#define BT_ATT_OP_SIGNED_WRITE_CMD 0xd2
2020-07-23 18:54:26 -04:00
struct bt_att_signed_write_cmd {
2021-03-15 09:57:36 -04:00
uint16_t handle;
uint8_t value[];
2020-07-23 18:54:26 -04:00
} __packed;