gpt4 book ai didi

java - 在android中识别android蓝牙设备

转载 作者:行者123 更新时间:2023-11-30 03:52:15 26 4
gpt4 key购买 nike

我在 android api 级别 15 中做蓝牙应用程序,我想使用蓝牙连接远程设备。我使用 fetchUuidsWithSdp() 获取 UUID。我正在为所有其他设备(如诺基亚、PC 但不是 Android 设备)获取 uuid。

来自文档,

fetchUuidsWithSdp().//This API is asynchronous and ACTION_UUID intent is sent, with the UUIDs supported by the remote end. If there is an error in getting the SDP records or if the process takes a long time, ACTION_UUID intent is sent with the UUIDs that is currently present in the cache. Clients should use the getUuids() to get UUIDs if service discovery is not to be performed.

从文档“客户端应该使用 getUuids()”,我的问题是,我如何确定 UUID 是来自其他设备还是来自 android?

最佳答案

你不能。

来自Android docs : "UUID 的要点是它足够大,你可以随意选择并且不会冲突。"

除了串行端口配置文件 (SPP) 的 UUID 00001101-0000-1000-8000-00805F9B34FB,由于上述原因,没有众所周知的 UUID。

0x1101 是串行端口配置文件的 ID - 这就是 UUID 以 00001101 开头的原因。因此,您显然能够识别其他设备支持的配置文件(这首先是 SDP 的主要原因)。您可能会尝试查看设备 ID (DID) 配置文件,看看是否有任何东西可以用来检测对方的制造商。

关于您没有从 Android 设备获取任何 UUID:确保这些设备实际上通过蓝牙提供至少一项服务(例如网络访问)——然后您应该获取一个以网络访问 ID 开头的 UUID配置文件(例如 PAN)。

getUuids() 和 fetchUuidsWithSdp() 之间的区别是,就像文档状态一样,后者实际上向另一个设备执行 SDP 请求,而前者只是返回那些与最后一个响应(最常见的是收到的响应)一起获取的请求使用蓝牙 2.1+ 发现时)。

关于java - 在android中识别android蓝牙设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13947712/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com