2017-04-26 79 views
0

下午好。 我正在研究一個應用程序,它假設通過藍牙將文件從計算機傳輸到智能手機,但配對無法正常工作。藍牙串口與ObexFileTransfer

配對與32feets庫:

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

最後一個參數被假設是藍牙適配器GUID。如果我通過

  1. BluetoothService.SerialPort餵養它。我只能連接到Iphone SE

  2. BluetoothService.ObexFileTransfer。我只能連接Allview Soul Xtream Mini。 另外我得到了一個星系標籤2,我無法以任何方式連接。 我用了一個接受器和錯誤是:

    • 前{ 「的請求的地址不在其上下文4CBCA5CAA8A0有效:0000110600001000800000805f9b34fb」} System.Net.Sockets.SocketException

我已經做了一些研究,這是我發現: https://32feet.codeplex.com/wikipage?title=Errors

配對碼:

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); 

      } 
     } 

由於藍牙我正在使用華碩USB-BT400。 我能做些什麼來解決我的連接問題?

回答

0

我解決了這個問題這樣

 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; 

另外,如果別人得到有關如何我可以連接到我的galaxy tab我聽着,我沒任何想法,也與它配對。