timschneeb / GalaxyBuds-BatteryLevel

Simple python script to read battery values from the Samsung Galaxy Buds
MIT License
20 stars 3 forks source link

Different service name #11

Closed ttoino closed 3 years ago

ttoino commented 3 years ago

I tried out this script on my machine and got the following output using the verbose flag:

Checking device model...
Galaxy Buds (1D57)
Searching for RFCOMM interface...
Couldn't find the proprietary RFCOMM service

Checking the source code, I tried printing out the service matches and got the following output:

{'service-classes': ['00001102-0000-1000-8000-00805F9B34FD'], 'profiles': [('00001102-0000-1000-8000-00805F9B34FD', 258)], 'name': 'GEARMANAGER3', 'description': None, 'provider': None, 'service-id': None, 'protocol': 'RFCOMM', 'port': 2, 'host': 'XX:XX:XX:XX:XX:XX'}

For some reason, my headset is reporting GEARMANAGER3 as the service name, and not GEARMANAGER as the script was expecting.

necauqua commented 1 year ago

Hello! Didn't think it was worth creating another identical issue, but for Galaxy Buds2 Pro (at least the ones I've just got) the service name is FACTORY.

Not sure you should even check for the service name, isn't there always just one service with the serial port uuid?

lol ```patch diff --git a/buds_battery.py b/buds_battery.py index a4cc69a..2f666e1 100755 --- a/buds_battery.py +++ b/buds_battery.py @@ -113,20 +113,16 @@ def main(): print("Searching for RFCOMM interface...") uuid = ("00001101-0000-1000-8000-00805F9B34FB" if not islegacy else "00001102-0000-1000-8000-00805f9b34fd") + service_matches = bluetooth.find_service(uuid=uuid, address=str(args.mac[0])) - port = host = None - for match in service_matches: - target_name = "" - if isinstance(match["name"], str): - target_name = "GEARMANAGER" - else: - target_name = b"GEARMANAGER" + if len(service_matches) != 1: + print("Unusual amount of serial port services lol") + sys.exit(1) - if target_name in match["name"]: - port = match["port"] - host = match["host"] - break + service = service_matches[0] + port = service["port"] + host = service["host"] if port is None or host is None: print("Couldn't find the proprietary RFCOMM service") ```