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

Why BatteryStateQuerier send messaged to sock? #89

Closed steam3d closed 1 year ago

steam3d commented 1 year ago

I tested code cycle: https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level/blob/e74acb74b60bb744347a4cbc7d784918040652a7/bluetooth_battery.py#L103

If I do not send any command back, I will receive the same result. So why do you send some commands like this?

https://github.com/TheWeirdDev/Bluetooth_Headset_Battery_Level/blob/e74acb74b60bb744347a4cbc7d784918040652a7/bluetooth_battery.py#L123

TheWeirdDev commented 1 year ago

Your device sends the same result but other people's do not. Some commands have been added to maximize the support for multiple devices and might not be needed for your device.

Some Bluetooth devices will ask if some feature is supported or not and only answer if we say we support it. We use the commands we captured from Bluetooth traffic of android devices and try to respond like a real device.