Not returning from accept when trying to listen to bluetooth communication - Android -
i'm trying establish bluetooth communication between android phone/tablet (4.0.3), , bluetooth device, earring reader (destron fearring dtr3e, in case want know, don't suppose do).
i paired phone reader (the reader has pairing passcode on tag) bluetooth settings, bluetooth on of course, , i'm trying listen reads device, means of bluetoothserversocket. problem accept call never returns, doing wrong. communication done using rfcomm.
code:
private class acceptthread extends thread { private final bluetoothserversocket mmserversocket; public acceptthread() { // use temporary object later assigned mmserversocket, // because mmserversocket final bluetoothserversocket tmp = null; try { // my_uuid app's uuid string, used client code string uuid = "00001101-0000-1000-8000-00805f9b34fb"; tmp = bluetoothadapter.listenusinginsecurerfcommwithservicerecord("pdfparserserver", uuid.fromstring(uuid)); } catch (exception e) { e.printstacktrace(); } mmserversocket = tmp; } public void run() { bluetoothsocket socket = null; // keep listening until exception occurs or socket returned while (true) { try { socket = mmserversocket.accept(); } catch (ioexception e) { break; } // if connection accepted if (socket != null) { // work manage connection (in separate thread) try { mmserversocket.close(); } catch (ioexception e) { e.printstacktrace(); } break; } } } /** cancel listening socket, , cause thread finish */ public void cancel() { try { mmserversocket.close(); } catch (ioexception e) { } } }
is there missing?
thank you!
the reason cause code never come accept that, device "destron fearring dtr3e" trying connect to, has bluetoothserver socket , not bluetooth client, hence, device might waiting connect it, in stead of creating bluetoothserver socket , waiting connect android device, should read specs on device , make sure 1 has open connection on "destron fearring dtr3e" socket...
hope helps...
regards!
Comments
Post a Comment