TheWeirdDev / Bluetooth_Headset_Battery_Level

A python script to get battery level from Bluetooth headsets
GNU General Public License v3.0
760 stars 83 forks source link

Add support for Nearby/FastPair protocol (Pixel buds left/right/case report) #94

Closed drinkcat closed 6 months ago

drinkcat commented 6 months ago

This is, at least, what Google Pixel Buds use to report left, right, and case battery status. Also, extend the BatteryStateQuerier class to support returning more than one value, and I added logging support (mostly for my debugging convenience).

I figured that out by enabling BT snoop logs on my phone. The protocol is simple, and data is sent from the headset automatically on connection (and regularly when the battery level changes). Once I figured out which UUID the channel/port corresponded to, I found out it is Google's Nearby/Fastpair protocol (https://developers.google.com/nearby/fast-pair/landing-page). The protocol documentation doesn't appear to be public, but information can be gathered from opensource code.

Only tested with Google Pixel Buds A-series. I believe some BT speakers use that protocol as well.

TheWeirdDev commented 6 months ago

Well done! Everything seems good to me.

Feel free to add your name to the authors before I merge.

drinkcat commented 6 months ago

Well done! Everything seems good to me.

Feel free to add your name to the authors before I merge.

Done! Thanks!