shinyorg/shiny/shiny-bluetoothle
Claude Code and agent skill by shinyorg/shiny
- community
Checking that the SKILL.md file is still in the repository.
Shiny BluetoothLE client/central operations for scanning, connecting, and communicating with BLE peripherals
Install
npx vskill@latest install shinyorg/shiny/shiny-bluetoothleSKILL.md
The same SKILL.md was published earlier as shinyorg/shiny/shiny-bluetoothle.
Shiny BluetoothLE (Client/Central)
When to Use This Skill
Use this skill when the user needs to:
- Scan for BLE peripherals
- Connect to and communicate with BLE devices
- Read, write, or subscribe to GATT characteristics
- Read or write GATT descriptors
- Implement managed scans with automatic peripheral list management
- Request MTU changes, pair with devices, or perform reliable write transactions
- Read standard BLE services (device information, battery, heart rate)
- Work with BLE advertisement data
- Open L2CAP CoC channels to a peripheral that has published a PSM
- Upload or download files over L2CAP with percent-complete / throughput / ETA metrics
- Write or receive messages longer than one GATT operation (message framing)
- Claim a ticketed L2CAP channel from a host that shares one PSM, or use a channel as a
Stream
Do NOT use this skill for BLE hosting/peripheral mode (advertising, GATT server). That is a separate library (Shiny.BluetoothLE.Hosting).
Library Overview
- NuGet Package:
Shiny.BluetoothLE(Android, iOS/tvOS/macOS, Windows, and Blazor WebAssembly via the Web Bluetooth API -Shiny.BluetoothLE.Blazorno longer exists),Shiny.BluetoothLE.Linux(Linux via BlueZ - a separate package so its D-Bus dependency never reaches WebAssembly) - Registration:
services.AddBluetoothLE()everywhere except Linux, where it isservices.AddLinuxBluetoothLE()fromShiny.BluetoothLE.Linux. The Web Bluetooth classes areBrowserBleManager/BrowserPeripheral/BrowserAdvertisementData - Primary Namespace:
Shiny.BluetoothLE - Managed Scan Namespace:
Shiny.BluetoothLE.Managed - Platforms: Android, iOS/tvOS/macOS (Apple), Windows, Linux (BlueZ), WebAssembly (Web Bluetooth)
tvOS
tvOS runs the same CoreBluetooth central implementation as iOS — scanning, connecting, GATT and L2CAP are identical and there is no tvOS-specific code to write. Two Apple limits to encode in any guidance you generate:
- No background Bluetooth. tvOS has no
bluetooth-centralbackground mode. Scans and connections end when the app suspends, and settingAppleBleConfiguration.RestoreIdentifieraccomplishes nothing — do not suggest it for tvOS. - No peripheral role.
Shiny.BluetoothLE.Hostinghas no tvOS target;CBMutableService/CBMutableCharacteristiccarry no constructors there. If asked to build a GATT server on tvOS, say it is not possible rather than producing code that cannot compile.
Also worth mentioning when relevant: the Siri Remote is itself a BLE device, so an Apple TV has fewer simultaneous connections to spare than an iPhone.
Blazor WebAssembly / Web Bluetooth caveats
The Blazor implementation is built on the browser's Web Bluetooth API and inherits its limitations:
- User-gesture gated. Scans must be kicked off from a click handler. The browser shows a native chooser and Shiny only sees the peripheral(s) the user explicitly selects — there is no ambient/background scanning and no manufacturer data.
- HTTPS or `http://localhost` required. The API is unavailable on plain
http://. - No background operation. Scanning and connections stop when the tab is backgrounded or closed.
- Browser support is Chromium-only and requires enabling in some cases. When generating setup instructions or troubleshooting guidance, note the following:
- Chrome / Edge / Brave / Opera (desktop): enabled by default on Windows, macOS, Linux, ChromeOS. Fallback:
chrome://flags/#enable-web-bluetooth(oredge://flags, etc.) → Enabled → restart. Linux also needsexperimental-web-platform-featureson and BlueZ 5.43+. - Chrome / Edge (Android): Android 6.0+. OS location services must be on for the chooser prompt to appear.
- Samsung Internet: enable
internet://flags→ Web Bluetooth. - Safari (macOS / iOS / iPadOS): not supported. On iOS/iPadOS suggest third-party WKWebView-based browsers Bluefy or WebBLE. Stock macOS Safari has no workaround.
- Firefox: not supported on any platform.
Setup
Register in your MauiProgram.cs or host builder:
The delegate class:
Android Manifest (required for scanning)
Add the BLE permissions to Platforms/Android/AndroidManifest.xml. Critical: on Android 12+ (API 31+) Shiny requests only BLUETOOTH_SCAN / BLUETOOTH_CONNECT at runtime — it does NOT request ACCESS_FINE_LOCATION. If you declare BLUETOOTH_SCAN without the neverForLocation flag, Android silently withholds all scan results unless fine location is also granted, so scans appear to return nothing. Unless your app actually derives physical location from BLE, always add neverForLocation:
If you DO use BLE to infer location, omit neverForLocation and also request/grant ACCESS_FINE_LOCATION at runtime.
Scans discover both legacy and Bluetooth 5 extended advertisements automatically (when the chipset supports extended advertising); legacy advertisements that virtually all peripherals send are always included. To force a legacy-only scan, use new AndroidScanConfig(IncludeExtendedAdvertisements: false).
Code Generation Instructions
When generating BLE client code, follow these conventions:
- Always request access before scanning: Call
IBleManager.RequestAccess()orRequestAccessAsync()and verifyAccessState.Availablebefore starting a scan - it is how a denied permission or a switched-off adapter reaches the user. It is no longer load-bearing for the scan itself: as of 5.6 aScan()issued before the Apple central has finished powering on is parked and started automatically (see #12), rather than being silently dropped.
- Use reactive (IObservable) APIs as the primary pattern: The library is built on System.Reactive. Use the
Asyncextension methods only when you need Task-based patterns.
- Dispose scan subscriptions: Only one scan can be active at a time. Always dispose the scan subscription or call
StopScan()when done - either one releases the slot. Never track "am I scanning" with your own flag; readIBleManager.IsScanning, which reports whether the native scan is running (it isfalsewhile a scan is parked waiting on the adapter).
- Use string-based UUIDs for services and characteristics: The API uses string UUIDs throughout (e.g.,
"180D"or"0000180d-0000-1000-8000-00805f9b34fb").
- Prefer `ConnectAsync` for simple connection flows: It handles waiting for the connected state and has a default 30-second timeout.
- Always call `CancelConnection()` or `DisconnectAsync()` when done: Connections are not automatically cleaned up.
- Use `IManagedScan` for UI-bound scanning: It provides an
INotifyReadOnlyCollectionthat works with MVVM bindings and handles peripheral deduplication, buffering, and stale removal.
- Feature detection via interface checks: Optional capabilities (MTU request, pairing, reliable transactions) use feature interfaces. Always use the
Try*orCan*extension methods rather than casting directly.
8a. `IPeripheral.Mtu` is the usable payload, not the ATT MTU: It is already the negotiated ATT MTU minus the 3-byte ATT header (BleConstants.AttHeaderSize), so fragment writes to peripheral.Mtu directly — never write peripheral.Mtu - 3. The units are asymmetric across a single call: TryRequestMtu(512) passes 512 as an ATT MTU to the platform but emits 509, the payload. When handing a value to an API that genuinely wants an ATT MTU, add the header back with peripheral.Mtu + BleConstants.AttHeaderSize. The MTU belongs to the link: Mtu resets to 20 on disconnect, so request it in a WhenConnected() handler (every reconnect), not once after the first connect.
- Handle `BleException` and `BleOperationException`: GATT operations can throw these.
BleOperationExceptionincludes aGattStatusCode. An in-flight operation that is interrupted by a disconnect faults with aBleExceptionrather than hanging, so always have anonErrorhandler (orcatch) on read/write/discovery calls — with auto-reconnect enabled, retry once the peripheral reportsConnectedagain. If the subscription is already gone when that fault arrives (aWhenStatusChanged().Select(...).Switch()pipeline tears down the in-flight call on the same disconnect), the fault is dropped rather than raised throughTaskScheduler.UnobservedTaskException- never add anUnobservedTaskExceptionfilter forBleExceptionto keep disconnects out of crash telemetry.
- Connection auto-reconnect:
ConnectionConfig.AutoConnect = true(default) reconnects the peripheral after a dropped link or a power cycle on every platform — never write your ownWhenDisconnected().Subscribe(_ => peripheral.Connect())loop on top of it, the two fight each other. SetAutoConnect = falsefor a faster initial connection when you intend to own reconnecting.CancelConnection()disposes the auto-reconnect, so a deliberate disconnect stays disconnected; callConnect()again to re-arm it. Auto-reconnect restores the link only — re-run per-connection setup (MTU request, authentication handshake, reading a config characteristic) fromWhenConnected(), not once after the firstConnectAsync().
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 repositoryCheckingskills/shiny-bluetoothle/SKILL.md
Popularity
- Repository stars
- 1,577
- Repository forks
- 246
- 7-day trend score
- 0
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/shinyorg/shiny/shiny-bluetoothle)