This project has moved. 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 2:19 PM by alanjmcf, version 9


kakerkhan Feb 26, 2015 at 8:42 AM 
Hi Sir,
Iam working on this piece of code to detect if a paired device is in range or not. but i didn't understand the code kindly i need a sample in c# , is appriciated .

nakram Apr 26, 2014 at 7:00 AM 
The library is good, but the following line in the above example is confusing:
BluetoothDeviceInfo device = ...

Can you please comment it or clarify what should be the RHS value?

zaxbowow Jun 30, 2011 at 9:38 PM 
This method takes just as long as a pair request, which would return the same information (success) if the device is within range. I was hoping to improve device in-range recognition speed (especially for large numbers of devices); this doesn't help in this regard.