Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I clear the CoreBluetooth cache on MacOS?

I'm developing a Bluetooth LE device and am having trouble because of MacOS's caching of the services. If I try to delete a service or change its UUID on the device I'm developing, the change doesn't show up on the Mac and instead I continue seeing the old list of services and UUIDs from the device. I tried going to another Mac that hadn't paired with my device and it saw the new list of services with the correct UUIDs, so it seems to be a caching issue with my development Mac.

I found the com.apple.Bluetooth.plist file in /Library/Preferences and deleted it, but the system put it back with the same data, I presume the system has the cache loaded into memory and is just writing it back out when needed.

Does anybody know how to wipe the MacOS CoreBluetooth device/service cache?

like image 929
John Stephen Avatar asked Dec 12 '13 20:12

John Stephen


People also ask

How do I clear my Apple Bluetooth cache?

Step 1: Open Settings and go to 'Apps'. Step 2: Next, go to the Bluetooth option and select it. Step 3: Tap on 'Storage' and 'Clear Cache'.


1 Answers

I finally found the source of the problem -- there's a cache in the user preferences folder in a folder named ByHost. Here are the steps to clear the Bluetooth cache:

  • Turn off Bluetooth
  • Delete com.apple.Bluetooth.plist from /Library/Preferences
  • Delete files named com.apple.Bluetooth.somehexuuidstuff.plist from ~/Library/Preferences/ByHost (note that this is the user preference folder, not the system one)
  • Turn on Bluetooth

After doing that my peripheral's services are correctly identified. From what I found on the web, there may also be some other com.apple.Bluetooth files in /Library/Preferences related to HIDs or headsets or something -- I don't know if it's important to delete those as I didn't have them on my system.

like image 74
John Stephen Avatar answered Sep 19 '22 19:09

John Stephen