2

首先,我不得不说,我是 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

任何提示或建议将不胜感激。对不起,我的英语不好。

4

1 回答 1

3

自从你大约六个月前问过这个问题以来,我希望你已经解决了你的问题,但对于其他人来说,你的问题可能与此有关:

带有 Galaxy S3 的 Android 蓝牙 SPP

查看该问题的答案。

于 2013-07-04T10:24:30.893 回答