att

package
v0.783.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package att decodes the Bluetooth Attribute Protocol (ATT, Core spec Vol 3 Part F) — the request/response protocol behind GATT, carried on L2CAP CID 0x0004. ATT is the application layer of BLE: it is how a client reads and writes a server's attributes (characteristics), discovers its services, and receives notifications. Decoding ATT traffic from a btsnoop / HCI-ACL capture is the recon headline for what a BLE app actually does on a device: which attribute **handles** it reads and writes, the **service / characteristic discovery** (Read By Group Type / Read By Type / Find Information) that maps the GATT database, and the **notifications / indications** a device pushes. It is the final layer of the project's Bluetooth-stack decode chain (bt_hci_decode → bt_l2cap_decode → here) and pairs with the UUID naming in bluetooth_gatt_uuid_lookup.

Wrap-vs-native judgement

Native. An ATT PDU is a 1-byte opcode then per-opcode fixed fields —
little-endian 16-bit handles, a 16-bit MTU, 2-or-16-byte UUIDs, and value
blobs. A byte read + an opcode dispatch + handle/UUID reads; stdlib only,
no new go.mod dep.

Verifiable / no confidently-wrong output

The ATT opcodes, the error codes and the per-opcode field layouts follow
the Bluetooth Core specification (Vol 3 Part F) — deterministic and
byte-checkable. The common opcodes (Error/Exchange MTU/Find Information/
Read By Type/Read/Read By Group Type/Write/Notification/Indication) are
field-decoded; the attribute VALUE blobs are surfaced as raw hex (their
contents are characteristic-specific), and the length-prefixed
attribute-data lists (discovery responses) are surfaced raw with their
per-record length noted. An opcode outside the decoded set is named (or
reported by value) with its body raw.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Opcode    int    `json:"opcode"`
	OpcodeHex string `json:"opcode_hex"`
	Operation string `json:"operation"`

	Handle      string `json:"handle,omitempty"`
	StartHandle string `json:"start_handle,omitempty"`
	EndHandle   string `json:"end_handle,omitempty"`
	UUID        string `json:"uuid,omitempty"`
	MTU         *int   `json:"mtu,omitempty"`
	ValueHex    string `json:"value_hex,omitempty"`

	// Error Response
	RequestOpcode string `json:"request_opcode,omitempty"`
	ErrorCode     string `json:"error_code,omitempty"`

	// Discovery responses (length-prefixed attribute-data lists)
	RecordLength *int `json:"record_length,omitempty"`

	PayloadHex string   `json:"payload_hex,omitempty"`
	Notes      []string `json:"notes,omitempty"`
}

Result is the decoded view of an ATT PDU.

func Decode

func Decode(input string) (*Result, error)

Decode parses an ATT PDU (the L2CAP CID-0x0004 payload, starting at the ATT opcode) from hex (whitespace / ':' / '-' / '_' separators and a '0x' prefix tolerated).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL