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

Chaitanya
  • 3,399
  • 6
  • 29
  • 47

1 Answers1

1

Check if the UUID you are using is correct and should be the same at the Clinet and the Server sides.

Ensure that on the RF reader side it is waiting for incoming connection ? i.e there is an equivalent of the listenUsingInsecureRfcommWithServiceRecord().

Dennis Mathews
  • 6,897
  • 2
  • 26
  • 39
  • Ok. So, for the RF reader also has a UUID which has to be used in android app ? How should we check if the RF reader is waiting for connection ? So, the only means for establishing a connection for non-UI devices is, they should be waiting like a server. Am I correct for the last statement ? – Chaitanya Feb 20 '13 at 05:19
  • So, we will have to make use of UUID used within the RF reader ? Where can we get this UUID from ? Device manfacturer ? – Chaitanya Feb 20 '13 at 07:09