起初我不得不说,我是android的初学者。我正在开发一款应用程序,该应用程序应通过蓝牙连接到没有任何操作元件(无按钮,无显示)的测量仪器,并接收测量数据。不幸的是,我对测量仪器和制造商也不太了解。我知道的一切是,我必须通过RFCOMM进行通信,当我与android配对时,我必须将序列号作为PIN(09000)发送。 这项工作到目前为止。 Andorid与设备配对。尝试连接时,它首先建立连接,然后在几秒钟后中断连接。我正在使用三星Galaxy S3和HTC Sensation。
在这里,您可以找到我完整的蓝牙连接类:
http://iukp.chefti.com/JAVA/AndroidBluetooth.java
以下是logcat输出以获取更多参考:
12-22 17:24:56.104: I/System.out(6079): ConnectThread()
12-22 17:24:56.104: V/BluetoothSocket.cpp(6079): initSocketNative
12-22 17:24:56.104: V/BluetoothSocket.cpp(6079): ...fd 51 created (RFCOMM, lm = 26)
12-22 17:24:56.104: V/BluetoothSocket.cpp(6079): initSocketFromFdNative
12-22 17:24:56.109: I/System.out(6079): ConnectThread() try succesfull
12-22 17:24:56.114: I/System.out(6079): ConnectThread.run()
12-22 17:24:56.114: I/System.out(6079): mmSocket.connect 0.1()
12-22 17:24:56.124: D/BluetoothUtils(6079): isSocketAllowedBySecurityPolicy start : device null
12-22 17:24:57.109: V/BluetoothSocket.cpp(6079): connectNative
12-22 17:24:57.174: V/BluetoothSocket.cpp(6079): ...connect(51, RFCOMM) = 0 (errno 115)
12-22 17:24:57.179: I/System.out(6079): true
12-22 17:24:57.184: I/System.out(6079): ConnectedThread()
12-22 17:24:57.184: I/System.out(6079): socket.X tried
12-22 17:24:57.184: I/System.out(6079): manageConnectedSocket()
12-22 17:24:57.184: I/System.out(6079): run()
12-22 17:24:57.184: I/System.out(6079): ConnectThread() try succesfull - run()
12-22 17:24:57.184: I/System.out(6079): SON F BICHT
12-22 17:24:57.184: I/Choreographer(6079): Skipped 67 frames! The application may be doing too much work on its main thread.
12-22 17:24:58.189: D/dalvikvm(6079): GC_CONCURRENT freed 91K, 6% free 12469K/13191K, paused 21ms+4ms, total 76ms
12-22 17:24:58.209: V/BluetoothSocket.cpp(6079): abortNative
12-22 17:24:58.209: V/BluetoothSocket.cpp(6079): ...asocket_abort(51) complete
12-22 17:24:58.209: V/BluetoothSocket.cpp(6079): destroyNative
12-22 17:24:58.209: V/BluetoothSocket.cpp(6079): ...asocket_destroy(51) complete
任何提示或建议都将不胜感激。抱歉我的英语不好。
答案 0 :(得分:3)