症状
MBP(会社用および私用)を2,3日電源落とさず使うと、Bluetoothのデバイス検知ができなくなる & 登録済みデバイスの再接続ができなくなる
またGUI(環境設定)からのオン・オフも効きが悪くなる
どちらも再起動すると直る
Sierra(購入時)からHigh Sierra, Mojaveと継続して発症
やりたいこと
(再起動したくない時が多いので)再起動せずに
- 検知・再接続できるようにする
- オン・オフを操作する
試したこと
Mojave以降で試したことを解決まで随時更新予定
CLIでbluetoothd再起動
https://github.com/rgcr/m-cli/blob/master/plugins/bluetooth#L26-L33 を参考に、Appleの公開APIを利用1
# Bluetooth off
$sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0
$sudo killall -HUP bluetoothd
# Bluetooth on
$sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1
$sudo killall -HUP bluetoothd
オン・オフはできた2が、検知などは解決せず
Bluetoothモジュールをリセット
メニューバーのBluetoothボタンをshift+option押下したままクリックすると隠しメニューのデバッグを利用できる
- 現在の設定値をバックアップ
$sudo cp /Library/Preferences/com.apple.Bluetooth.plist ~/Desktop/
- デバッグ->すべてのデバイスを削除
- デバッグ->Bluetoothモジュールをリセット
......解決せず
com.apple.Bluetoothの設定値をいじる
$defaults read /Library/Preferences/com.apple.Bluetooth
これで/Library/Preferences/com.apple.Bluetooth.plist
の中身をjsonでみれる(?)が、この中の値をいじれば解決するかも?