问题
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..
On my Raspberry PI, I could do and check the following when the AVR is switched on and active :
(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
[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
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 ?
Thanks a lot, Ricorico94
回答1:
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')
来源:https://stackoverflow.com/questions/54162833/how-to-wake-up-by-bluetooth-a-device-in-bluetooth-stand-by-like-the-avr-sony-st