std.hardware.bluetooth_gattc
Der GATT-Client: Dienste und Charakteristiken eines BLE-Geräts finden, Werte lesen und schreiben, Benachrichtigungen abonnieren.
Ein BLE-Gerät beschreibt sich selbst über eine Hierarchie aus Diensten (Services), die Charakteristiken enthalten, die wiederum Deskriptoren tragen. Jedes Element hat ein Handle — eine 16-Bit-Zahl, über die es angesprochen wird — und eine UUID, die sagt, was es bedeutet. Der Ablauf ist deshalb immer: erst GattDiscoverServices, dann innerhalb eines Dienstes GattDiscoverChars, dann mit dem gefundenen Handle lesen oder schreiben.
Die GattSvc*- und GattChar*-Funktionen lesen einzelne Felder aus dem Ergebnispuffer der Discovery — der Puffer ist ein Feld fester Satzgröße, die Funktionen sind die Zugriffshilfen darauf.
Für Benachrichtigungen muss der Client in den CCCD-Deskriptor der Charakteristik schreiben; danach schickt das Gerät von sich aus Aktualisierungen, die mit einer Empfangsfunktion abgeholt werden.
std.hardware.bluetooth — Übersicht · Bluetooth-Guide · Standard Library
Schnittstelle
| Signatur |
|---|
GattSvcStart(buf: int64, idx: int64): int64 |
GattSvcEnd(buf: int64, idx: int64): int64 |
GattSvcUUID(buf: int64, idx: int64): int64 |
GattCharDecl(buf: int64, idx: int64): int64 |
GattCharValue(buf: int64, idx: int64): int64 |
GattCharUUID(buf: int64, idx: int64): int64 |
GattCharProps(buf: int64, idx: int64): int64 |
GattDiscoverServices(fd: int64, outBuf: int64, maxServices: int64): int64 |
GattDiscoverChars(fd: int64, startHandle: int64, endHandle: int64, outBuf: int64, maxChars: int64): int64 |
GattFindCharByUUID(charBuf: int64, charCount: int64, uuid: int64): int64 |
GattFindServiceByUUID(svcBuf: int64, svcCount: int64, uuid: int64): int64 |
GattReadChar(fd: int64, valueHandle: int64, dataBuf: int64, bufLen: int64): int64 |
GattWriteChar(fd: int64, valueHandle: int64, data: int64, dataLen: int64): int64 |
GattWriteCmd(fd: int64, valueHandle: int64, data: int64, dataLen: int64): int64 |
GattEnableNotification(fd: int64, cccdHandle: int64): int64 |
GattDisableNotification(fd: int64, cccdHandle: int64): int64 |
GattEnableIndication(fd: int64, cccdHandle: int64): int64 |
GattRecvNotification(fd: int64, handleOut: int64, dataBuf: int64, bufLen: int64): int64 |
GattPoll(fd: int64, timeoutMs: int64): int64 |
ReadHeartRate(fd: int64, hrHandle: int64, flagsOut: int64, bpmOut: int64): int64 |
ReadBatteryLevel(fd: int64, battHandle: int64): int64 |
| Konstante | Wert | Bedeutung |
|---|---|---|
GATT_UUID_PRIMARY_SERVICE | 0x2800 | – |
GATT_UUID_SECONDARY_SERVICE | 0x2801 | – |
GATT_UUID_CHARACTERISTIC | 0x2803 | Declaration |
GATT_UUID_CCCD | 0x2902 | Client Char Config |
GATT_UUID_SCCD | 0x2903 | Server Char Config |
GATT_UUID_CHAR_FORMAT | 0x2904 | Presentation Format |
GATT_SVC_GENERIC_ACCESS | 0x1800 | – |
GATT_SVC_GENERIC_ATTRIBUTE | 0x1801 | – |
GATT_SVC_HEART_RATE | 0x180D | – |
GATT_SVC_BATTERY | 0x180F | – |
GATT_SVC_DEVICE_INFO | 0x180A | – |
GATT_SVC_CURRENT_TIME | 0x1805 | – |
GATT_UUID_DEVICE_NAME | 0x2A00 | – |
GATT_UUID_APPEARANCE | 0x2A01 | – |
…sowie 16 weitere Konstanten in der Quelldatei std/hardware/bluetooth_gattc.lyx.
Quelle: std/hardware/bluetooth_gattc.lyx · geprüft mit lyxc 1.0.17E · Stand 2026-08-12
