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

Bluetooth cant pass from AcceptBluetoothClient

Topics: Bluetooth - Microsoft
Jan 28, 2013 at 3:50 PM

Hi to all, im making one app in windows (server) and an Android one (Client or Sender)

I have the following code and i ve just have no response in the "AcceptBluetoothClient" class.

Im stuck here, dont know if my c# code is not working or the Android one. 

Tell me just how to test something and pass de AcceptBluetoothClient line.

Thanks to all and sorry my english.


 private void btn_soyCliente_Click(object sender, EventArgs e)
             Guid UUID = new Guid("{00000003-0000-1000-8000-00805f9b34fb}");
            BluetoothListener newListener = new BluetoothListener(UUID);
            newListener .ServiceName = "XXXXXX";
            newListener .Authenticate = false;
            newListener .Start();
            BluetoothClient client = newListener.AcceptBluetoothClient();

            Stream stream = client.GetStream();

Im working on Windows 7.

Jan 29, 2013 at 3:13 PM
Edited Jan 29, 2013 at 3:14 PM

Its me again, today im trying to send data from one PC to another  result = false for me.

Here is my code in Server Side : 


 public Form1()
            if (BluetoothRadio.IsSupported)
                BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
                btListener = new BluetoothListener(UUID);                
                btListener.ServiceName = "Ne.on Bluetooth Service";
                btListener.Authenticate = false;
                thHR = new Thread(new ThreadStart(recibiendo));

void recibiendo()
                consolo("Dispositivo a la espera de conexiones entrantes...");                             
                BluetoothClient client = btListener.AcceptBluetoothClient(); //NEVER PASS THIS LINE, STAY HERE FOREVER
                Stream peerStream = client.GetStream();
                var wtr = new StreamReader(peerStream);
                var line = wtr.ReadLine();

                    String asd =btStreamReader.ReadLine();
                buscando = false;
            } while (buscando);


And now the client :



               BluetoothAddress addressSeleccionado = ((ListBoxItem)lsx_devices.SelectedItem).Address;
                consolo("Me preparo para conectar con : " + addressSeleccionado.ToString() );
                var ep = new BluetoothEndPoint(addressSeleccionado, UUID);
                InTheHand.Net.Sockets.BluetoothClient cli = new InTheHand.Net.Sockets.BluetoothClient();
                System.Net.Sockets.NetworkStream peerStream = cli.GetStream();
                consolo("Conecci�n realizada.");
                var wtr = new StreamWriter(peerStream);
                consolo("Fin Envio");


My GUID is the same in both apps :  private Guid UUID = new Guid("{00000003-0000-1000-8000-00805f9b34fb}");

My test is that i discover devices, then i select one and try to connect , and this come to end, but my server side still in the 

AcceptBluetoothClient() Line, never pass throught. 

Any suggestion what i have wrong so i can finally handle data between both pcs?

Jan 30, 2013 at 7:42 AM

Hi, i figured out that changing the UUID for a new one made by Visual Studio Guid Generator and everything works fine now.


Now im back to Android conection. Wish me luck


Jan 30, 2013 at 6:57 PM

I'm glad you good it working.

UUID 0x0003 -- that's the shorthand for the long UUID in your code -- is the value for RFCOMM. Using it has the service database search find *any* service using RFCOMM. So apparently there were other services on the target and the client was connecting to some other server.

Jan 31, 2013 at 12:05 PM
Hi Alan,

I have a quick question, what object do i have to close or dispose when a client is detected or connected?

Im trying to connect with 2 or 3 different android devices and sometimes works and sometimes don´t .

Best wishes for u.
Feb 1, 2013 at 12:29 PM
Close the Listener if you want to Accept no more connections.

Close individual Clients/NetworkStreams if you don't want to communicate with that client connection again.