Skip to content

BLE Tools

Tools for interacting with Bluetooth Low Energy devices — sensors, fitness trackers, IoT devices, and more.

Scan for BLE (Bluetooth Low Energy) devices.

Parameters:

NameTypeRequiredDefaultDescription
adapterstringYes-Adapter name
timeoutintegerNo10Scan duration in seconds
name_filterstringNo-Only devices with name containing this
service_filterstringNo-Only devices advertising this service UUID

Returns:

[
{
"address": "AA:BB:CC:DD:EE:FF",
"name": "Heart Rate Monitor",
"rssi": -65,
"uuids": ["0000180d-0000-1000-8000-00805f9b34fb"],
"manufacturer_data": {"76": "02150201..."},
"service_data": {}
}
]

Example:

# Basic scan
bt_ble_scan adapter="hci0" timeout=10
# Filter by name
bt_ble_scan adapter="hci0" name_filter="Fitness"
# Filter by service (Heart Rate)
bt_ble_scan adapter="hci0" service_filter="0000180d-0000-1000-8000-00805f9b34fb"

List GATT services for a connected BLE device.

Parameters:

NameTypeRequiredDescription
adapterstringYesAdapter name
addressstringYesDevice MAC address

Returns:

[
{
"uuid": "0000180f-0000-1000-8000-00805f9b34fb",
"primary": true,
"description": "Battery Service"
},
{
"uuid": "0000180d-0000-1000-8000-00805f9b34fb",
"primary": true,
"description": "Heart Rate Service"
}
]

Example:

bt_ble_services adapter="hci0" address="AA:BB:CC:DD:EE:FF"

Notes:

  • Device must be connected first
  • Wait 2-3 seconds after connecting for service discovery

List GATT characteristics for a BLE device.

Parameters:

NameTypeRequiredDefaultDescription
adapterstringYes-Adapter name
addressstringYes-Device MAC address
service_uuidstringNo-Filter to this service only

Returns:

[
{
"uuid": "00002a19-0000-1000-8000-00805f9b34fb",
"service_uuid": "0000180f-0000-1000-8000-00805f9b34fb",
"flags": ["read", "notify"],
"description": "Battery Level"
}
]

Example:

# All characteristics
bt_ble_characteristics adapter="hci0" address="AA:BB:CC:DD:EE:FF"
# Filter by service
bt_ble_characteristics adapter="hci0" address="..." service_uuid="0000180f-0000-1000-8000-00805f9b34fb"

Read a GATT characteristic value.

Parameters:

NameTypeRequiredDescription
adapterstringYesAdapter name
addressstringYesDevice MAC address
char_uuidstringYesCharacteristic UUID

Returns:

{
"uuid": "00002a19-0000-1000-8000-00805f9b34fb",
"hex": "4b",
"decoded": 75,
"description": "Battery Level: 75%"
}

Example:

bt_ble_read adapter="hci0" address="AA:BB:CC:DD:EE:FF" char_uuid="00002a19-0000-1000-8000-00805f9b34fb"

Notes:

  • Characteristic must have read flag
  • Device must be connected

Write a value to a GATT characteristic.

Parameters:

NameTypeRequiredDefaultDescription
adapterstringYes-Adapter name
addressstringYes-Device MAC address
char_uuidstringYes-Characteristic UUID
valuestringYes-Value to write
value_typestringNo”hex”How to interpret value: “hex”, “string”, “int”
with_responsebooleanNotrueWait for write acknowledgment

Value Types:

TypeExampleBytes Written
hex”0102ff”0x01, 0x02, 0xFF
string”hello”UTF-8 encoded
int”42”Single byte (0-255)

Returns:

{
"status": "written",
"uuid": "...",
"bytes_written": 3
}

Example:

# Write hex bytes
bt_ble_write adapter="hci0" address="..." char_uuid="..." value="0102ff" value_type="hex"
# Write string
bt_ble_write adapter="hci0" address="..." char_uuid="..." value="hello" value_type="string"
# Write without waiting for response (faster)
bt_ble_write adapter="hci0" address="..." char_uuid="..." value="01" with_response=false

Enable or disable notifications for a characteristic. When enabled, notification values are automatically buffered and accessible via MCP resources.

Parameters:

NameTypeRequiredDescription
adapterstringYesAdapter name
addressstringYesDevice MAC address
char_uuidstringYesCharacteristic UUID
enablebooleanYestrue to enable, false to disable

Returns (enable=true):

{
"status": "notifications_enabled",
"uuid": "00002a37-0000-1000-8000-00805f9b34fb",
"uuid_short": "0x2A37",
"resource_uri": "bluetooth://ble/AA:BB:CC:DD:EE:FF/00002a37-.../notifications",
"history_uri": "bluetooth://ble/AA:BB:CC:DD:EE:FF/00002a37-.../notifications/history"
}

Returns (enable=false):

{
"status": "notifications_disabled",
"uuid": "00002a37-0000-1000-8000-00805f9b34fb"
}

Example:

# Enable heart rate notifications
bt_ble_notify adapter="hci0" address="..." char_uuid="00002a37-0000-1000-8000-00805f9b34fb" enable=true
# Read notification values via MCP resource
ReadMcpResource uri="bluetooth://ble/.../notifications"
# Disable notifications
bt_ble_notify adapter="hci0" address="..." char_uuid="..." enable=false

Notes:

  • Characteristic must have notify flag
  • Notifications are buffered (up to 100 values) in a circular buffer
  • Access buffered values via resource_uri or history_uri

List all active BLE notification subscriptions.

Parameters: None

Returns:

{
"count": 2,
"subscriptions": [
{
"address": "AA:BB:CC:DD:EE:FF",
"char_uuid": "00002a37-0000-1000-8000-00805f9b34fb",
"uuid_short": "0x2A37",
"notifying": true,
"buffer_count": 15,
"total_received": 47,
"resource_uri": "bluetooth://ble/.../notifications",
"history_uri": "bluetooth://ble/.../notifications/history"
}
]
}

Example:

bt_ble_notification_status

Clear the notification buffer for a characteristic while keeping the subscription active.

Parameters:

NameTypeRequiredDescription
adapterstringYesAdapter name
addressstringYesDevice MAC address
char_uuidstringYesCharacteristic UUID

Returns:

{
"status": "buffer_cleared",
"uuid": "00002a37-0000-1000-8000-00805f9b34fb",
"cleared_count": 15
}

Example:

bt_ble_clear_notification_buffer adapter="hci0" address="AA:BB:CC:DD:EE:FF" char_uuid="00002a37-..."

Read battery level from a BLE device (convenience function).

Parameters:

NameTypeRequiredDescription
adapterstringYesAdapter name
addressstringYesDevice MAC address

Returns:

{
"battery_level": 75,
"unit": "percent"
}

Example:

bt_ble_battery adapter="hci0" address="AA:BB:CC:DD:EE:FF"

Notes:

  • Uses standard Battery Service (UUID 0x180F)
  • Returns error if device doesn’t support battery service
ServiceShort UUIDFull UUID
Battery0x180F0000180f-0000-1000-8000-00805f9b34fb
Heart Rate0x180D0000180d-0000-1000-8000-00805f9b34fb
Device Info0x180A0000180a-0000-1000-8000-00805f9b34fb
Generic Access0x180000001800-0000-1000-8000-00805f9b34fb
CharacteristicShort UUIDService
Battery Level0x2A19Battery
Heart Rate Measurement0x2A37Heart Rate
Manufacturer Name0x2A29Device Info
Model Number0x2A24Device Info