我的目标是获取存储在设备中的数据。就像正在测量温度或任何温度的设备,并将其存储到其内存中。我需要通过记录访问控制点(RACP)查询所有此数据设备。为了实现它,首先想到的是获得特色开始通知将代码写入描述符通过eventListener获取所有数据结果:在使用的启动通知示例上引发错误:https://googlechrome.github.io/samples/web-bluetooth/notifications-async-await.html https://bugs.chromium.org/p/chromium/issues/detail?id=664863由于特性为INDICATE,WRITE类型,因此下一个想法是不启动通知。因此,正在考虑添加侦听器并写入设备文档中的描述符代码,其中指出:操作码:1 –报告存储的记录即使删除了startNotifications行也抛出错误,所以我的代码示例是:const mainService = 'my correct service uuid'; const characteristicUUID1 = 'my correct char uuid'; const characteristicUUID2 = 'my correct char uuid'; const descriptorUUID = '00002902-0000-1000-8000-00805f9b34fb'; let deviceCache = null; let serverCache = null; let serviceCache = null; let characteristicCacheA = null; let characteristicCacheB = null; let descriptorCache = null; try { deviceCache = await navigator.bluetooth.requestDevice({ filters: [{ name: 'my device' }] }); console.log('Connecting to GATT Server...'); serverCache = await deviceCache.gatt.connect(); console.log('Getting Services...'); serviceCache = await serverCache.getPrimaryService(mainService); console.log('Getting Characteristics A...'); characteristicCacheA = await serviceCache.getCharacteristic(characteristicUUID1); console.log('Start Notifications A...'); await characteristicCacheA.startNotifications(); console.log('Getting Characteristics B...'); characteristicCacheB = await serviceCache.getCharacteristic(characteristicUUID2); console.log('Start Notifications B...'); await characteristicCacheB.startNotifications();通知错误为(具有实验性chrome功能,不会引发错误):错误:GATT操作由于未知原因而失败。描述符错误是:在被标记为排除写入的被列入黑名单的对象上调用writeValue()。另外,我的设备要求输入密码,但网络正在连接而没有提示任何内容。因此,也许它说阻止写入描述符。如何处理图钉输入-不知道(一旦启用了chrome实验功能后,系统提示我输入图钉,请先确定其是否相关)。我的逻辑正确吗?-不要这样。有什么建议么?
2 回答

一只萌萌小番薯
TA贡献1795条经验 获得超7个赞
调用writeValue()
失败,因为对CCCD的访问位于阻止列表中。对的调用startNotifications()
将在必要时写入描述符以启用通知。
我们需要调查这种startNotifications()
失败的“未知原因” 。您使用什么操作系统?请按照报告Web蓝牙错误的说明进行操作,并在Chromium项目的问题跟踪器中提交问题。
添加回答
举报
0/150
提交
取消