首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >需要访问Bicycle蓝牙速度传感器服务名称。蓝牙分配的服务页面已关闭。我还能在哪里找到这些信息呢?

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

Stack Overflow用户
提问于 2021-04-11 09:15:40
回答 2查看 42关注 0票数 0

我想查找需要将此示例从battery_service更改为自行车速度传感器服务所需的服务。简单地执行navigator.bluetooth.requestDevice(acceptAllDevices=true)可以与自行车速度传感器设备配对,但它会出错,因为我没有为它提供正确的服务名称。

代码语言:javascript
复制
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禁止错误

EN

回答 2

Stack Overflow用户

发布于 2021-04-12 13:13:35

规格已经移动,现在可以在以下位置找到:https://www.bluetooth.com/specifications/specs/gatt-specification-supplement-4/

票数 1
EN

Stack Overflow用户

发布于 2021-04-13 15:33:53

Chrome处理的所有标准化Bluetooth GATT UUID字符串都在这个文件中:https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/modules/bluetooth/bluetooth_uuid.cc。我相信下面这行就是你要找的。

代码语言:javascript
复制
  {"cycling_speed_and_cadence", 0x1816},

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

代码语言:javascript
复制
// 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也是一个很好的起点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67040637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档