The peripheral I'm connecting to has the Service Changed characteristic, and my understanding is that on connect, if the Service Changed characteristic is present, the client may not cache attributes if it is not bonded. There's a nice explainer on this here.
Now, I start with an empty /var/lib/bluetooth/[adapter]
directory. If I use bluetoothctl
to turn scan on, then off, I'll see my device. Then I connect to it, and discovery of services and characteristics happens (by monitoring the ATT messages using btmon
). Great! Now I disconnect.
Examining the /var/lib/bluetooth/[adapter]
directory shows:
- directory
/var/lib/bluetooth/[adapter]/[device]
- file
/var/lib/bluetooth/[adapter]/cache/[device]
Now, let me remove the device from bluetoothd:
bt-device -r [device]
Examining the /var/lib/bluetooth/[adapter]
directory now shows:
- file
/var/lib/bluetooth/[adapter]/cache/[device]
That's troubling. And if I run bluetoothctl
again, turn scan on, turn it off, and connect, I no longer see the characteristic discovery happen. Only service discovery. That does not obey the contract of the Service Changed characteristic.
If, instead, I manually delete /var/lib/bluetooth/[adapter]/cache/[device]
, then I see characteristic discovery.
Question:
Given that bt-device -r [device]
does NOT remove the cache/[device]
file, how do I programmatically remove that file without having to fire up a sudo rm
process?