为什么Android>2.2中保留蓝牙SPP UUID?

发布于 2024-10-30 16:27:43 字数 3302 浏览 0 评论 0原文

我正在开发一个 Android 应用程序 通过蓝牙与另一台设备通信。

它打开一个蓝牙服务器套接字 SPP 通信的著名标准 UUID: (00001101-0000-1000-8000-00805F9B34FB)。

但自从我的 Archos 平板电脑上的 Android 2.2 更新后,此操作失败并出现异常, 说这个UUID是保留的。

在 Android 2.1 的 Milestone 上,相同的代码可以正常运行。

为什么这个UUID被保留? 在 Android 源代码中,我可以看到保留的 UUID 数组,但不包括 SPP ID。

请参阅:http://grepcode.com/file/repository....RESERVED_UUIDS

有人知道可以使用给定 UUID 打开蓝牙套接字的解决方法吗?

日志中的异常堆栈跟踪:

W/BluetoothService( 1290): Attempted to register a reserved UUID: 00001101-0000-1000-8000-00805f9b34fb
E/BluetoothService(20201): Socket listen() failed
E/BluetoothService(20201): java.io.IOException: Not able to register SDP record for GlucoTel SPP
E/BluetoothService(20201): at android.bluetooth.BluetoothAdapter.listenUsingRfco mmWithServiceRecord(BluetoothAdapter.java:778)
E/BluetoothService(20201): at com.bodytel.android.BluetoothService$AcceptThread. <init>(BluetoothService.java:285)
E/BluetoothService(20201): at com.bodytel.android.BluetoothService.start(Bluetoo thService.java:156)
E/BluetoothService(20201): at com.bodytel.android.BodytelAndroidClient.onResume( BodytelAndroidClient.java:246)
E/BluetoothService(20201): at android.app.Instrumentation.callActivityOnResume(I nstrumentation.java:1149)
E/BluetoothService(20201): at android.app.Activity.performResume(Activity.java:3 823)
E/BluetoothService(20201): at android.app.ActivityThread.performResumeActivity(A ctivityThread.java:3118)
E/BluetoothService(20201): at android.app.ActivityThread.handleResumeActivity(Ac tivityThread.java:3143)
E/BluetoothService(20201): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2684)
E/BluetoothService(20201): at android.app.ActivityThread.access$2300(ActivityThr ead.java:125)
E/BluetoothService(20201): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:2033)
E/BluetoothService(20201): at android.os.Handler.dispatchMessage(Handler.java:99 )
E/BluetoothService(20201): at android.os.Looper.loop(Looper.java:123)
E/BluetoothService(20201): at android.app.ActivityThread.main(ActivityThread.jav a:4627)
E/BluetoothService(20201): at java.lang.reflect.Method.invokeNative(Native Method)
E/BluetoothService(20201): at java.lang.reflect.Method.invoke(Method.java:521)
E/BluetoothService(20201): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:868)
E/BluetoothService(20201): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:626)
E/BluetoothService(20201): at dalvik.system.NativeStart.main(Native Method)

我们用来打开蓝牙套接字的 Android Java 代码片段:

private static final String BT_NAME = "GlucoTel SPP";
private static final UUID BT_ID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
.....
BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothServerSocket socket = mAdapter.listenUsingRfcommWithServiceRecord(BT_NAM E, BT_ID);
.....
socket = mmServerSocket.accept();

我们在以下设备上观察到此问题:

测试设备 1:
- 爱可视 32
- 固件2.1.8(Android 2.2.1)
- 开发板版本:A32-V5

测试设备2:
- 爱可视 101
- 固件2.0.54(Android 2.2.1)
- 开发板版本 A101IT-V6

感谢您的任何想法或反馈!

I am working on an Android Application that
communicates with another device via bluetooth.

It opens a Bluetooth Server Socket with
the well-known standard UUID for SPP communication:
(00001101-0000-1000-8000-00805F9B34FB).

But since the Android 2.2 update on my Archos Tablet this fails with an exception,
saying that this UUID is reserved.

On a Milestone with Android 2.1 the same code works without problems.

Why is this UUID reserved?
In the Android Source I can see the Array of reserved UUIDs, but the SPP ID is not included.

see: http://grepcode.com/file/repository....RESERVED_UUIDS

Does anybody know a workaround that would enable opening a bluetooth socket with the given UUID?

The exception stacktrace from the log:

W/BluetoothService( 1290): Attempted to register a reserved UUID: 00001101-0000-1000-8000-00805f9b34fb
E/BluetoothService(20201): Socket listen() failed
E/BluetoothService(20201): java.io.IOException: Not able to register SDP record for GlucoTel SPP
E/BluetoothService(20201): at android.bluetooth.BluetoothAdapter.listenUsingRfco mmWithServiceRecord(BluetoothAdapter.java:778)
E/BluetoothService(20201): at com.bodytel.android.BluetoothService$AcceptThread. <init>(BluetoothService.java:285)
E/BluetoothService(20201): at com.bodytel.android.BluetoothService.start(Bluetoo thService.java:156)
E/BluetoothService(20201): at com.bodytel.android.BodytelAndroidClient.onResume( BodytelAndroidClient.java:246)
E/BluetoothService(20201): at android.app.Instrumentation.callActivityOnResume(I nstrumentation.java:1149)
E/BluetoothService(20201): at android.app.Activity.performResume(Activity.java:3 823)
E/BluetoothService(20201): at android.app.ActivityThread.performResumeActivity(A ctivityThread.java:3118)
E/BluetoothService(20201): at android.app.ActivityThread.handleResumeActivity(Ac tivityThread.java:3143)
E/BluetoothService(20201): at android.app.ActivityThread.handleLaunchActivity(Ac tivityThread.java:2684)
E/BluetoothService(20201): at android.app.ActivityThread.access$2300(ActivityThr ead.java:125)
E/BluetoothService(20201): at android.app.ActivityThread$H.handleMessage(Activit yThread.java:2033)
E/BluetoothService(20201): at android.os.Handler.dispatchMessage(Handler.java:99 )
E/BluetoothService(20201): at android.os.Looper.loop(Looper.java:123)
E/BluetoothService(20201): at android.app.ActivityThread.main(ActivityThread.jav a:4627)
E/BluetoothService(20201): at java.lang.reflect.Method.invokeNative(Native Method)
E/BluetoothService(20201): at java.lang.reflect.Method.invoke(Method.java:521)
E/BluetoothService(20201): at com.android.internal.os.ZygoteInit$MethodAndArgsCa ller.run(ZygoteInit.java:868)
E/BluetoothService(20201): at com.android.internal.os.ZygoteInit.main(ZygoteInit .java:626)
E/BluetoothService(20201): at dalvik.system.NativeStart.main(Native Method)

The Android Java Code Snippet we use to open the bluetooth socket:

private static final String BT_NAME = "GlucoTel SPP";
private static final UUID BT_ID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
.....
BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothServerSocket socket = mAdapter.listenUsingRfcommWithServiceRecord(BT_NAM E, BT_ID);
.....
socket = mmServerSocket.accept();

We have observed this issue on the following devices:

Test Device 1:

- Archos 32

- Firmware 2.1.8 (Android 2.2.1)

- Board Version: A32-V5

Test Device 2:

- Archos 101

- Firmware 2.0.54 (Android 2.2.1)

- Board Version A101IT-V6

Thanks for any ideas or feedback!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文