我有一个非常懒的蓝牙键盘,我试图让它保持清醒(参见:上一个问题)。如果我不按任何键,它会在 30 秒到 10 分钟后进入睡眠状态(我猜这取决于我之前使用它的时间),并且重新连接至少需要 5 秒的令人沮丧的时间。所以我想运行一个脚本,每隔几秒钟发送/询问一些东西(我还不知道)以保持清醒。
第一步是找到它。
我尝试了l2ping:
$ sudo l2ping E0:6A:4E:71:85:F6
Can't connect: Host is down
我尝试使用 pybluez (python),但也失败了:
>>> import bluetooth
>>> bluetooth.discover_devices()
[]
>>> bluetooth.find_service(address='all')
[]
>>> sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
>>> sock.connect(("E0:6A:4E:71:85:F6", 1))
Traceback (most recent call last):
File "<string>", line 3, in connect
_bluetooth.error: (112, 'Host is down')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: [Errno 112] Host is down
>>> "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: [Errno 112] Host is down
>>>
我尝试了蓝牙:
watch -n 60 echo -e 'connect E0:6A:4E:71:85:F6' | bluetoothctl
(而且它还是睡着了)
下一步将是让它忙碌以保持清醒。
任何帮助表示赞赏。