This project has moved and is read-only. For the latest updates, please go here.

Testing if a device is in range

If you want to test solely whether a particular device is in range then do a lookup for a 'fake' Class Id e.g.

bool inRange;
Guid fakeUuid = new Guid("{F13F471D-47CB-41d6-9609-BAD0690BF891}"); // A specially created value, so no matches.
BluetoothDeviceInfo device = ...
try {
   ServiceRecord[] records = device.GetServiceRecords(uuid);
   Debug.Assert(records.Length == 0, "Why are we getting any records?? len: " + records.Length);
   inRange = true;
} catch (SocketException) {
   inRange = false;
If a device comes into range but neither it nor the local device attempt a connection nor are running discovery, then neither will know they are in range.

Access to the in-range and out-of range events are available on the Microsoft stack on Win32 and they behave as described there, see class BluetoothWin32Events.

Last edited Mar 8, 2013 at 3:19 PM by alanjmcf, version 9