1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15# This file contains Emboss definitions of the protocol data units (PDUs) 16# associated with the Attribute Protocol (ATT) as defined in Vol 3 (Host), Part 17# F of the Bluetooth Core Specification. The Emboss compiler is used to generate 18# a C++ header from this file. 19 20import "pw_bluetooth/hci_data.emb" as hci 21import "pw_bluetooth/l2cap_frames.emb" as l2cap 22 23[$default byte_order: "LittleEndian"] 24[(cpp) namespace: "pw::bluetooth::emboss"] 25 26 27enum AttOpcode: 28 -- Attribute Protocol PDU Opcodes. See Core Spec v5.4, Vol 3, Part F, 29 -- Section 3.4.8 for a table with a summary of the Attribute Protocol PDUs. 30 [maximum_bits: 8] 31 ATT_ERROR_RSP = 0x01 32 ATT_EXCHANGE_MTU_REQ = 0x02 33 ATT_EXCHANGE_MTU_RSP = 0x03 34 ATT_FIND_INFORMATION_REQ = 0x04 35 ATT_FIND_INFORMATION_RSP = 0x05 36 ATT_FIND_BY_TYPE_VALUE_REQ = 0x06 37 ATT_FIND_BY_TYPE_VALUE_RSP = 0x07 38 ATT_READ_BY_TYPE_REQ = 0x08 39 ATT_READ_BY_TYPE_RSP = 0x09 40 ATT_READ_REQ = 0x0A 41 ATT_READ_RSP = 0x0B 42 ATT_READ_BLOB_REQ = 0x0C 43 ATT_READ_BLOB_RSP = 0x0D 44 ATT_READ_MULTIPLE_REQ = 0x0E 45 ATT_READ_MULTIPLE_RSP = 0x0F 46 ATT_READ_BY_GROUP_TYPE_REQ = 0x10 47 ATT_READ_BY_GROUP_TYPE_RSP = 0x11 48 ATT_WRITE_REQ = 0x12 49 ATT_WRITE_RSP = 0x13 50 ATT_WRITE_CMD = 0x52 51 ATT_PREPARE_WRITE_REQ = 0x16 52 ATT_PREPARE_WRITE_RSP = 0x17 53 ATT_EXECUTE_WRITE_REQ = 0x18 54 ATT_EXECUTE_WRITE_RSP = 0x19 55 ATT_READ_MULTIPLE_VARIABLE_REQ = 0x20 56 ATT_READ_MULTIPLE_VARIABLE_RSP = 0x21 57 ATT_MULTIPLE_HANDLE_VALUE_NTF = 0x23 58 ATT_HANDLE_VALUE_NTF = 0x1B 59 ATT_HANDLE_VALUE_IND = 0x1D 60 ATT_HANDLE_VALUE_CFM = 0x1E 61 ATT_SIGNED_WRITE_CMD = 0xD2 62 63# ===================== Attribute Protocol PDUs ============================= 64# Core Spec v5.4 Vol 3, Part F, Section 3.4 65# 66# Many of the ATT packet definitions are parameterized on the size(s) of the 67# attribute value(s) they carry. 68# 69# Attribute value type is opaque to ATT and defines the size of an attribute, 70# which may be fixed or variable. In most cases, attribute value size can be 71# inferred from the length of the packet that carries the PDU. In cases where 72# attribute size cannot be inferred (such as in packets carrying multiple 73# attribute values), the size is either reported in a packet field or assumed to 74# be mutually known by server & client. 75# 76# See Core Spec Vol 3, Part F, Section 3.2 for more details about attributes. 77 78# ============ 3.4.1 Error handling ============ 79 80 81# ============= 3.4.2 MTU exchange ============= 82 83 84# =========== 3.4.3 Find information =========== 85 86 87# ========== 3.4.4 Reading attributes ========== 88 89 90# ========== 3.4.5 Writing attributes ========== 91 92 93# ============ 3.4.6 Queued writes ============= 94 95 96# =========== 3.4.7 Server initiated =========== 97 98 99struct AttHandleValueNtf(attribute_size: UInt:16): 100 -- 3.4.7.1 ATT_HANDLE_VALUE_NTF 101 -- A server can send a notification of an attribute’s value at any time. 102 0 [+1] AttOpcode attribute_opcode 103 $next [+2] UInt attribute_handle 104 [requires: this > 0] 105 106 $next [+attribute_size] UInt:8[attribute_size] attribute_value 107