LoginSignup
1
1

More than 5 years have passed since last update.

CLIでOSXのBluetooth接続を改善する WIP

Posted at

症状

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押下したままクリックすると隠しメニューのデバッグを利用できる

  1. 現在の設定値をバックアップ
    • $sudo cp /Library/Preferences/com.apple.Bluetooth.plist ~/Desktop/
  2. デバッグ->すべてのデバイスを削除
  3. デバッグ->Bluetoothモジュールをリセット

......解決せず

com.apple.Bluetoothの設定値をいじる

$defaults read /Library/Preferences/com.apple.Bluetooth

これで/Library/Preferences/com.apple.Bluetooth.plistの中身をjsonでみれる(?)が、この中の値をいじれば解決するかも?


  1. deamonに対してhang upで再起動させてるがlaunchctl stop[start] com.apple.bluetoothdでも可能 

  2. sudo launchctl list|grep com.apple.bluetoothdでStatusという項目がみれるが、これはそのサービスの最後の終了コード。ex, -15ならSIGTERM。 

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1