如何通过蓝牙唤醒蓝牙支持的设备(如avr索尼STR-DN1080)

问题描述 投票:1回答:1

我试图了解我的AVR STR-DN1080是如何通过蓝牙使用覆盆子pi而不是我的Android手机唤醒的。让我解释一下: - 我的AVR索尼STR-DN1080可以进入蓝牙待机模式。在这种情况下,我可以使用我的Android手机,在配对的设备中搜索,找到我的“STR DN1080 XXXX”设备,只需点击它,手机开始做一些事情,几秒钟后,我的AVR唤醒并打开。 - 所以我想我可以使用我的Raspberry PI 3B +来使用它的蓝牙并在需要时远程唤醒我的AVR .. - 我的PI正在运行Stretch并且它的蓝牙似乎工作正常(见下文)。但是,一旦我将AVR置于待机状态,我就无法使用PI命令连接到设备(它看不到设备)。我还注意到,当AVR处于待机状态时,我的手机在活动设备中看不到它,因此它必须使用“配对设备”中的信息。

所以我相信有些东西我不明白它是如何唤醒蓝牙工作的..

在我的Raspberry PI上,我可以在AVR打开并激活时检查以下内容:

(我使用sudo,因为在我的Stretch上只有sudo使bluetoothctl工作,否则,我收到错误信息,如“没有默认控制器可用”。我改变了MAC地址的机密性。)

sudo bluetoothctl
[bluetooth]# pair AA:BB:CC:DD:EE:FF
Attempting to pair with AA:BB:CC:DD:EE:FF
[CHG] Device AA:BB:CC:DD:EE:FF Connected: yes
[CHG] Device AA:BB:CC:DD:EE:FF Modalias: bluetooth:v0046p0802d0903
[CHG] Device AA:BB:CC:DD:EE:FF UUIDs: 0000110a-0000-1000-8000-00805f9f9f9b
[CHG] Device AA:BB:CC:DD:EE:FF UUIDs: 0000110b-0000-1000-8000-00805f9f9f9b
[CHG] Device AA:BB:CC:DD:EE:FF UUIDs: 0000110c-0000-1000-8000-00805f9f9f9b
[CHG] Device AA:BB:CC:DD:EE:FF UUIDs: 0000110e-0000-1000-8000-00805f9f9f9b
[CHG] Device AA:BB:CC:DD:EE:FF UUIDs: 00001200-0000-1000-8000-00805f9f9f9b
[CHG] Device AA:BB:CC:DD:EE:FF UUIDs: 00001800-0000-1000-8000-00805f9f9f9b
[CHG] Device AA:BB:CC:DD:EE:FF ServicesResolved: yes
[CHG] Device AA:BB:CC:DD:EE:FF Paired: yes
Pairing successful
So it seems working and paired. But once I put it into stand by, the "scan on" command doesn't show my AVR and the following commands don't work:

[bluetooth]# connect AA:BB:CC:DD:EE:FF
Attempting to connect to AA:BB:CC:DD:EE:FF
Failed to connect: org.bluez.Error.Failed
[bluetooth]# pair AA:BB:CC:DD:EE:FF
Attempting to pair with AA:BB:CC:DD:EE:FF
Failed to pair: org.bluez.Error.AlreadyExists
In parallel, on my android phone, the AVR is not listed in active bluetooth devices of the phone, but if I click on the memorized "paired device" of my AVR, then it wakes it up properly.

所以我有兴趣了解这是如何唤醒蓝牙工作的..是否还有其他命令可以运行(如WOL机制?)?我怎么能在覆盆子PI上做到这一点?

非常感谢Ricorico94

android bluetooth raspberry-pi avr sony
1个回答
0
投票

要通过蓝牙唤醒设备,我只需连接到“RFCOMM”端口2即可唤醒设备。用Python编写的示例代码(只需将主机更改为设备的设备地址):

import bluetooth

name = "STR-DN 1080 EU"
host = "AA:BB:CC:DD:EE:FF"
port = 2

print(f"connecting to \"{name}\" on {host}")

sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
sock.connect((host, port))
sock.close()

我确实有连接超时但设备正在唤醒:

bluetooth.btcommon.BluetoothError: (110, 'Connection timed out')

如果设备已经唤醒,则拒绝连接:

bluetooth.btcommon.BluetoothError: (111, 'Connection refused')
© www.soinside.com 2019 - 2024. All rights reserved.