简体   繁体   English

识别android中的android蓝牙设备

[英]Identify android bluetooth device in android

Im doing bluetooth apps in android api level 15, I want to coneect remote device using bluetooth. 我在android api 15级中做蓝牙应用程序,我想使用蓝牙连接远程设备。 I get UUIDs using fetchUuidsWithSdp(). 我使用fetchUuidsWithSdp()获得了UUID。 I am getting uuids for all other devices like nokia, pc but not android device. 我正在为诺基亚,PC等所有其他设备获取uuid,但没有android设备。

From Doucment, 从Doucment,

fetchUuidsWithSdp().//This API is asynchronous and ACTION_UUID intent is sent, with the UUIDs supported by the remote end. fetchUuidsWithSdp()。//此API是异步的,并发送ACTION_UUID意图,而远端支持UUID。 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. 如果获取SDP记录时出错,或者该过程花费很长时间,则将使用缓存中当前存在的UUID发送ACTION_UUID意向。 Clients should use the getUuids() to get UUIDs if service discovery is not to be performed. 如果不执行服务发现,则客户端应使用getUuids()获取UUID。

From docs 'Clients should use the getUuids()', My question is, How can i identified that UUID is from other devices or from android? 从文档“客户端应使用getUuids()”开始,我的问题是,如何识别UUID是来自其他设备还是来自android?

You can't. 你不能

From the Android docs : "The point of a UUID is that it's big enough that you can select any random and it won't clash." 来自Android文档 :“ UUID的意义在于它足够大,您可以选择任何随机变量,并且不会发生冲突。”

Apart from Serial Port Profile's (SPP) UUID 00001101-0000-1000-8000-00805F9B34FB , there are no well-known UUIDs for the reason stated above. 除了串行端口配置文件(SPP)UUID 00001101-0000-1000-8000-00805F9B34FB ,由于上述原因,没有众所周知的UUID。

0x1101 is the ID of the Serial Port Profile - that's why the UUID begins with 00001101 . 0x1101是串行端口配置文件的ID -这就是为什么UUID开头00001101 So you are apparently able to identify the profiles the other device supports (that's the primary reason for SDP in the first place). 因此,您显然可以识别其他设备支持的配置文件(这首先就是SDP的主要原因)。 You might try to look into the Device ID (DID) profile and see if there's anything you can rely on for detecting the other side's manufacturer. 您可以尝试查看“设备ID(DID)”配置文件,看看是否有什么可以依靠来检测另一方的制造商。

Regarding you're not getting any UUIDs from Android devices: Make sure those devices actually offer at least one service via Bluetooth (Network Access, for instance) - you should then get a UUID which begins with the ID of a Network Access profile (eg PAN). 关于您没有从Android设备获取任何UUID:确保这些设备实际上通过蓝牙(例如,网络访问)至少提供一项服务-然后,您应该获得一个以网络访问配置文件的ID开头的UUID(例如泛)。

The difference between getUuids() and fetchUuidsWithSdp() is, like the docs state, that the latter actually performs a SDP request to the other device, while the former just returns those fetched with the last response (most commonly the one received upon discovery with Bluetooth 2.1+). 与docs状态一样,getUuids()和fetchUuidsWithSdp()之间的区别在于,后者实际上向另一台设备执行了SDP请求,而前者只是返回了最后一个响应(最常见的是发现时收到的响应)。蓝牙2.1+)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM