bluezのデバイス検索可能時間のタイムアウトを無効にする方法

投稿者: | 2022年5月8日

bluezのタイムアウト時間

以前、raspberryPiでbluezによるビーコン発信を実現しましたが、デフォルトでタイムアウト時間が設定されているため、数分経過すると他端末からのスキャンができなくなってしまいます。
そこで今回はこのタイムアウト時間を無効にする方法をご紹介します。
※タイムアウト時間はセキュリティ的にはあった方が良いため、開発時に限ってタイムアウト時間を無効にするといいです。

/etc/bluetooth/main.confを編集

/etc/bluetooth/main.confを開き、コメントアウトされている「DiscoverableTimeout = 0」を解放します。
これにより、bluetoothctl内でdiscoverable on を実行したあとに、自動的に discoverable off にするまでの時間が無効になります。

vim /etc/bluetooth/main.conf   #エディタはvimでなくてもOKです。


[General]

# Defaults to 'BlueZ X.YZ', if Name is not set here and plugin 'hostname' is not loaded.
# The plugin 'hostname' is loaded by default and overides the Name set here so
# consider modifying /etc/machine-info with variable PRETTY_HOSTNAME=<NewName> instead.
#Name = BlueZ

# Default device class. Only the major and minor device class bits are
# considered. Defaults to '0x000000'.
#Class = 0x000100

# How long to stay in discoverable mode before going back to non-discoverable
# The value is in seconds. Default is 180, i.e. 3 minutes.
# 0 = disable timer, i.e. stay discoverable forever
DiscoverableTimeout = 0  #コメントアウト解放

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です