agentleFS
SensorsIotSensorsIot/Embedded-AI-Harness/.claude/skills/testbench-ble/SKILL.md

testbench-ble

Skill235 starsChanged 3 months agoMITView on GitHub

Use this skill whenever the user needs to interact with BLE peripherals through the testbench — scanning for devices, connecting by address, writing to GATT characteristics, or checking connection status. The Pi acts as a BLE-to-HTTP bridge using bleak. Also use when sending keystrokes to BLE HID devices, triggering OTA via BLE commands, or debugging BLE connectivity. Triggers on "BLE", "bluetooth", "GATT", "NUS", "Nordic UART", "BLE scan", "BLE write", "BLE connect".

  • Sends data out

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check devices array in response

    line 81
  2. Distinctive:

    Write to NUS RX characteristic

    line 86

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

ESP32 Bluetooth LE Proxy

Base URL: $TESTBENCH_URL — see Step 0

Step 0: Point at a bench

There are several benches and their addresses move, so nothing here writes one down. $BENCH is not usable either — a container cannot resolve mDNS. Discover the bench and export its URL:

export TESTBENCH_URL=$(sudo python3 .claude/skills/esp-idf-handling/discover-testbench.py \
                         --url --name <bench-hostname>)
curl -s "$TESTBENCH_URL/api/info"        # confirm before anything else

--url refuses to guess when more than one bench answers, so --name is required whenever a second bench is powered on. TESTBENCH_URL is the same variable pytest --wt-url falls back to.

Endpoints

Request and response shapes: FSD Appendix D.5.

One BLE connection at a time — connect to a second peripheral without disconnecting the first and the call fails rather than switching.

Examples

# Scan for BLE devices (5s timeout)
curl -X POST $TESTBENCH_URL/api/ble/scan \
  -H 'Content-Type: application/json' \
  -d '{"timeout": 5}'

# Scan with name filter
curl -X POST $TESTBENCH_URL/api/ble/scan \
  -H 'Content-Type: application/json' \
  -d '{"timeout": 5, "name_filter": "<device-name>"}'

# Connect by MAC address
curl -X POST $TESTBENCH_URL/api/ble/connect \
  -H 'Content-Type: application/json' \
  -d '{"address": "AA:BB:CC:DD:EE:FF"}'

# Write hex data to a GATT characteristic
curl -X POST $TESTBENCH_URL/api/ble/write \
  -H 'Content-Type: application/json' \
  -d '{"characteristic": "6e400002-b5a3-f393-e0a9-e50e24dcca9e", "data": "48656c6c6f", "response": true}'

# Check connection status
curl $TESTBENCH_URL/api/ble/status

# Disconnect
curl -X POST $TESTBENCH_URL/api/ble/disconnect

Nordic UART Service (NUS) UUIDs

UUIDRole
6e400001-b5a3-f393-e0a9-e50e24dcca9eNUS Service
6e400002-b5a3-f393-e0a9-e50e24dcca9eRX Characteristic (write to this)
6e400003-b5a3-f393-e0a9-e50e24dcca9eTX Characteristic (notifications from device)

Common Workflows

  1. Send a command via NUS:
    • POST /api/ble/scan with name_filter to find device
    • POST /api/ble/connect with the MAC address from scan results
    • POST /api/ble/write with NUS RX UUID and hex-encoded command
    • POST /api/ble/disconnect when done
  2. Check if device is advertising:
    • POST /api/ble/scan with short timeout and name filter
    • Check devices array in response
  3. Send binary command protocol:
    • Connect to device
    • Encode command bytes as hex (e.g., 0x02 + "Hello" = 0248656c6c6f)
    • Write to NUS RX characteristic
    • Monitor device response via serial or UDP logs (see testbench-logging)

Troubleshooting

ProblemFix
"BLE not available"bleak not installed on testbench Pi
Scan returns emptyIncrease timeout; check device is advertising
Connect fails (409)Already connected — disconnect first
Write fails "invalid hex data"Data must be hex string (e.g., "48656c6c6f" for "Hello")
Device not found by nameCheck exact advertised name; BLE names are case-sensitive

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.