简体   繁体   English

在使用不同版本的Android设备扫描时,为同一个BLE设备获取不同的byte [] scanRecord数据

[英]Getting different byte[] scanRecord data for same BLE device while scanning with different versions of android device

private final BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
    @Override
    public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
       }
 }

I scanned a single BLE device from Acer table of version 4.4.2 and Nexus 7 5.1 version. 我从Acer表4.4.2版和Nexus 7 5.1版扫描了一台BLE设备。 I want to filter the BLE devices using UUIDS, but I am getting different scanRecord data for same BLE device. 我想使用UUIDS过滤BLE设备,但我为同一个BLE设备获取不同的scanRecord数据。

I attached the detailed pics. 我附上详细的照片。 在此输入图像描述 在此输入图像描述

This is pretty common in BLE world. 这在BLE世界中很常见。 When a BLE device advertises multiple services - The scanner is free to filter what it needs or is relevant to it. 当BLE设备宣传多项服务时 - 扫描仪可以自由过滤它所需要的或与之相关的内容。 I have seen similar behavior in a HRM (Heart Rate Monitor) device which doubles up as a Food Pod (profile - RSCP) as well - Hence implementing 2 services at the same time. 我在HRM(心率监测器)设备中看到了类似的行为,它同样兼作Food Pod(配置文件 - RSCP) - 因此同时实现了2个服务。

For such devices (hosting multiple services) it is a good practice to have a type resolution policy for BLE scan results - for example this may be an order of precedence:- 对于此类设备(托管多个服务),最好为BLE扫描结果提供类型解析策略 - 例如,这可能是一个优先顺序: -

1. GAP Appearance  
2. GATT Service  

The fitness sensor I mentioned above ( TICKR RUN from Wahoo ) sets GAP appearance to 833 belt type HRM and advertises 2 UUID s- HRP and RSCP. 我上面提到的健身传感器( 来自Wahoo的TICKR RUN )将GAP外观设置为833带式HRM,并通告2 UUID s-HRP和RSCP。 So going by sheer scan (advertisement) results we concluded it to be a HRM device only. 因此,通过纯粹的扫描(广告)结果,我们认为它只是一个HRM设备。 Only after you connect to it for retrieving GATT services you get the full set of GATT UUIDs and it turned out to support RSCP (Running Speed and Cadence Profile) and HRP (Heart Rate Profile) 只有在连接到它以检索GATT服务后,才能获得全套GATT UUID,结果证明它支持RSCP (运行速度和节奏配置文件)和HRP (心率配置文件)

Now from the perspective of scanning - it's a costly game to connect to each and every device in the discovery phase hence it might be OK to go with the primary service the device is advertising 现在从扫描的角度来看 - 在发现阶段连接到每个设备是一个昂贵的游戏,因此可以使用设备宣传的主要服务

HTH! HTH!

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

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