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

Add option to turn off NC and ambient sound #36

Merged
merged 5 commits into from Mar 14, 2021

Conversation

guilhermealbm
Copy link
Contributor

This fixes #18. After taking a look over bluetooth messages, found out that ambient sound control is turned off when sending vol=-1.

The only problem I faced is when checking and, after, unchecking the box. It returns a "Invalid checksum!". Same happens when do it at "Focus on Voice" checkbox, so I think that's maybe a problem with XM4's (and not my changes), as other people said in #27.

I tested it in XM4's and Windows. Hope it helps! :)

@semvis123
Copy link
Contributor

Hey I might be wrong on this one, but to me it looks like NC_ASM_EFFECT::OFF should be used to turn off the ambient sound control. This turns it off for me, on a WH-1000XM3.

@guilhermealbm
Copy link
Contributor Author

guilhermealbm commented Mar 9, 2021

Just tested here and turns off on a XM4 too. That's weird; both approaches turns it off (independently or combined).

Taking another look at bluetooth messages between my phone and xm4, apparently both informations are sent (NC_ASM_EFFECT::OFF and vol=-1)
Guess I'll add the missing one to this PR.

@semvis123
Copy link
Contributor

I have updated the macOS version to have the same functionality.
Compiled version

@Plutoberth
Copy link
Owner

@guilhermealbm which method did you use to fetch the messages between your phone and the headset? Did you hook the relevant function using Frida or something? I didn't manage to get it to work using the sniffer Android provides. I'll probably merge this this weekend, BTW.

@guilhermealbm
Copy link
Contributor Author

Hi @Plutoberth! I started trying logging with Bluetooth HCI Snoop and analyzing it with Wireshark, but was extremely confusing. So, I discovered that my device has a logkit.

It generates a really big file, but I filtered by my XM4's MAC and found the event logs;
For example, when I toggle the "Ambient Sound Control" button, it records:

03-08 23:00:17:503 handleBluetoothA2dpActiveDeviceChangeExt  state=2 addr=[...] prof=2 supprNoisy=true vol=18
03-08 23:00:17:504 setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent  state=2 addr=[...] prof=2 supprNoisy=true vol=18
03-08 23:00:17:506 A2DP sink connected: device addr=[...] state=2 vol=18
03-08 23:00:20:405 handleBluetoothA2dpActiveDeviceChangeExt  state=0 addr=[...] prof=2 supprNoisy=false vol=-1
03-08 23:00:20:405 setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent  state=0 addr=[...] prof=2 supprNoisy=false vol=-1

I ommited my mac addr, but, in general, that's it! 😃

@Plutoberth Plutoberth mentioned this pull request Mar 11, 2021
@Plutoberth
Copy link
Owner

Hi @Plutoberth! I started trying logging with Bluetooth HCI Snoop and analyzing it with Wireshark, but was extremely confusing. So, I discovered that my device has a logkit.

It generates a really big file, but I filtered by my XM4's MAC and found the event logs;
For example, when I toggle the "Ambient Sound Control" button, it records:

03-08 23:00:17:503 handleBluetoothA2dpActiveDeviceChangeExt  state=2 addr=[...] prof=2 supprNoisy=true vol=18
03-08 23:00:17:504 setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent  state=2 addr=[...] prof=2 supprNoisy=true vol=18
03-08 23:00:17:506 A2DP sink connected: device addr=[...] state=2 vol=18
03-08 23:00:20:405 handleBluetoothA2dpActiveDeviceChangeExt  state=0 addr=[...] prof=2 supprNoisy=false vol=-1
03-08 23:00:20:405 setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent  state=0 addr=[...] prof=2 supprNoisy=false vol=-1

I ommited my mac addr, but, in general, that's it! 😃

Wow, so this format is standardized? I was 100% sure it was proprietary. This is really great news for future features. I have a Oneplus too so I'll check this out when I have some time.

Copy link
Owner

@Plutoberth Plutoberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, looks great, just one small request - could you make it so the text "Focus on voice isn't enabled on this level" isn't shown if ambient sound is disabled?
image

@guilhermealbm
Copy link
Contributor Author

guilhermealbm commented Mar 13, 2021

Wow, so this format is standardized? I was 100% sure it was proprietary. This is really great news for future features. I have a Oneplus too so I'll check this out when I have some time.

I don't think it's a standardized format. Fortunately, toggling NC button also calls android's handleBluetoothA2dpActiveDeviceChangeExtand setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent methods, which are recorded by OnePlus logkit. But, for example, alternating between equalizer profiles doesn't generate any record at log file 😕

I was not sure why this happens too, but Galaxy Buds Client explains it very well. To certain features, reverse-engineer the data format is the only alternative.

@guilhermealbm
Copy link
Contributor Author

Hi, looks great, just one small request - could you make it so the text "Focus on voice isn't enabled on this level" isn't shown if ambient sound is disabled?
image

I really didn't notice that! Just fixed 😄

@Plutoberth
Copy link
Owner

LGTM, merged :)

@Plutoberth Plutoberth merged commit 6355d26 into Plutoberth:master Mar 14, 2021
@V02460 V02460 mentioned this pull request Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to turn off NC and ambient sound
3 participants