shinyorg/shiny/shiny-beacons

Claude Code and agent skill by shinyorg/shiny

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

iBeacon and Eddystone ranging, background region monitoring, and broadcasting for .NET MAUI, iOS, Android, macOS, Windows, Linux and Blazor using Shiny.Beacons

Install

npx vskill@latest install shinyorg/shiny/shiny-beacons

SKILL.md

The same SKILL.md was published earlier as shinyorg/shiny/shiny-beacons.

Shiny Beacons

iBeacon and Eddystone ranging, background region monitoring, and broadcasting.

When to Use This Skill

Use this skill when the user needs to:

  • Detect nearby iBeacons and estimate the distance to them
  • Be notified when the device enters or leaves a beacon region, including in the background
  • Read Eddystone UID, URL or TLM (telemetry) frames
  • Turn the device itself into an iBeacon or Eddystone beacon
  • Tune beacon distance/proximity accuracy
  • Diagnose why beacon distances are jumping around, or why a region never fires

Library Overview

PropertyValue
NuGetShiny.Beacons
NamespaceShiny.Beacons
PlatformsiOS, Mac Catalyst, macOS, Android, Windows, Linux, Blazor WebAssembly. No tvOS target — tvOS binds no CLBeacon* type at all
DI NamespaceShiny (extension methods on IServiceCollection)
Depends onShiny.BluetoothLE, Shiny.BluetoothLE.Hosting

The one thing to understand first

iBeacon and Eddystone travel through different parts of a BLE advertisement, and that dictates everything else.

  • iBeacon is manufacturer data under Apple's company id 0x004C. CoreBluetooth strips it

from every scan result on iOS, Mac Catalyst and macOS. There is no scan configuration that gets it back. So on Apple platforms iBeacon goes through CoreLocation and costs a location permission. Everywhere else Shiny parses the advertisement directly and it costs a Bluetooth permission.

  • Eddystone is service data under UUID 0xFEAA, which CoreBluetooth passes through untouched.

It behaves identically on every platform, Apple included.

Never tell a user that an iOS app can range iBeacons over IBleManager.Scan(). It cannot.

Setup

csharp
// Foreground ranging - "which beacons are near me and how far?"
services.AddBeaconRanging();
// Background region monitoring - "tell me when I enter/leave"
services.AddBeaconMonitoring<MyBeaconMonitorDelegate>();
// Eddystone frames (works everywhere, including Apple)
services.AddEddystoneScanning();
// Become a beacon
services.AddBeaconBroadcasting();

All four accept an optional BeaconRangingOptions. AddBeaconMonitoring also wires the default repository so regions survive a process restart. On every platform the monitoring comes back up at startup on its own (Windows, Linux and Blazor restart the BLE scan as a startup task), and a monitoring scan that fails (Bluetooth switched off) is retried after RegionExitTimeout - so don't generate code that calls StartMonitoring again on launch just to resume.

On Linux or any plain-.NET host, register a IBleManager first (AddBluetoothLE() from Shiny.BluetoothLE.Linux) — the beacon registrations throw a named error if none is present.

Ranging

csharp
public class BeaconViewModel(IBeaconRangingManager ranging)
{
IDisposable? sub;
public async Task Start()
{
var access = await ranging.RequestAccess();
if (access != AccessState.Available)
return;
var region = new BeaconRegion("store-front", Guid.Parse("B9407F30-F5F8-466E-AFF9-25556B57FE6D"));
this.sub = ranging
.WhenBeaconRanged(region)
.Subscribe(beacon =>
{
// beacon.Distance is metres, beacon.Proximity is the bucket
Console.WriteLine($"{beacon.Major}/{beacon.Minor}: {beacon.Distance:N1}m ({beacon.Proximity})");
});
}
public void Stop() => this.sub?.Dispose();
}

Ranging starts on first subscription and stops when the last subscription is disposed. It is a foreground activity — use monitoring for anything that has to work with the app closed.

ManagedBeaconScan for UI

