如何解决使用 Windows 10 中的 Node Js 扫描并连接 BLE 设备
我正在尝试使用 node js 扫描 BLE 设备。但我在运行时遇到错误。 我已经提到了这个 Git Repo https://github.com/noble/noble
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'bluetooth-hci-socket'
Require stack:
- D:\BLE-node\node_modules\noble\lib\hci-socket\hci.js
- D:\BLE-node\node_modules\noble\lib\hci-socket\bindings.js
- D:\BLE-node\node_modules\noble\lib\resolve-bindings.js
- D:\BLE-node\node_modules\noble\index.js
- D:\BLE-node\app.js
这里是 App.js
app.js
const Noble = require("noble");
const BeaconScanner = require("node-beacon-scanner");
var scanner = new BeaconScanner();
scanner.onadvertisement = (advertisement) => {
var beacon = advertisement["iBeacon"];
beacon.RSSi = advertisement["RSSi"];
console.log(JSON.stringify(beacon,null," "))
};
scanner.startScan().then(() => {
console.log("Scanning for BLE devices...");
}).catch((error) => {
console.error(error);
});
解决方法
尝试检查 bluetooth-hci-socket
是否已正确安装和声明。 (https://github.com/noble/node-bluetooth-hci-socket#windows)
尝试使用最新的noble fork:https://github.com/abandonware/noble
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。