如何通过蓝牙唤醒处于待机状态的设备(例如AVR索尼STR-DN1080) [英] How to wake up by bluetooth a device in bluetooth stand by (like the avr Sony STR-DN1080)

查看:800
本文介绍了如何通过蓝牙唤醒处于待机状态的设备(例如AVR索尼STR-DN1080)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to understand how my AVR STR-DN1080 can be woken up by bluetooth using a raspberry pi instead of my android phone. Let me explain: - My AVR Sony STR-DN1080 can go into bluetooth stand-by mode. In such case, I can use my android phone, search among the paired devices, find my "STR DN1080 XXXX" device, simply click on it and the phone starts doing something and after few seconds, my AVR wakes up and switches on. - so I thought I could use my Raspberry PI 3B + to use its bluetooth and wake up remotely my AVR when needed.. - my PI is running Stretch and its bluetooth seems working ok (see below). But once I put my AVR in stand by, I can't use the PI commands to connect to the device (it doesn't see the device). I noticed also that when AVR is on stand by, my phone doesn't see it among active devices, so it must use info from "paired device".

因此,我相信蓝牙唤醒的工作方式我不了解.

So I believe there's something I don't understand on how wake-up on bluetooth works..

在我的Raspberry PI上,当AVR处于打开状态且处于活动状态时,我可以进行以下检查:

On my Raspberry PI, I could do and check the following when the AVR is switched on and active :

(我使用sudo,因为只有在sudo上sudo才能使bluetoothctl正常工作,否则,我会收到诸如无默认控制器可用"的错误消息.为了保密起见,我更改了MAC地址.)

(I use sudo, because on my Stretch only sudo makes the bluetoothctl work, otherwise, I get error message like "No default controller available". An I changed the MAC addresses for confidentiality.)

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

因此,它似乎可以正常工作并且配对. 但是,一旦我将其置于备用状态,"scan on"命令就不会显示我的AVR,并且以下命令也将不起作用:

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

同时,在我的android手机上,该手机的活动蓝牙设备中未列出AVR,但是如果我单击存储的AVR配对设备",它将正确唤醒.

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上做到这一点?

So I'd be interested to understand how this wakes on bluetooth work.. Are there other commands to be run (like the WOL mechanisms ?) ? How could I do that on a raspberry PI ?

非常感谢, Ricorico94

Thanks a lot, Ricorico94

推荐答案

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

To wake-up the device via Bluetooth I simply connect to "RFCOMM" port 2 and the device wakes-up. Example code code written in Python (just change host to the device address of your device):

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()

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

I do get a connection time out but the device is waking up:

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

,或者如果设备已经处于唤醒状态则拒绝连接:

or a refused connection if the device is already a wake:

bluetooth.btcommon.BluetoothError: (111, 'Connection refused')

这篇关于如何通过蓝牙唤醒处于待机状态的设备(例如AVR索尼STR-DN1080)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