微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

需要访问自行车蓝牙速度传感器服务名称蓝牙分配服务页面已关闭我还能在哪里找到这些信息?

如何解决需要访问自行车蓝牙速度传感器服务名称蓝牙分配服务页面已关闭我还能在哪里找到这些信息?

我想查找我需要将这个示例从 battery_service 更改为自行车速度传感器服务的服务。只需执行 navigator.bluetooth.requestDevice(acceptAllDevices=true) 即可与自行车速度传感器设备配对,但由于我没有为其提供正确的服务名称而出错。

navigator.bluetooth.requestDevice({ filters: [{ services: ['battery_service'] }] })
.then(device => { /* … */ })
.catch(error => { console.error(error); });

我只是通过猜测得知心率是 {filters:[{services:[ 'heart_rate' ]}]})。还没有弄清楚自行车速度和踏频传感器的名称。由于文档已关闭,有没有办法内省 requestDevice 以获得此信息?

https://webbluetoothcg.github.io/web-bluetooth/#biblio-bluetooth-assigned-services

给出链接

https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorsHomePage.aspx

哪个页面不再存在,403 Forbidden error

enter image description here

解决方法

规范已被移动,现在可以在:https://www.bluetooth.com/specifications/specs/gatt-specification-supplement-4/

,

Chrome 处理的所有标准化蓝牙 GATT UUID 字符串都在此文件中:https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/modules/bluetooth/bluetooth_uuid.cc。我相信下面的这一行正是您要找的。​​p>

  {"cycling_speed_and_cadence",0x1816},

这意味着您可以使用字符串名称或其 UUID:

// This works.
navigator.bluetooth.requestDevice({ filters: [{ services: ['cycling_speed_and_cadence'] }] });

// And this works as well ;)
navigator.bluetooth.requestDevice({ filters: [{ services: [0x1816] }] });

https://web.dev/bluetooth 也是一个不错的起点。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。