Open tcboy88 opened 2 years ago
This is the only data I can request from the earbuds. I don't have any further control over it. Someone else asked about a way to get raw accelerator data; however, the only available method to download the data is very slow: https://github.com/ThePBone/BudsPro-AcceleratorPolling. It probably isn't suited for your use case.
Also, I didn't bother reverse-engineering the whole code for all the calculations from Samsung's official app. They have additional logic and also handle particular Bluetooth messages with calibration data. My code doesn't do any of this; it just decodes and outputs the raw quaternion without special post-processing. I'm pretty sure that Samsung has some way to auto-adjust the data when it switches from right or left.
I recommend decompiling the official app with JADX to check how Samsung has implemented this. Some parts of the code are built into a native shared JNI library though. You can also enable a debug mode for the 360° feature in the official app by creating these (empty) files in /sdcard
: debug.txt
and gyrocal.txt
. It might be helpful when comparing values with the script.
I'll check Samsung's implementation, but no guarantees if I can manage to reimplement it properly. I've wanted to port the 360° effect to Linux for some time, so I'll give it a shot.
I tried with TWO buds pro, both using the RIGHT earbud and I can get both data simultaneously. However, due to a weird bug, sometimes it will switch from using the RIGHT earbud to using the LEFT earbud automatically while I was streaming the IMU data to PC. I think the IMU data always comes from the main/active earbud, but the main/active earbud will change automatically, depends how Samsung decides which one is the main/active one. But I always kept the left earbud in the case, so I am not sure why it switches automatically from Right earbud to Left earbud.
While you can't prevent the earbuds from changing the primary earbud (as far as I know), you could send a special Bluetooth message that can select the primary earbud: MAIN_CHANGE
(message id 112); it takes a 1-byte value as an argument, either 0 for right or 1 for left. https://github.com/ThePBone/GalaxyBudsClient/blob/3ceb9ec21cced888444e1544e1c6a27656819cd8/GalaxyBudsClient/Message/MessageComposer.cs#L41
To detect if the primary earbud changed, you can listen to status update messages, which contain information about the primary earbud. Then you could send a MAIN_CHANGE
message to revert to the previous earbud.
Status message decoder example:
https://github.com/ThePBone/GalaxyBudsClient/blob/3ceb9ec21cced888444e1544e1c6a27656819cd8/GalaxyBudsClient/Message/Decoder/StatusUpdateParser.cs#L17
By default, it starts by using the RIGHT earbud (quaternion). Sometimes, there is a bug where the RIGHT earbud will suddenly stop sending IMU data, and it switches to use the LEFT earbud instead. I wonder if you can update it so that it sends BOTH sides IMU at the same time?
If possible, could you also add sending raw accelerometer data (xyz)?
Thank you very much.