Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No battery level for Sony WF-1000XM3 #16

Closed
superbonaci opened this issue May 11, 2020 · 22 comments
Closed

No battery level for Sony WF-1000XM3 #16

superbonaci opened this issue May 11, 2020 · 22 comments

Comments

@superbonaci
Copy link

superbonaci commented May 11, 2020

Same issue as #3:

./bl_battery.py <MAC>
<MAC> is offline [Errno 111] Connection refused
@TheWeirdDev
Copy link
Owner

I assume you tried those tricks that i mentioned?

@superbonaci
Copy link
Author

No idea how to do it...

@TheWeirdDev
Copy link
Owner

I mean changing the port number from 4 to other numbers below 10

@superbonaci
Copy link
Author

superbonaci commented May 11, 2020

When testing ports 6-10 it hangs, then trying to reconnect causes a different error:

./bl_battery.py <MAC>
^CTraceback (most recent call last):
  File "./bl_battery.py", line 82, in <module>
    main()
  File "./bl_battery.py", line 73, in main
    s.connect((device, 6))
KeyboardInterrupt

./bl_battery.py <MAC>
<MAC> is offline [Errno 16] Device or resource busy

After a while it releases the device.

@TheWeirdDev
Copy link
Owner

I can't debug because it don't have that device.

You can try putting print statements in send and getATCommand functions to see what is getting transferred between devices.
add print for line and message variables and send the output to me.

@superbonaci
Copy link
Author

With Samsung's I tested on port 4 and does display commands, but with Sony's only get <MAC> is offline [Errno 111] Connection refused. The buds are connected and can play music and system audio as normal. The other ports don't work.

@TheWeirdDev
Copy link
Owner

Is your Sony device connected before running the script? someone in another issue said disconnecting the device before running the script worked for them.

@superbonaci
Copy link
Author

Yes it's connected at the moment of running the script. With Samsung's I have no problem running the script while playing music. Will try disconnecting.

@superbonaci
Copy link
Author

Tried again with them disconnected.
Ports 3-5 Connection refused.
6-7 <MAC> is offline [Errno 115] Operation now in progress after a while
8-9 hangs forever.

@TheWeirdDev
Copy link
Owner

Hmm, this is weird. I have no idea.

@superbonaci
Copy link
Author

However they connect to play music or any other thing.

@Bobo1239
Copy link
Contributor

Just chiming in here in case you or anybody else who owns the device wants to investigate further. To add support for the Samsung Galaxy Buds I've captured the traffic from my phone to the ear buds using the "Enable Bluetooth HCI snoop log" in the Android developer menu. (Make sure restart bluetooth afterwards for this to take effect.) Then you should be able to find the recorded traffic somewhere like /sdcard/oem_log/btsnoop/hci_snoop_2020_05_07_19_42_35.cfa. This file can then be analysed using Wireshark. Setting the filter to bthfp shows all AT commands and responses which were sent. If that results in no remaining packets then there's probably some other protocol which is used for the battery level and you'll have to look at the whole traffic.

@superbonaci
Copy link
Author

superbonaci commented May 12, 2020

I think I've found how battery percentage is represented. @Bobo1239 how did you send and receive AT commands, did you use Python or any other terminal software? In order do to step-by-step debug. Did you do it from a computer, a phone, etc?

@Bobo1239
Copy link
Contributor

In my case the AT communication already worked with the Python script from this repo and I could just go from there. For your device it seems that isn't the case unfortunately. I don't really have any experience with bluetooth so don't know why exactly you can't establish a connection.

Perhaps you can check the RFCOMM channel number which is used by Android to rule out that error. You can see it in Wireshark when selecting a captured packet and looking at the "Bluetooth RFCOMM Protocol" layer.

@superbonaci
Copy link
Author

Can't detect which BT channel is, so here's the summary copied from Wireshark:
Sony_WF1000XM3__Wireshark_100%vol-both.txt

Volume is specified at line 393:

HFP	35	Rcvd AT+IPHONEACCEV=1,1,9

The battery percentage value is (last_number+1)*10.
Sony WF-1000XM3 only outputs 4 different values:
1,1,9 -> 100% battery displayed (71%~100% real charge)
1,1,6 -> 70% battery displayed (51%~70% real charge)
1,1,4 -> 50% battery displayed (21%~50% real charge)
1,1,1 -> 20% battery displayed (0%~20% real charge)

The value provided by last number is the minimum value of the 2 earbuds, not counting the charging case. Example:
Left: 50%
Right: 70%
Charging case: 30%
Value displayed on phone bluetooth settings and status bar: 50%
Value received: AT+IPHONEACCEV=1,1,4

The companion app from Sony is able to provide the 3 values independently, also happens with Samsung Galaxy Buds except that those don't provide case charge:

Sony app

No idea if those values can be extracted by Wireshark or they use some proprietary encoding.

@TheWeirdDev
Copy link
Owner

I have a MI Bluetooth speaker that connects to the socket but does not send any AT command whatsoever. It sends AT commands to my phone but not to the script. I guess for some devices, it's more complicated than a simple socket connection. It would be great if a Bluetooth expert joined this conversation.

@superbonaci
Copy link
Author

@TheWeirdDev maybe it's the bluetooth profile. I'm no bluetooth expert either.

@benjezzy
Copy link

Just wanted to mention I'm having the same issue as @superbonaci with my Sony WH-1000XM3 (over-ear headphones). Can't seem to get connect on any port.

Anything I can do to help debug?

@superbonaci
Copy link
Author

@kred-jon open a new issue and delete your post, this is not related.

@chaoscreater
Copy link

I can't seem to get this working on my WH-1000XM3 either. I'll be receiving my WF-1000XM3 earbuds in a few weeks, so can give that a test too. At the moment, I'm getting either a device is offline message, or that it just hangs when I test using other ports.

image

@superbonaci
Copy link
Author

superbonaci commented Aug 2, 2020

@chaoscreater forget about this script, we need a much better one like https://github.com/ThePBone/GalaxyBuds-BatteryLevel

@TheWeirdDev TheWeirdDev added the wontfix This will not be worked on label Aug 2, 2020
Repository owner locked and limited conversation to collaborators Aug 2, 2020
@TheWeirdDev
Copy link
Owner

Using the port number 10 or higher might work for this device: See issue #33

If you have any comments or questions about this device or a similar Sony device, please open a new issue.

@TheWeirdDev TheWeirdDev removed the wontfix This will not be worked on label Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants