Expand description
C ABI for bluetooth_core.
Modules§
- permission
- Cross-platform Bluetooth permission status and request.
Structs§
- BleCharacteristic
- A GATT characteristic.
- BleDevice
- A discovered BLE peripheral.
- BleService
- A GATT service with its characteristics.
- BleSession
- A live BLE session. Created by
bt_session_new; freed bybt_session_free.
Enums§
- BleEvent
- An event from the central’s event stream.
- Error
- Errors that can occur during BLE session operations.
Functions§
- bt_
connect ⚠ - Connects to a peripheral by id. Returns 0 on success, -1 on error.
- bt_
disconnect ⚠ - Disconnects from a peripheral by id. Returns 0 on success, -1 on error.
- bt_
discover_ ⚠services - Discovers services on a peripheral and writes them as a JSON array into
buf. Returns bytes written (> 0), or -1 on error. - bt_
last_ error - Returns the most recent error message on the calling thread (empty if none).
The pointer is valid until the next
bt_*call on this thread. - bt_
permission_ status - Returns the current Bluetooth authorization status: 0 not-determined, 1 granted, 2 denied, 3 restricted, 4 unsupported (no app-level permission on this platform; treat as granted).
- bt_read⚠
- Reads a characteristic’s value into
buf. Returns bytes written (>= 0), or -1 on error. - bt_
request_ permission - Requests Bluetooth authorization (prompting if not yet determined) and returns the resulting status, using the same codes as bt_permission_status.
- bt_
session_ free - Frees a session created by bt_session_new, stopping its background tasks.
- bt_
session_ new - Opens a BLE session on the first available adapter. Returns null on failure; see bt_last_error.
- bt_
session_ ⚠poll_ event - Drains the next queued BLE event as a JSON string into
buf. - bt_
start_ ⚠scan - Starts scanning.
filter_jsonis an optional JSON array of service-UUID strings (pass null to scan for everything). Returns 0 on success, -1 on error. - bt_
stop_ scan - Stops scanning. Returns 0 on success, -1 on error.
- bt_
subscribe ⚠ - Subscribes to a characteristic; notifications arrive via bt_session_poll_event. Returns 0 or -1.
- bt_
unsubscribe ⚠ - Unsubscribes from a characteristic. Returns 0 or -1.
- bt_
write ⚠ - Writes
lenbytes fromdatato a characteristic.with_responseselects a with-response (nonzero) vs without-response (0) write. Returns 0 or -1.