/shiny:shiny-bluetoothfrom shiny
Generate code using Shiny.Bluetooth for classic Bluetooth (BR/EDR) - RFCOMM / Serial Port Profile client connections and servers over a System.IO.Stream, inquiry discovery, paired device listing, pairing and discoverability on Android, Windows, macOS (AppKit) and Linux (BlueZ). Not for Bluetooth Low Energy and not available on iOS / Mac Catalyst.
Ships in shiny. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in Shiny.Bluetooth, the classic Bluetooth (BR/EDR) library: RFCOMM client and
server connections exposed as a plain System.IO.Stream, inquiry discovery, the paired device list,
pairing, and making the device discoverable.
Invoke this skill when the user wants to:
shiny-bluetoothle skill instead. A "BLE serial" module (HM-10, nRF UART) is BLE too.Capabilities before offering an operation - RequestDiscoverable throws
BluetoothNotSupportedException on Windows and macOS.| Item | Value |
|---|---|
| NuGet | Shiny.Bluetooth, plus Shiny.Bluetooth.Linux on Linux |
| Namespace | Shiny.Bluetooth (types); Shiny (registration extensions) |
| Platforms | Android, Windows, macOS (AppKit), Linux (BlueZ). No iOS, Mac Catalyst or tvOS. |
| Platform | Backed by |
|---|---|
| Android | BluetoothAdapter, BluetoothSocket, BluetoothServerSocket |
| Windows | Windows.Devices.Bluetooth.Rfcomm (RfcommDeviceService, RfcommServiceProvider, StreamSocket) and a DeviceWatcher |
| macOS | IOBluetooth through the Objective-C runtime (the .NET macOS SDK has no binding) - needs an AppKit main loop |
| Linux | BlueZ over D-Bus: Adapter1/Device1, and ProfileManager1.RegisterProfile for every RFCOMM connection in both directions |
| Operation | Android | Windows | macOS | Linux |
|---|---|---|---|---|
GetPairedDevices | ✅ | ✅ | ✅ | ✅ |
Discover (~12 s inquiry) | ✅ | ✅ | ✅ | ✅ |
Pair | ✅ system dialog | ✅ system UI | ✅ system prompt | ✅ needs a BlueZ agent for PIN/confirm |
Connect | ✅ | ✅ | ✅ (secure ignored) | ✅ |
Listen | ✅ | ✅ | ✅ (secure ignored) | ✅ |
RequestDiscoverable | ✅ system dialog | ❌ | ❌ | ✅ |
// Android, Windows, macOS
builder.Services.AddBluetooth();
// Linux - reference Shiny.Bluetooth.Linux; AddBluetooth does not exist on plain net10.0
services.AddLinuxBluetooth();
Both register IBluetoothManager as a singleton. iOS/Mac Catalyst apps cannot reference the package
at all - in a multi-targeted MAUI app, condition the PackageReference and the registration:
<PackageReference Include="Shiny.Bluetooth" Condition="!$(TargetFramework.Contains('-ios')) AND !$(TargetFramework.Contains('maccatalyst'))" />
#if ANDROID || WINDOWS
builder.Services.AddBluetooth();
#endif
public interface IBluetoothManager
{
BluetoothCapabilities Capabilities { get; }
Task<AccessState> RequestAccess(CancellationToken ct = default);
Task<IReadOnlyList<IBluetoothDevice>> GetPairedDevices(CancellationToken ct = default);
Task<IBluetoothDevice> GetDevice(string address, CancellationToken ct = default); // a known address, no discovery
IAsyncEnumerable<BluetoothDiscoveryResult> Discover(CancellationToken ct = default);
Task<BluetoothListener> Listen(Guid serviceUuid, string serviceName, bool secure = true, CancellationToken ct = default);
Task<bool> RequestDiscoverable(TimeSpan duration, CancellationToken ct = default);
}
public interface IBluetoothDevice // equality is by Address only
{
string Address { get; } // always "AA:BB:CC:DD:EE:FF"
string? Name { get; }
bool IsPaired { get; } // as read, and kept current by Pair
uint? ClassOfDevice { get; }
BluetoothMajorDeviceClass? MajorDeviceClass { get; } // decoded from ClassOfDevice
Task<bool> Pair(CancellationToken ct = default);
Task<BluetoothConnection> Connect(Guid serviceUuid, bool secure = true, CancellationToken ct = default);
}
public record BluetoothDiscoveryResult(IBluetoothDevice Device, int? Rssi); // Rssi in dBm from the inquiry
public sealed class BluetoothConnection : IAsyncDisposable, IDisposable
{
IBluetoothDevice Device; Guid ServiceUuid; Stream Stream; // dispose either to disconnect
}
public sealed class BluetoothListener : IAsyncDisposable
{
Guid ServiceUuid; string ServiceName;
Task<BluetoothConnection> Accept(CancellationToken ct = default); // dispose to withdraw the SDP record
}
BluetoothServiceUuids.SerialPort // 00001101-0000-1000-8000-00805F9B34FB
BluetoothServiceUuids.FromShortId(0x1105) // any SIG 16/32-bit id on the base UUID
Exceptions: BluetoothException (base), BluetoothNotSupportedException, BluetoothPermissionException,
BluetoothConnectionException (service not found, out of range, refused).
public class PrinterService(IBluetoothManager bluetooth)
{
public async Task<string> SendCommand(string address, string command, CancellationToken ct)
{
var access = await bluetooth.RequestAccess(ct);
if (access != AccessState.Available)
throw new InvalidOperationException($"Bluetooth is {access}");
var device = await bluetooth.GetDevice(address, ct);
await using var connection = await device.Connect(BluetoothServiceUuids.SerialPort, ct: ct);
// RFCOMM is a stream - frame it. Here: newline-terminated text.
var writer = new StreamWriter(connection.Stream, leaveOpen: true) { NewLine = "\r\n", AutoFlush = true };
var reader = new StreamReader(connection.Stream, leaveOpen: true);
await writer.WriteLineAsync(command.AsMemory(), ct);
return await reader.ReadLineAsync(ct) ?? "";
}
}
var devices = new List<IBluetoothDevice>(await bluetooth.GetPairedDevices());
// Discover runs ~12 seconds; cancel to stop sooner. Finish it before connecting - an inquiry
// slows connections on the same radio to a crawl.
await foreach (var result in bluetooth.Discover(ct))
{
Console.WriteLine($"{result.Device} {result.Rssi} dBm");
if (!devices.Contains(result.Device)) // equality is by address
devices.Add(result.Device);
}
Filter by class when it helps: device.MajorDeviceClass == BluetoothMajorDeviceClass.Imaging for printers.
Name can be null for a device the OS has never resolved the name of. RSSI belongs to the sighting, so it
is on BluetoothDiscoveryResult, not on the device - paired devices from GetPairedDevices() have none.
IBluetoothDevice is not constructible - get one from GetPairedDevices(), Discover(), GetDevice(address)
or an accepted BluetoothConnection.Device. Do not write a class implementing it.
if (!device.IsPaired && !await device.Pair(ct))
return; // the user declined, or the PIN was wrong
device.Connect(..., secure: true) (the default) pairs on the way in anyway on Android/Windows; call Pair
explicitly when you want the prompt to happen at a predictable moment. Pass secure: false for
devices that cannot pair at all.
var serviceId = Guid.Parse("8ce255c0-200a-11e0-ac64-0800200c9a66"); // your own UUID
await using var listener = await bluetooth.Listen(serviceId, "My App Sync", ct: ct);
while (!ct.IsCancellationRequested)
{
var connection = await listener.Accept(ct);
_ = HandleClient(connection, ct); // one task per connection
}
static async Task HandleClient(BluetoothConnection connection, CancellationToken ct)
{
await using (connection)
{
var buffer = new byte[1024];
int read;
while ((read = await connection.Stream.ReadAsync(buffer, ct)) > 0)
await connection.Stream.WriteAsync(buffer.AsMemory(0, read), ct); // echo
}
}
On an accepted connection connection.Device is a full IBluetoothDevice - you can Pair or Connect back to it - but
its Name is only filled in where the platform already knew it.
For other devices to find an unpaired server, make it discoverable (Android/Linux):
if (bluetooth.Capabilities.HasFlag(BluetoothCapabilities.Discoverable))
await bluetooth.RequestDiscoverable(TimeSpan.FromMinutes(2), ct);
A remote disconnect is a read returning 0 (or an IOException). There is no separate
"disconnected" event - the stream is the connection.
<!-- API 31+ -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" /> <!-- only for RequestDiscoverable -->
<!-- API 30 and below -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
RequestAccess returns NotSetup when any of these is missing from the manifest. Discover and
Pair use broadcast receivers registered by the library; nothing else to declare.
Packaged apps declare <DeviceCapability Name="bluetooth" /> and <DeviceCapability Name="radios" />.
Unpackaged apps need nothing.
NSBluetoothAlwaysUsageDescription in Info.plist; com.apple.security.device.bluetooth in the
entitlements when sandboxed. IOBluetooth delivers every callback on the main run loop, so this works
in an AppKit app (including Shiny's macOS hosting) - not in a console app with no NSApplication loop.
bluetoothd running and the process allowed on the system bus for org.bluez (root, or the
bluetooth group under the default policy). Pairing a device that asks for a PIN or confirmation
needs a BlueZ agent - a desktop session has one; on a headless device run bluetoothctl with
agent on / default-agent or pair once by hand. Pair returns false when no agent answers.
Connect needs BlueZ to already know the device (paired, or seen by Discover). Only hci0 is used.
net10.0-ios.ReadAsync as one message. Frame the stream.Discover is still enumerating - finish or cancel the inquiry first.BluetoothConnection / BluetoothListener - the radio link and SDP
record stay up until you do.RequestDiscoverable on Windows/macOS without checking Capabilities.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub shinyorg/skills --plugin shiny57 skills in this plugin
/localizegenGenerate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications/shiny-accessorysetupGenerate code using Shiny.BluetoothLE.AccessorySetup - the system accessory pairing sheet for BLE devices (AccessorySetupKit on iOS 18+, CompanionDeviceManager on Android) with no MFi, no location prompt and no general Bluetooth prompt on iOS; picked accessories open as Shiny.BluetoothLE peripherals, and Android adds background presence (device appeared / disappeared) events/shiny-actorsGenerate code using Shiny.Actors — Orleans-style virtual actors without the ceremony, AOT/trim-clean, running anywhere .NET runs including .NET MAUI and Blazor WebAssembly. Covers actor interfaces and source-generated proxies, the ShinyActorBuilder (AddShinyActors), persistent state with ETags, named states and auto-save, event-sourced JournaledActor with snapshots, state and event migrations, typed streams (durable, implicit consumers), timers and persistent reminders (background jobs via Shiny.Jobs, on-time OS notifications via Shiny.Notifications), concurrency control ([Reentrant], [AlwaysInterleave], [ReadOnly], [StatelessWorker]), call filters and request context, OpenTelemetry traces and metrics, remoting over HTTP (Shiny.Net.HttpServer server, RemoteActorSystem client), mDNS discovery of actor servers, Shiny.DocumentDb storage (SQLite, PostgreSQL, IndexedDB...), and the ActorTestHost testing kit./shiny-agesignalsGenerate code using Shiny.AgeSignals to read the user's age range as the app store shares it - Apple Declared Age Range (iOS / macOS 26+) and Google Play Age Signals (Android) - for app store accountability laws (Texas SB 2420, Utah, Louisiana, California AB 1043) and age-gated features/shiny-aiconversationGenerate code for Shiny.AiConversation v3 - session-based AI conversations for .NET over Microsoft.Extensions.AI with persisted, resumable sessions (IAiSessionManager / IAiSession / IAiTurn), streaming replies, the built-in ask_user tool for typed questions and multiple-choice answers, interruption and supersession, usage and context-window pressure tracking, rolling context compaction, silent assistant memory, conversation search, session titles and long-term memory, session interceptors for tools and prompts, pluggable session/memory stores (in-memory or SQLite via Shiny.AiConversation.Stores.SqliteDocDb), and voice conversations via Shiny.AiConversation.Voice (wake word, push-to-talk, follow-up, quiet-word/barge-in interruption, sentence-streamed text-to-speech over Shiny.Speech, acknowledgement modes, sounds, voice selection tools), the MAUI chat UI via Shiny.AiConversation.Maui (AiChatView bound to a session with streaming bubbles, choice chips, push-to-talk and an AiMemoryView), image attachments with retention, and the use_camera tool via Shiny.AiConversation.Maui.Camera, and AG-UI via Shiny.AiConversation.AgUi (a session as an AG-UI event stream for the Shiny AgentView with ask_user questions as interrupts, the render_ui tool for A2UI surfaces, and a remote AG-UI agent as the chat client)/shiny-appdevicebridgeGenerate code using Shiny.AppDeviceBridge, device bridges on your app's own Shiny.Net.HttpServer that also host a web app (Blazor WebAssembly, React, Vue, any static build) inside a .NET MAUI app on Android, iOS, Mac Catalyst, Windows and the maui-labs macOS and Linux heads — served from a loopback HTTP server, updated over the air from a signed release server, GitHub releases or a provider of your own, and given device access through bridges with typed C# and TypeScript clientsOther plugins' skills for the same job