WhenBeaconRanged emits once per advertisement, which is far too chatty to bind a list to. Use the managed scan, which keeps one entry per beacon and updates it in place:

csharp
var scan = ranging.CreateManagedScan();
await scan.Start(region, scheduler, clearTime: TimeSpan.FromSeconds(15));
// scan.Beacons is an INotifyReadOnlyCollection<ManagedBeacon>

clearTime drops beacons that stop advertising, so the list reflects what is actually in range.

Monitoring

csharp
public class MyBeaconMonitorDelegate(INotificationManager notifications) : IBeaconMonitorDelegate
{
public Task OnStatusChanged(BeaconRegionState newStatus, BeaconRegion region)
=> notifications.Send("Beacons", $"{region.Identifier}: {newStatus}");
}
// somewhere in your app
var access = await monitoring.RequestAccess(); // asks for ALWAYS location on Apple
if (access == AccessState.Available)
await monitoring.StartMonitoring(new BeaconRegion("store-front", uuid, major: 1));

Monitored regions are persisted and re-armed on the next launch. Monitoring reports only entry/exit — it never reports distance. Range the region in the foreground when you need that.

A region the device is already inside reports Entered right after StartMonitoring on Android and on iOS / Mac Catalyst 18+. iOS below 18 does not - call RequestState(region) there if the starting state matters. On Apple, RequestAccess() returns Restricted while only when-in-use is granted. The first upgrade request waits up to 30 seconds for the user's answer; iOS shows that prompt once, so later calls return straight away and the user has to change it in Settings.

Eddystone

csharp
var access = await scanner.RequestAccess();
scanner.WhenFrameReceived().Subscribe(frame =>
{
switch (frame)
{
case EddystoneUidFrame uid:
Console.WriteLine($"{uid.Uid.Namespace}/{uid.Uid.Instance} at {uid.Distance:N1}m");
break;
case EddystoneUrlFrame url:
Console.WriteLine(url.Url);
break;
case EddystoneTlmFrame { IsEncrypted: false } tlm:
// BatteryVolts is null on a mains-powered beacon, TemperatureCelsius null with no sensor
Console.WriteLine($"{tlm.BatteryVolts}V {tlm.TemperatureCelsius}C up {tlm.Uptime}");
break;
}
});

Correlate a TLM frame with the beacon's UID/URL frame using frame.PeripheralId — a beacon interleaves frame types, and only the peripheral identifier ties them together.

EID frames surface their raw rotating identifier as EddystoneEidFrame.EphemeralId. Resolving one back to a registered beacon needs the deployment's identity key and the Curve25519/AES-EAX derivation from the spec, which this library does not implement.

Broadcasting

csharp
await broadcaster.StartIBeacon(uuid, major: 1, minor: 2);
await broadcaster.StartEddystoneUid(EddystoneUid.Parse("0102030405060708090A", "0B0C0D0E0F10"));
await broadcaster.StartEddystoneUrl("https://shinylib.net/");
broadcaster.Stop();

Only one advertisement runs at a time; starting a second replaces the first.

Code Generation Instructions

  1. Always `RequestAccess()` and check the `AccessState` before ranging, monitoring or broadcasting.
  2. Inject the managers (IBeaconRangingManager, IBeaconMonitoringManager, IEddystoneScanner,

IBeaconBroadcaster) — never instantiate them.

  1. Dispose the ranging subscription. Ranging runs until the last subscriber goes away; leaving a

subscription alive keeps the radio (and on Apple, CoreLocation) busy.

  1. `BeaconRegion` requires a unique `Identifier` and a UUID. Major is optional; Minor requires

Major. 0 is a legal value for both — do not treat it as "unset".

  1. Use `IBeaconMonitorDelegate` for background transitions, never a subscription. The app may not

be running when the transition fires.

  1. Bind lists through `ManagedBeaconScan`, not through raw WhenBeaconRanged output.
  2. Prefer `Beacon.Distance` over `Beacon.Rssi` in user-facing code. Rssi is the raw single-packet

