1

I am trying to connect insecurely using bluetooth to a RFreader. I tried using the bluetooth chat example provided in the sample projects. I am using android 2.3 and above for this.

I have encountered many links for using

createInsecureRfcommSocketToServiceRecord() 

along with

listenUsingInsecureRfcommWithServiceRecord(String, UUID)
  1. I have changed Bluetooth chat example according to my need.
  2. Initially it shows up the list of scanned devices(RF reader shows up).
  3. After selecting a device, the connectThread will be invoked. It will create the BluetoothSocket using createInsecureRfcommSocketToServiceRecord().

  4. Then I am starting the thread which cancels discovery and calls bluetoothSocket.connect().

But, it is failing here giving an **IOException:Service discovery failed**. I have removed the code for AcceptThread() which listens for connections, since I am explicitly connecting by selecting a device from list of scanned devices.

Am I doing any mistake ? Is there any other procedure for connecting to non-UI bluetooth devices ?

Thanks in advance :)

4

1 に答える 1

1

使用している UUID が正しく、Clinet 側とサーバー側で同じである必要があるかどうかを確認します。

RF リーダー側で着信接続を待機していることを確認しますか? つまり、listenUsingInsecureRfcommWithServiceRecord() に相当するものがあります。

于 2013-02-19T23:29:36.943 に答える