gpt4 book ai didi

android - 蓝牙 LE 扫描结果返回 null,但我知道我的外围设备正在广播心率服务 UUID(由第 3 方 BLE 应用程序验证)。为什么?

转载 作者:行者123 更新时间:2023-12-02 13:32:22 24 4
gpt4 key购买 nike

我对我的 BLE 扫描没有返回 GATT 服务 UUID 感到沮丧(即 scanRecord.getServiceUUIDs() 返回 null )。但是,我知道我的心率外围设备工作正常并且广告正常,因为 LightBlue 应用程序发现了(并且可以读取)心率服务)。
这是我的 ScanCallback 中的函数目的:

override fun onScanResult(callbackType: Int, result: ScanResult?) {
super.onScanResult(callbackType, result)
// This log shows that result.mServiceUuids is null
Log.i(TAG, "BLEDeviceManager.ScanCallback.onScanResult: ${result.toString()}")

// TODO: handle null ScanResult
val parcelUuids = if (result.getScanRecord() != null) result.getScanRecord()!!.getServiceUuids() else null
if (parcelUuids == null) {
Log.i(TAG, "parcelUUids was null for scanRecord = ${result.getScanRecord()!!.toString()}")
return
}
val serviceList = ArrayList<UUID>()
for (i in parcelUuids.indices) {
val serviceUUID = parcelUuids.get(i).getUuid()
if (!serviceList.contains(serviceUUID))
serviceList.add(serviceUUID)
}
Log.i(TAG, "Here is a list of the service UUIDs: $serviceList")
}

这是日志:

I/BLEDeviceManager: parcelUUids was null for scanRecord = ScanRecord [mAdvertiseFlags=6, mServiceUuids=null, mServiceSolicitationUuids=null, mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=3, mDeviceName=blehr_sensor_1.0]



我做错了什么使得 mServiceUuids总是为空?

最佳答案

根据您输出的 ScanRecord,您的设备没有宣传任何服务 UUID。这并不意味着它没有该服务....它只是不做广告。

您可能想要连接到它,然后调用 discoverServices() 来获取它真正拥有的服务列表......

关于android - 蓝牙 LE 扫描结果返回 null,但我知道我的外围设备正在广播心率服务 UUID(由第 3 方 BLE 应用程序验证)。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60652323/

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