Peter
Peter

Reputation: 38465

gatttool difference between --char-desc and --characteristics

The gatttool --help-all says the following:

Usage:
  gatttool [OPTION...]

Help Options:
  -h, --help                                Show help options
  --help-all                                Show all help options
  --help-gatt                               Show all GATT commands
  --help-params                             Show all Primary Services/Characteristics arguments
  --help-char-read-write                    Show all Characteristics Value/Descriptor Read/Write arguments

GATT commands
  --primary                                 Primary Service Discovery
  --characteristics                         Characteristics Discovery
  --char-read                               Characteristics Value/Descriptor Read
  --char-write                              Characteristics Value Write Without Response (Write Command)
  --char-write-req                          Characteristics Value Write (Write Request)
  --char-desc                               Characteristics Descriptor Discovery
  --listen                                  Listen for notifications and indications

Primary Services/Characteristics arguments
  -s, --start=0x0001                        Starting handle(optional)
  -e, --end=0xffff                          Ending handle(optional)
  -u, --uuid=0x1801                         UUID16 or UUID128(optional)

Characteristics Value/Descriptor Read/Write arguments
  -a, --handle=0x0001                       Read/Write characteristic by handle(required)
  -n, --value=0x0001                        Write characteristic value (required for write operation)

Application Options:
  -i, --adapter=hciX                        Specify local adapter interface
  -b, --device=MAC                          Specify remote Bluetooth address
  -t, --addr-type=[public | random]         Set LE address type. Default: public
  -m, --mtu=MTU                             Specify the MTU size
  -p, --psm=PSM                             Specify the PSM for GATT/ATT over BR/EDR
  -l, --sec-level=[low | medium | high]     Set security level. Default: low
  -I, --interactive                         Use interactive mode

The --characteristics says Characteristics Discovery and the --char-desc says Characteristics Descriptor now what is the difference?

If i run them both against the same BLE device i get diffrent handles for the same uuid? Example:

gatttool --device=C4:7C:8D:62:D3:19 --characteristics
...
handle = 0x0032, char properties = 0x0a, char value handle = 0x0033, uuid = 00001a00-0000-1000-8000-00805f9b34fb
...

gatttool --device=C4:7C:8D:62:D3:19 --char-desc
...
handle = 0x0033, uuid = 00001a00-0000-1000-8000-00805f9b34fb
...

So am i supposed to use the handle from --characteristics or the handle from --char-desc when using read/write (-a parameter)?

Upvotes: 3

Views: 7427

Answers (1)

treavg
treavg

Reputation: 189

Think of descriptors as metadata about the characteristic, or "defined attributes that describe a characteristic value". For instance you may have a characteristic which holds some measured value, which then also has a descriptor that states the acceptable range for the value.

If you read the characteristic, you are going to get the value itself; read the range descriptor then you are going to get the valid range.

Some descriptors have been adopted into the Bluetooth specification and have assigned numbers and some may be custom without general documentation.

A decent reference: https://www.bluetooth.com/specifications/gatt/descriptors

And more specific to the range example above: https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.valid_range.xml

Upvotes: 2

Related Questions