espressif/esp-claw/ble
Claude Code and agent skill by espressif/esp-claw
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install espressif/esp-claw/bleSKILL.md
The same SKILL.md was published earlier as espressif/esp-claw/ble.
BLE Skill (lua_module_ble · Phase 1C)
This skill describes how an Agent can control the BLE module on ESP-Claw via Lua scripts. The module is a thin ESP-IDF NimBLE adapter; it does not depend on LuatOS, Arduino, or any intermediate framework.
Capabilities (Phase 1C)
- BLE controller and NimBLE host bring-up / teardown
- Legacy (BT4) connectable advertising with device name, appearance, and 16-bit
service UUIDs
- Fixed 3-slot connection table with stable
conn_indexidentifiers - MTU preference and per-connection MTU tracking
- Unified event queue:
ble.on_event(fn)+ble.process_events(timeout_ms) - Peripheral-side disconnect (
ble.disconnect) - Module diagnostics via
ble.stats() - Dynamic GATT Server via
ble.gatts_define(profile) - Cached characteristic values via
ble.gatts_set_value()and
ble.stats({ char = ... })
- Server-initiated
ble.notify()/ble.indicate()using stableconn_index - SMP configuration via
ble.smp_config(opts)beforeble.init()
Not in Phase 1: Central / scanning / GATT Client, passkey / numeric comparison Lua callbacks, bond-management Lua APIs, BLE 5.x extended advertising.
Mutual Exclusion with lua_module_ble_hid
Skill selection hard rule
When the user asks only for "broadcasting", "advertising", "normal BLE", "BLE", "GATT", service discovery, characteristic read/write, notify, or indicate, use only this ble skill. Do not use `ble_hid` as a fallback for ordinary BLE advertising or GATT tasks.
Use ble_hid only when the user explicitly mentions HID, keyboard, mouse, media controls, consumer control, typing text, key combos, cursor movement, clicking, or scrolling.
Hard rule: `lua_module_ble` and `lua_module_ble_hid` must never advertise simultaneously. Both modules share the single BLE controller and NimBLE host; running both at the same time causes undefined behaviour.
Switching from BLE → HID:
- Call
ble.adv_stop()thenble.deinit(). - Start
lua_module_ble_hid(e.g. viaskills/ble_hid/scripts/start_ble_hid.lua). - Inform the user that the mode has changed.
Switching from HID → BLE:
- Deinitialize
lua_module_ble_hidvia its own deinit API. - Then call
ble.init()/ble.adv_start(...)in this module. - Inform the user.
Quick-start entry point
Run skills/ble/scripts/start_ble.lua to initialise BLE and start advertising. The script runs an indefinite process_events loop; send a stop signal to terminate it.
To stop ordinary BLE advertising and tear down this module, run skills/ble/scripts/stop_ble.lua. Do not try HID scripts as a recovery path for ordinary BLE failures.
API Reference (Phase 1C)
All functions that can fail return true on success or nil, "error_code" on failure (recoverable errors). Parameter type errors raise luaL_error.
ble.init() → true | nil, err
Starts BLE controller (if not already running) and NimBLE host. Waits up to 15 s for host sync. Idempotent.
Error codes: ble_unsupported (if CONFIG_BT_NIMBLE_MAX_CONNECTIONS < 1).
If ble.smp_config({ require_bond_persist = true }) was set and NimBLE NVS persistence is disabled, returns ble_smp_nvs_persist_disabled.
ble.smp_config(opts) → true | nil, err
Configures NimBLE SMP before the BLE stack is initialized:
io_cap must be one of "no_io", "display_only", "display_yes_no", "keyboard_only", "keyboard_display". mitm = true with "no_io" returns ble_smp_invalid_config. Calling this after ble.init() returns ble_invalid_state.
ble.deinit() → true | nil, err
Drains the event queue (firing all pending callbacks), stops advertising, disconnects peers, stops NimBLE host, releases only controller state owned by this module. Idempotent. Safe to call from any state.
ble.set_name(name) → true | nil, err
Sets the GAP Device Name. name must be a string ≤ 28 bytes. Requires ble.init() to have been called. Becomes the default advertising name when adv_start() is called without data.name.
ble.set_max_mtu(mtu) → true | nil, err
Sets the preferred ATT MTU (23..517). Must be called after ble.init() and before any active connection exists.
Error codes: ble_mtu_invalid, ble_init_not_initialized, ble_invalid_state (connection already exists).
ble.adv_start(opts) → true | nil, err
Starts Legacy Advertising. opts is a table:
Error codes: ble_adv_busy, ble_adv_data_too_long, ble_unsupported (BLE 5.x fields), ble_init_not_initialized.
adv_requested state machine: after adv_start() the module maintains adv_requested = true. If a 3rd connection makes the slot full, advertising is paused (adv_stopped reason="connection_full") but adv_requested stays true. When a slot frees up, advertising restarts automatically (adv_started reason="re_advertise").
ble.adv_stop() → true | nil, err
Stops advertising. Sets adv_requested = false. Idempotent.
ble.disconnect(opts) → true | nil, err
Disconnects a peer from the Peripheral side.
conn_index may be omitted when exactly one connection is active. On success, a disconnected reason="local" event is queued asynchronously.
Error codes: ble_conn_not_found, ble_conn_index_required (multiple connections, no index given), ble_conn_invalid_index.
ble.on_event(fn_or_nil) → true | nil, err
Registers (or clears) the single global BLE event callback. Replacing the callback also clears the pending event queue.
fn_or_nil must be a function or nil; other types raise luaL_error.
ble.process_events(timeout_ms) → number | nil, err
Dispatches up to 8 pending events on the Lua task. timeout_ms (default 0) sets how long to wait for the first event; subsequent reads are non-blocking. Returns the number of events dispatched.
ble.stats(opts?) → table | nil, err
Returns a module snapshot. Without arguments:
connections always has exactly 3 entries (indexed 1..3 in Lua; conn_index is 0..2).
With char argument (Phase 1B+, returns characteristic cached value):
ble.gatts_define(profile) → true | nil, err
Defines and immediately activates a GATT Server. Call after ble.init() and before a GATT profile is active. Hot modification is unsupported; call ble.deinit() before defining a different profile.
UUIDs can be 16-bit, 32-bit, or 128-bit strings. Characteristic lookup prefers the stable id; UUID lookup is allowed but returns ble_gatt_char_ambiguous when multiple characteristics match. Do not declare descriptor 2902 because NimBLE creates CCCD automatically for notify / indicate.
Error codes: ble_init_not_initialized, ble_gatt_already_started, ble_unsupported for secondary = true, ble_smp_invalid_config for authenticated permissions without a MITM-capable SMP config.
ble.gatts_set_value(opts) → true | nil, err
Updates the C-side cached value. It does not notify peers.
Error codes: ble_invalid_state, ble_gatt_char_not_found, ble_gatt_char_ambiguous, ble_gatt_data_too_long.
ble.notify(opts) → true | nil, err
Sends a notification to a peer that has subscribed to the characteristic.
Error codes: ble_conn_not_found, ble_conn_index_required, ble_conn_invalid_index, ble_gatt_char_not_found, ble_gatt_not_subscribed, ble_gatt_data_too_long, ble_gatt_send_failed, ble_smp_security_failed.
ble.indicate(opts) → true | nil, err
Same shape as ble.notify(), but sends an indication and waits for ATT confirmation. Each connection can have only one pending indication; a second call returns ble_gatt_indicate_in_progress until indicate_complete arrives.
Module Constants
Events
Register one global callback with ble.on_event(fn) and poll it with ble.process_events(timeout_ms):
Event types and key fields
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingcomponents/lua_modules/lua_module_ble/skills/ble/SKILL.md
Popularity
- Repository stars
- 2,330
- Repository forks
- 511
- 7-day trend score
- 38
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/espressif/esp-claw/ble)