Skip to main content
Use the Bluetooth provider to test a BLE peripheral from the host running Embedder. The provider uses Bleak and exposes a script-only helper API. Scan results, connections, GATT trees, and notifications publish to the Monitor’s Bluetooth tab while the script runs. This provider covers Bluetooth Low Energy GATT operations. It does not expose Bluetooth Classic workflows.

Check the host adapter

Run hardware_status and inspect the bluetooth provider. It reports:
  • Whether Python is available
  • Whether Embedder’s Python environment is ready
  • Whether a host BLE adapter was detected
Approve Bleak installation on first use. Platform requirements differ:

Scan before connecting

ble_scan returns platform-specific addresses:
  • macOS returns a CoreBluetooth UUID.
  • Linux and Windows return a Bluetooth MAC address.
Pass the exact address value returned by the scan. Do not replace a macOS UUID with a printed device MAC from another tool. You can filter by a case-insensitive name substring or by advertised service UUIDs. Active scanning requests scan responses; passive scanning does not.

Connect and discover GATT

Discover services once after you connect:
.embedder/hardware/ble_gatt.py
ble_list_services returns services, characteristic UUIDs and properties, and descriptor UUIDs and handles. It also populates the GATT tree in the Bluetooth tab. The provider caches characteristic handles for that connection so later reads and writes do not walk the database again.

Read and write characteristics

Characteristic reads return bytes. Interpret them only with the service specification or project protocol. For a write, state whether you need an acknowledgement:
  • response=True uses Write With Response.
  • response=False uses Write Without Response.
Write data can be bytes, a byte array, a list of byte values, or a hexadecimal string. The helper returns the number of bytes written.
A GATT write can change configuration, start an OTA path, or control an actuator. Name the characteristic, payload, and expected result before you ask Embedder to write.
Descriptor helpers can read or write a descriptor such as CCCD 0x2902. Use the characteristic UUID and descriptor UUID returned by discovery.

Collect notifications

Notifications arrive asynchronously. Use this sequence:
1

Subscribe

Call ble_subscribe with the connection handle and characteristic UUID.
2

Collect a bounded window

Call ble_collect_notifications for the duration you need. Filter by characteristic when several subscriptions are active.
3

Unsubscribe

Call ble_unsubscribe to release the subscription.
4

Disconnect

Call ble_disconnect before the script exits.
.embedder/hardware/ble_notifications.py
Each returned entry includes the connection handle, address, characteristic UUID, hexadecimal value, and timestamp. The Bluetooth tab receives notification events live even before the script drains its buffer.

Mark test phases

Use ble_publish_event to add a script milestone to the Bluetooth event log:
This marker helps you compare a GATT action with notifications emitted later in the same script.

Manage connections

The script runner disconnects open BLE handles during cleanup. Still disconnect explicitly when you:
  • Connect to several devices
  • Run a long background script
  • Need to reconnect during the same script
ble_get_rssi returns the current connection RSSI when the host backend provides it. Some Linux BlueZ versions return no post-connect RSSI.

Fix BLE problems

Open System Settings, go to Privacy & Security, then Bluetooth, and grant permission to the process running Embedder. Retry the scan after permission is enabled.
Scan again and pass the returned platform-specific address. Confirm that the peripheral is still advertising and not connected to another central.
Run service discovery and use the UUID returned by the GATT tree. Do not assume a short UUID when the backend returned a full 128-bit UUID.
Check the characteristic’s notify or indicate property, subscribe before triggering the peripheral, and keep the collection window open long enough.
Use Write With Response when the characteristic supports it, then read back or wait for the protocol’s acknowledgement notification.

Hardware scripts

Keep BLE workflows and result JSON under a hardware lease.

Power analyzer

Measure radio activity and sleep current during a BLE test.
Last modified on August 24, 2026