接続されたBluetoothキーボードにPingを送信する

接続されたBluetoothキーボードにPingを送信する

私は目を覚まそうとしている非常に怠惰なBluetoothキーボードを持っています(参照:前の質問)。何も押さないと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
>>> 

私はBluetoothを試しました:

watch -n 60 echo -e 'connect E0:6A:4E:71:85:F6' | bluetoothctl

(そしてまだ眠っていた)

次のステップは、正気を保つために忙しく過ごすことです。

助けてくれてありがとう。

ベストアンサー1

おすすめ記事