我是 javascript 和 node.js 的新手。目前从事医疗项目。首先我将解释我的工作。我必须从蓝牙设备接收数据(正常血压率、脉搏率)并使用 node.js 在 Web 应用程序中显示读数。我不知道如何从蓝牙设备(病人监护仪)接收数据,你们能给我推荐一些博客或书籍来阅读吗?提前致谢。
您可以使用“node-bluetooth”分别从设备发送数据和从设备接收数据。这是示例代码:-
const bluetooth = require('node-bluetooth');
// create bluetooth device instance
const device = new bluetooth.DeviceINQ();
device
.on('finished', console.log.bind(console, 'finished'))
.on('found', function found(address, name) {
console.log('Found: ' + address + ' with name ' + name);
device.findSerialPortChannel(address, function(channel) {
console.log('Found RFCOMM channel for serial port on %s: ', name, channel);
// make bluetooth connect to remote device
bluetooth.connect(address, channel, function(err, connection) {
if (err) return console.error(err);
connection.write(new Buffer('Hello!', 'utf-8'));
});
});
// make bluetooth connect to remote device
bluetooth.connect(address, channel, function(err, connection) {
if (err) return console.error(err);
connection.on('data', (buffer) => {
console.log('received message:', buffer.toString());
});
connection.write(new Buffer('Hello!', 'utf-8'));
});
}).inquire();
它扫描“device”变量中给出的设备名称。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)