NOW LOADING

MidiBluetoothConnectionState


How far along a Bluetooth MIDI device is in getting connected
Namespace Windows.Devices.Midi2.Transports.Bluetooth
Type Name MidiBluetoothConnectionState
Type WinRT Enumeration (a 32-bit unsigned or signed integer)
IDL MidiBluetoothConnectionStateEnum.idl

Reported by MidiBluetoothDeviceInformation.ConnectionState.

Connecting to a Bluetooth Low Energy device is not quick. The service opens a GATT session on a background worker, which takes seconds, and a device the customer has asked for stays wanted and is retried until it appears. IsConnected alone therefore cannot tell an attempt which is under way from a device which is simply switched off, which is why this exists.

Disconnecting a device in any state other than NotConnected cancels the request, so it is also the way to stop the service waiting for a device which is never coming back.

Values

Value Numeric Value Description
NotConnected 0 Not connected, and the service is not trying. A device which needs pairing also reports this, because retries are suspended until it is paired.
WaitingForDevice 1 Wanted, but the device has not been reachable yet. The service keeps retrying for as long as it stays wanted.
Connecting 2 An attempt is running right now.
Connected 3 Connected.

An application showing a connect button will usually want to hide or disable it for anything other than NotConnected, and offer disconnect instead, so a customer cannot queue attempt after attempt while one is already in flight.

Didn't find what you were looking for?

Windows MIDI Services is an open source project with all source available on GitHub. We have a great community on Discord as well. Between GitHub and Discord, you should find the information you are looking for.