【发布时间】:2014-02-25 13:53:29
【问题描述】:
我正在尝试获取 ble 设备的 UUID。我一直在关注 android 开发人员指南,到目前为止我只能获得设备名称和 rssi。我试图获取设备的 Uuid 扫描方法,如下所示:
public void onLeScan(final BluetoothDevice device, int rssi,byte[] scanRecord) {
ParcelUuid[] myUUid =device.getUuids();
for(ParcelUuid a :myUUid){
Log.d("UUID",a.getUuid().toString());
}
String s = new String(scanRecord);
int len = scanRecord.length;
String scanRecords =new String(scanRecord) ;
deviceMap.put(device.getName().toString(), rssi);
Message msg = MainActivity.myHandler.obtainMessage();
Bundle bundle = new Bundle();
bundle.putCharSequence("dev_name", device.getName().toString());
bundle.putCharSequence("rssi", Integer.toString(rssi));
msg.setData(bundle);
MainActivity.myHandler.sendMessage(msg);
}
这会返回 - btif_gattc_upstreams_evt:事件 4096
【问题讨论】:
-
哪个 UUID?你的目标是什么?
-
我刚刚扫描的蓝牙设备uuid
-
但是哪个 UUID?一个设备通常有很多。或者,您想满足什么类型的设备和应用需求?
-
我对服务 UUID 不感兴趣,但对 ble 设备 uuid 感兴趣。据我所知,它是蓝牙的唯一标识符。 iOS 应用可以在广告包中获取。
-
不,一般情况下,BLE 设备中没有用于此目的的 UUID,尽管有设备地址。你的意思是 iBeacon UUID 吗?如果是这样,在 Android 上,您必须从广告数据包中解析出来 - 就 BLE 标准和堆栈而言,这些字节只是制造商特定的数据字段。