Adapters, Discovery & Pairing
Everything on the Classic side begins here. Until an adapter is enabled and a device is paired, no profile service has anything to do.
All of this is on BluetoothServiceClient, and all of it is per adapter.
Important
Bluetooth Classic is OpenView Pro only. This page and every other page under Bluetooth Classic and Application Helpers apply to Pro. Classic is not supported on OpenView Select — if that is your target, start at BLE Overview instead. See Supported & Not Supported.
Table of Contents
Enabling an Adapter
bluetoothClient.EnableAdapter(adapterIndex, pairingAgentTimeout);
pairingAgentTimeout is in seconds and governs how long the pairing agent waits for your application
to answer a confirmation request before giving up. The Classic demo uses 30.
Enabling is asynchronous, and the result arrives as AdapterEnabled. Check IsEnabled — this
notification reports failure as well as success:
case BluetoothMessageTypes.Ids.AdapterEnabled
when e.NotificationObject is BluetoothAdapterState state:
if (state.IsEnabled)
// adapter state.AdapterIndex is up
else
// it failed to come up; state.LastResult carries detail
break;
BluetoothAdapterState is the adapter's whole story in one object:
| Property | Meaning |
|---|---|
AdapterIndex |
Which adapter this is about |
IsEnabled |
Whether it is powered on |
IsDiscoverable, DiscoverableTimeout |
Current discoverable mode (both nullable) |
IsPairable, PairableTimeout |
Current pairable mode (both nullable) |
IsPolling |
Whether a discovery session is running |
LastResult |
Outcome of the most recent operation |
You can ask for it at any time with RequestAdapterState(adapterIndex), which returns it directly —
one of the few calls that does not answer by notification.
DisableAdapter(adapterIndex) powers the adapter down and reports AdapterDisabled.
Note
On a display, adapters normally come up in response to the device service reporting the hardware
ready. On the desktop stack that notification never fires, so the demo enables adapters eagerly after
checking config.Stack == SupportedBluetoothStack.StackDesktop. If your application hangs waiting for
an adapter on Windows, this is why.
Discoverable and Pairable
Two separate modes. Discoverable means a phone scanning nearby can see the display. Pairable means the display will accept a bonding attempt. A device that already knows the display can connect without it being discoverable.
// Visible for 180 seconds
bluetoothClient.SetAdapterDiscoverable(new BluetoothAdapterDiscoverableRequest
{
AdapterIndex = adapterIndex,
IsDiscoverable = true,
DiscoverableTimeout = 180
});
// Visible until told otherwise
bluetoothClient.SetAdapterDiscoverable(new BluetoothAdapterDiscoverableRequest
{
AdapterIndex = adapterIndex,
IsDiscoverable = true,
DiscoverableTimeout = 0
});
// Hidden
bluetoothClient.SetAdapterDiscoverable(new BluetoothAdapterDiscoverableRequest
{
AdapterIndex = adapterIndex,
IsDiscoverable = false
});
PairableTimeout behaves identically on BluetoothAdapterPairableRequest with IsPairable.
Both timeouts are uint?:
| Value | Effect |
|---|---|
| A positive number | Stay on for that many seconds, then revert |
0 |
Stay on indefinitely |
omitted (null) |
Use the adapter's default |
Neither call reports its result by return value. Drive your UI from AdapterDiscoverableChanged and
AdapterPairableChanged, and guard against re-entry while a toggle is in flight — the demo's
AdapterPanel keeps a discoverableStatePending flag for exactly this, because the button text is
updated by the notification rather than by the click.
Discovery
Discovery is a time-boxed session, not a query:
bluetoothClient.StartDiscovery(new BluetoothDiscoveryRequest
{
AdapterIndex = adapterIndex,
DiscoveryTimeout = 30
});
The returned BluetoothResult means "the request was accepted". Results arrive as notifications:
| Notification | Payload | Meaning |
|---|---|---|
DiscoveredDeviceAdded |
BluetoothDeviceDiscoveryInfo |
A device was found |
DiscoveredDeviceRemoved |
BluetoothDeviceDiscoveryInfo |
A previously found device went away |
DiscoveryComplete |
— | The window closed |
StopDiscovery(adapterIndex) ends the session early.
Two things about discovery results:
- They are filtered.
allowedDeviceClassesin adapter configuration suppresses devices whose Class of Device does not match, so a device that is genuinely nearby may never be reported. See Configuration Reference. - Capability information is incomplete. A discovered device's advertised profile flags are not authoritative until it has been paired. Classify discovery results by Class of Device, not by profile flags.
Pairing
The display is the pairing agent, which means your application is in the loop. Pass back the
BluetoothDeviceDiscoveryInfo you received from discovery:
bluetoothClient.RequestToPair(new BluetoothPairRequest { DeviceInfo = discovered });
sequenceDiagram
participant App as Your Application
participant Client as BluetoothServiceClient
participant Svc as BluetoothService
participant BlueZ as BlueZ / pairing agent
participant Phone as Phone
App->>Client: RequestToPair(deviceInfo)
Client->>Svc: pair request
Svc->>BlueZ: Pair()
BlueZ->>Phone: bonding
Phone-->>BlueZ: passkey
BlueZ-->>Svc: agent confirmation request
Svc-->>App: PairingRequested (Passkey)
Note over App: show passkey, wait for user
App->>Client: SendPairingConfirmation(Confirmed)
Client->>Svc: confirmation
Svc->>BlueZ: reply to agent
BlueZ-->>Svc: bonded
Svc-->>App: PairingComplete (BluetoothDevicePairedInfo)
Answering the confirmation:
case BluetoothMessageTypes.Ids.PairingRequested
when e.NotificationObject is BluetoothPairingNotification pairing:
ShowPasskeyPrompt(pairing.AdapterIndex, pairing.Passkey);
break;
// when the user accepts
bluetoothClient.SendPairingConfirmation(new BluetoothPairingConfirmation
{
AdapterIndex = adapterIndex,
Confirmed = true
});

