javascript 连接到Amazon Echo按钮

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 连接到Amazon Echo按钮相关的知识,希望对你有一定的参考价值。

var btSerial = new (require('bluetooth-serial-port')).BluetoothSerialPort();

var address = '50-dc-e7-a3-0b-e8';

btSerial.findSerialPortChannel(address, function(channel) {
	btSerial.connect(address, channel, function() {
		console.log('> connected to ' + address);
		btSerial.on('data', function(buffer) {
			console.log('> receiving ('+buffer.length+' bytes):', buffer);

			var isPressed = buffer[buffer.length-2] == 0xc0;
			console.log(' >> button is ' + (isPressed?'pressed':'released'));
		});

	}, function () {
		console.log('> cannot connect');
	});

}, function() {
	console.log('found nothing');
});


process.on('SIGINT', function() {
	console.log("> closing bluetooth connection.");
	btSerial.close();
	process.exit();
});

以上是关于javascript 连接到Amazon Echo按钮的主要内容,如果未能解决你的问题,请参考以下文章

将 Netatmo 气象站连接到 Amazon Echo (Alexa)

Amazon Alexa 语音识别1 : 简介

使用 SQLAlchemy 连接到 Amazon Aurora

Java 连接到 Amazon Redshift

将 IntelliJ 连接到 Amazon Redshift

如何从我的 Amazon EC2 实例中连接到 Amazon Redshift 集群