0

Good afternoon . I'm working on a application that is suppose to transfer files from Computer to a Smartphone through Bluetooth but the pairing isn't working how i expected.

Pairing with 32feets Library :

BluetoothEndPoint remoteEndPoint = new BluetoothEndPoint(selecteddevice.DeviceAddress,BluetoothService.ObexFileTransfer); 

The last parameter is suppose to be the Bluetooth adapter GUID . If i feed it by

  1. BluetoothService.SerialPort . I can connect only to Iphone SE

  2. BluetoothService.ObexFileTransfer . I can connect only with Allview Soul Xtream Mini . Also i got a galaxy tab 2 which i can't connect in either ways . I used a catch and the error is the following :

    • ex {"The requested address is not valid in its context 4CBCA5CAA8A0:0000110600001000800000805f9b34fb"} System.Net.Sockets.SocketException

I have done some research and this is what i found : https://32feet.codeplex.com/wikipage?title=Errors

Pairing code :

private void Connect()
      {
           SelectBluetoothDeviceDialog bldialog = new SelectBluetoothDeviceDialog();
           serviceClass = BluetoothService.SerialPort;
           bldialog.ShowAuthenticated = true;
           bldialog.ShowRemembered = true;
           bldialog.ShowUnknown = true;

           if (bldialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
           {
                if (bldialog.SelectedDevice == null)
                {
                     System.Windows.Forms.MessageBox.Show("No device selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return; 
                }                       
                BluetoothDeviceInfo selecteddevice = bldialog.SelectedDevice;
                BluetoothEndPoint remoteEndPoint = new BluetoothEndPoint(selecteddevice.DeviceAddress, BluetoothService.ObexFileTransfer);

                client = new BluetoothClient();
                try
                {
                     client.Connect(remoteEndPoint);
                }
                catch (SocketException ex)
                {
                     return;
                }
                catch (ObjectDisposedException ex)
                {
                     return;
                }
                catch (IOException ex)
                {
                     return;
                }

                textBox.Text += string.Format("Connected to: {0}", selecteddevice.DeviceName);
                textBox.Text += string.Format("Bluetooth Device Browser. Current Device: {0}", selecteddevice.DeviceName);

           }
      }

As Bluetooth i'm using ASUS USB-BT400 . What could i do in order to solve my connection problems ?

ATudor
  • 91
  • 9

1 Answers1

0

I solved the problem like this

       BluetoothDeviceInfo selecteddevice = bldialog.SelectedDevice;
                if (selecteddevice.DeviceName.ToLower().Contains("iphone"))
                     serviceClass = BluetoothService.SerialPort;
                else if (selecteddevice.DeviceName.ToLower().Contains("allview"))
                     serviceClass = new Guid("00001103-0000-1000-8000-00805f9b34fb");
                else serviceClass = BluetoothService.ObexFileTransfer;

Also if someone else got any idea about how i could connect to my galaxy tab i'm listening , i didn't manage to pair with it also .

ATudor
  • 91
  • 9