Bluetooth LE: Difference between revisions

Created page with "Also known as BLE. Not to be confused with Bluetooth, which is completely different except for where it's the same. ==GATT== The Generic Attribute Profile is the core BLE API. A server implements <i>services</i>, which are collections of one or more <i>characteristics</i>, and may have zero or more <i>secondary services</i>. A characteristic has a value, and optional <i>descriptors</i>. All three of these objects have UUIDs. Some UUIDs are assigned, and refer to sta..."
 
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


==GATT==
==GATT==
The Generic Attribute Profile is the core BLE API. A server implements <i>services</i>, which are collections of one or more <i>characteristics</i>, and may have zero or more <i>secondary services</i>. A characteristic has a value, and optional <i>descriptors</i>. All three of these objects have UUIDs. Some UUIDs are assigned, and refer to standard objects. Others are vendor-defined. The UUIDs of a server's services, their characteristics, and their descriptors can be enumerated, but the client must give meaning to them (they are not self-describing).
The Generic Attribute Profile is the core BLE API. A server implements <i>services</i>, which are collections of one or more <i>characteristics</i>, and may have zero or more <i>secondary services</i>. A characteristic has a value, and optional <i>descriptors</i>. All three of these objects have UUIDs. Some UUIDs are assigned, and refer to standard objects. Others are vendor-defined. The UUIDs of a server's services, their characteristics, and their descriptors can be enumerated, but the client must give meaning to them (they are not self-describing). A characteristic can be read-only, write-only, or read-write, as defined by the server.
 
===<tt>bluetoothctl</tt>===
Discover local BLE devices' names and MAC addresses:
* <tt>scan le</tt>
Operating with GATT requires connecting, as specified using the server's MAC:
* <tt>connect MAC</tt>
Once connected, discover services and characteristics:
* <tt>gatt.list-attributes</tt>
Operating with a characteristic requires selecting it by UUID:
* <tt>gatt.select-attribute UUID</tt>
Read the selected characteristic:
* <tt>gatt.read</tt>
Write the selected characteristic:
* <tt>gatt.write DATA</tt>
DATA must be expressed as a series of bytes in the form <tt>0xHH</tt>, separated by spaces. This can be generated on the command line via e.g.:
* <tt>echo -n "here is some data" | xxd -p | sed -e 's/\(..\)/0x\1 /g'</tt>
 
[[CATEGORY: Networking]]