-
-
Notifications
You must be signed in to change notification settings - Fork 209
BluetoothWin32Events
The Microsoft Bluetooth stack on Window raises events for various Bluetooth actions. We expose that feature via class BluetoothWin32Events.
Currently it raises two types of event: in-range and out-of-range using classes: BluetoothWin32RadioInRangeEventArgs and BluetoothWin32RadioOutOfRangeEventArgs. Both have properties Device which return a BluetoothDeviceInfo. Then the in-range event also includes a set of flags, which in Windows XP are: Address, Cod, Name, Paired, Personal, and Connected; more events are available in Windows 7. These events are provided on the BluetoothWin32RadioInRangeEventArgs class via properties: CurrentState and PreviousState, and also GainedStates etc.
To see the events get an instance of class BluetoothWin32Events via its method GetInstance. Then one should register for the events on that class and keep a reference to the instance.
Note that just being in range is not enough for devices to know that the other is present. Without running device discovery or a connection attempt the two devices will not see each other. Note however that Windows XP does not raise events when running device discovery (inquiry), this is fixed in Windows 7 (probably Vista). See 32feet blog Device Discovery improvements on MSFT+Win32 for more information.
For example when connecting and disconnecting on Windows XP to another device that is not paired we see:
12:23:48.9582648: InRange 000A3A6865BB 'joe',
now 'Address, Cod, Name, Connected'
was 'Address, Cod, Name'.
12:24:16.8009456: InRange 000A3A6865BB 'joe',
now 'Address, Cod, Name'
was 'Address, Cod, Name, Connected'.
For example when connecting and then disconnecting on Windows 7 to another v2.1 device that is paired with we see:
20:53:25.5605469: InRange 00190E02C916 'alanlt2ws',
now 'Address, Cod, Name, Paired, Personal, Connected, SspSupported, SspPaired, Rssi, Eir'
was 'Address, Cod, Name, Paired, Personal, SspSupported, SspPaired, Rssi, Eir'.
20:53:27.7949219: InRange 00190E02C916 'fred',
now 'Address, Cod, Name, Paired, Personal, SspSupported, SspPaired, Rssi, Eir'
was 'Address, Cod, Name, Paired, Personal, Connected, SspSupported, SspPaired, Rssi, Eir'.
32feet.NET - Personal Area Networking for .NET
In The Hand Ltd