【问题标题】:Can you access normal Bluetooth devices with chrome Bluetooth api from webpage ? (no BLE)您可以从网页使用 chrome 蓝牙 api 访问普通蓝牙设备吗? (无 BLE)
【发布时间】:2017-05-06 13:39:36
【问题描述】:

好的,所以我在做一些研究:如何通过网页连接到蓝牙设备。我希望页面提示配对设备列表并连接到它们。(蓝牙打印机)。我找到了一些解决方案,但我不想在客户的 PC 上安装任何东西(如第三方应用程序)。我发现 google bluetooth api thingy 它适用于 BLE,问题是,我要连接的设备没有 BLE。我试过了

chrome.bluetooth.getDevices(function(devices) {
  for (var i = 0; i < devices.length; i++) {
    console.log(devices[i].address);
  }
});

用于在 Chrome 开发者工具中进行测试,但返回错误

Uncaught TypeError: Cannot read property 'getDevices' of undefined
    at <anonymous>:1:17

此 API 仅适用于 Chrome 应用程序,或者我在这里做错了什么:D。

【问题讨论】:

    标签: google-chrome bluetooth webpage


    【解决方案1】:

    https://developer.chrome.com/apps/bluetooth 所述,此 Chrome 应用程序 API 仅适用于 OS X、Windows 和 Chrome 操作系统。

    看起来您可能错过了在 manifest.json 文件中包含“蓝牙”权限。见https://developer.chrome.com/apps/app_bluetooth

    【讨论】:

    • 好的。从我一直在阅读的内容来看,要访问 com/usb/bluetooth,我需要一个 chrome 应用程序。所以我需要做一个扩展,将数据从网页传递到 chrome 应用程序。我说的对吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多