reading and is very noisy; Distance is computed from filtered signal.

  1. `Beacon.TxPower` is null on Apple platforms. CoreLocation never surfaces the raw advertisement.

Do not write code that requires it cross-platform.

  1. Do not compare `Beacon` records for identity — every observation differs in RSSI and timestamp.

Use Beacon.Identity (a BeaconIdentity of UUID/major/minor).

  1. Use `IBeaconPacket` (in Shiny.BluetoothLE) to read or build a raw iBeacon payload. Never

hand-roll it with Guid.ToByteArray() or BitConverter.GetBytes() — both are little-endian and iBeacon is big-endian throughout.

Tuning distance accuracy

Everything lives on BeaconRangingOptions, passed to the Add* call:

csharp
services.AddBeaconRanging(new BeaconRangingOptions
{
// cluttered indoor space attenuates faster than free space (2.0)
DistanceEstimator = new PathLossDistanceEstimator(3.0),
// shorter window reacts faster to movement; longer reads more steadily when stationary
RssiFilterWindow = TimeSpan.FromSeconds(10),
// when a beacon advertises no calibration value
DefaultTxPower = -59,
ImmediateThreshold = 0.5,
NearThreshold = 3.0,
RegionExitTimeout = TimeSpan.FromSeconds(30)
});
  • `PathLossDistanceEstimator` (default) — d = 10^((txPower - rssi) / (10n)). Hardware-neutral

and predictable. Raise n towards 3-4 indoors.

  • `CurveFitDistanceEstimator` — the Radius Networks/AltBeacon empirical fit. Use it for parity

with other Android beacon stacks; its constants were fitted to one specific device.

  • Implement IBeaconDistanceEstimator for your own model.
Scan filter (ServiceUuids)

ServiceUuids filters the BLE scan wherever beacons come from one (Android, Windows, Linux, Blazor, plain .NET); Apple platforms use CoreLocation and ignore it. An iBeacon advertises no service UUID (the region UUID is a field inside the manufacturer data, not a service UUID), so never put the region's proximity UUID here. Set it only when the beacons also advertise a vendor service UUID in the same packet — only advertisements carrying one are reported, so a beacon that sends it in a separate packet is never seen:

csharp
services.AddBeaconMonitoring<MyDelegate>(new BeaconRangingOptions
{
// WRONG: ["B9407F30-F5F8-466E-AFF9-25556B57FE6D"] - that is the region UUID, nothing advertises it as a service
ServiceUuids = ["<vendor service uuid>"] // must be in the SAME packet as the iBeacon data
});

With no ServiceUuids, Android filters on Apple's iBeacon identifier (company 0x004C, payload starting 0x02 0x15) automatically, because Android delivers nothing from an unfiltered scan while the screen is off. Other platforms scan unfiltered. With AllowNonAppleCompanyId = true and no ServiceUuids, Android scans unfiltered too (those payloads use other company ids), so it stops while the screen is off.

Samples are always fed through a windowed trimmed-mean filter first (RssiFilter), which is what actually removes the jitter. On Apple platforms CoreLocation does its own filtering and hands back a distance directly, so the filter and estimator are bypassed there — only the thresholds apply.

Conventions

  • Proximity: Unknown, Immediate (<0.5m), Near (<3m), Far.
  • BeaconRegionState: Unknown, Entered, Exited.
  • Beacon.Distance is metres; a negative value means unknown, not "very close".
  • EddystoneUid is a value type; Namespace is 20 hex chars, Instance is 12.
  • Eddystone calibrates transmit power at 0 metres, iBeacon at 1 metre — a 41 dBm difference

the parser accounts for. Do not "fix" an Eddystone TxPower by comparing it to an iBeacon one.

  • AccessState is from Shiny.Core: Available, Denied, Disabled, Restricted, NotSupported, Unknown.

Platform Notes

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

Popularity

7-day trend score
0

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/shinyorg/shiny/shiny-beacons/badge)](https://verified-skill.com/skills/shinyorg/shiny/shiny-beacons)

Something wrong with this skill or its page? Tell us.