This project has moved. For the latest updates, please go here.

bluetooth listener cannot detect bluetooth connection

Topics: Bluetooth - Other
Dec 7, 2012 at 10:04 AM
Edited Dec 7, 2012 at 10:05 AM


I am trying to use bluetooth to detect if a phone is connected to my computer. after reading the documentation, i think i must followexample for bluetooth listener in this link:

my program is in c#and i am trying to listen on the specified service identifier(in my case, bluetoothsevice.handsfree).

here are my program:


bl = new BluetoothListener(BluetoothService.Handsfree);
bl.ServiceName = BluetoothService.GetName(BluetoothService.RFCommProtocol);// "32feet.NET Chat2";
      bc = bl.AcceptBluetoothClient();


when i run this part, application stuck in line

bc = bl.AcceptBluetoothClient();

has anyone meet this problem? is the problem from my program or also from bluetooth setting?

Dec 8, 2012 at 3:26 PM

That won't work. BluetoothListener is used to accept a connection to a particular application/service on the device. Unless the client device has an application that connects to that particular service then BtLsnr won't get a connection and thus will never return from a call to Accept.

If you're using desktop Windows the Microsoft stack then use BluetoothDeviceInfo.Connected, e.g.

BluetoothAddr myAddr = .......
var dev = new BluetoothDeviceInfo(myAddr);
var connected = dev.Connected;

As you'll see from the only other platform that has any support for Connected is BlueSoleil.