BluetoothPairingNotification carries only AdapterIndex, Passkey, and DisplayOnly, and
BluetoothPairingConfirmation only AdapterIndex and Confirmed — the adapter index is what
correlates the answer to the request, so a multi-adapter application must show the prompt per adapter.
The demo does this by owning a PairingPrompt inside each adapter's panel set.
When DisplayOnly is set, the user types the passkey on the remote device instead of confirming it. Show
the passkey with nothing to accept or reject, do not send a confirmation, and hide it when
PairingComplete arrives with the outcome. On the desktop stack, pairing the simulated "Keyboard 1" takes
this path; its first attempt fails and the retry succeeds.
The pairing notifications:
| Notification | Payload | Meaning |
|---|---|---|
PairingRequested |
BluetoothPairingNotification |
Show the passkey, and answer unless DisplayOnly is set |
PairingComplete |
BluetoothDevicePairedInfo |
The outcome: LastResult.Status is success when bonded, failure when rejected, timed out, or failed |
PairingCanceled |
BluetoothPairingCanceledInfo |
The remote device or BlueZ canceled the request |
UnpairingComplete |
— | Bond removed |
If you never answer PairingRequested, the agent times out after the interval given to
EnableAdapter and you get PairingComplete with a failure status.
Paired Devices and Unpairing
BluetoothPairedDevices paired = bluetoothClient.RequestPairedDevices(adapterIndex);
This returns directly. Each BluetoothDevicePairedInfo is what the rest of the API consumes — profile
connect and disconnect requests all take one:
| Property | Meaning |
|---|---|
AdapterIndex |
Which adapter it is bonded to |
DeviceName |
Friendly name |
DeviceMacAddress |
Address, and the stable identity to key your own state on |
DeviceRssi |
Signal strength |
DeviceClass |
BluetoothClassOfDevice — use for identity |
SupportedProfiles |
BluetoothProfilesFlags — use for capability. Authoritative now that it is paired. |
Uuids |
Raw advertised service UUIDs |
LastResult |
Outcome of the last operation on this device |
Unpair with RequestToUnpair(deviceInfo), confirmed by UnpairingComplete.
Tip
Now that the device is paired, SupportedProfiles can be trusted. Combine it with DeviceClass to
classify: Class of Device for identity, profile flags for capability. See
Class of Device for identity, SDP for capability.
Maintaining the discovered and paired lists — adding, removing, deduplicating, and telling your UI when
they change — is bookkeeping every application ends up writing. DeviceManager
does it for you.
Shutting Down Cleanly
Disable your adapters before the application exits:
foreach (var adapter in config.AdapterConfigurations)
bluetoothClient.DisableAdapter(adapter.AdapterIndex);
This is not politeness. Profile connection state is delivered only by notification and is never replayed, so an application that restarts while a phone is still connected has no way to discover that connection — there is no state query to fall back on. Disabling adapters severs the links, so the next run starts from a known-empty state.
The Classic demo calls DisableAdapters() immediately before ApplicationContext.Exit().