danielgjackson / noisecancel

Quickly turn off noise cancellation on Bose NC 700 or QC 35 headphones, or change modes on the QC Earbuds or QC 45.
https://noisecancel.danjackson.dev
MIT License
38 stars 0 forks source link

idea: allow disconnecting all other devices #6

Open DC7IA opened 2 years ago

DC7IA commented 2 years ago

Hi,

just an idea for another quick tile:

One that disconnects all other devices.

The reason:

Often I start music or a podcast. No audio. Then I realise one of two laptops must be connected. And then I have to either find that device and disable Bluetooth there or disconnect it using the official app from Bose which is overly complicated or annoying.

Not sure how feasible this is, though.

What do you think? :D

danielgjackson commented 2 years ago

Good idea. It will rely on finding out the commands that are sent to the device (and this will be different between major model types). Ideally it would be a simple sequence that's always the same, but things will be trickier if it depends on state (e.g. for devices that have multipoint, it might need to work out then specify a particular connection number)

DC7IA commented 11 months ago

There's a simple program in C that can list connected devices and disconnect devices: https://github.com/Denton-L/based-connect

Using those hex codes, the app could get a list of all devices, substract the device the app is running on and then loop over the list and disconnect all of them.

That way, if audio cannot be played because another device is still connected, you would no longer have to search for that device, maybe even log in if the screen is locked and then disconnect.

There could be several interesting tiles:

DC7IA commented 11 months ago

Those are the interesting parts:

List connected devices: https://github.com/Denton-L/based-connect/blob/ef66145bf4739ec96c1a6959f63146d12ba87e4c/based.c#L447

Connect device: https://github.com/Denton-L/based-connect/blob/ef66145bf4739ec96c1a6959f63146d12ba87e4c/based.c#L487

Disconnect device: https://github.com/Denton-L/based-connect/blob/ef66145bf4739ec96c1a6959f63146d12ba87e4c/based.c#L495

Remove/unpair device: https://github.com/Denton-L/based-connect/blob/ef66145bf4739ec96c1a6959f63146d12ba87e4c/based.c#L503

DC7IA commented 11 months ago

Good idea. It will rely on finding out the commands that are sent to the device (and this will be different between major model types).

Those are for the QC-35... Are you sure they will be different? I could just try it out. :dagger:

How did you find out what the app communicates? Maybe I can get to that communication as well and see what it transmits. :thinking:

DC7IA commented 11 months ago

I found a fork of that project, this adds support for nother device: https://github.com/airvzxf/bose-connect-app-linux

Maybe looking at that for reference is helpful as well.

DC7IA commented 11 months ago

I've managed getting a dump of the interaction the Bose Music app has with my Bose 700.

I've documented some actual packages, I've just replaced the mac addresses with question marks.

Seems to be the same as that project says for the QC-35:

List connected devices

Request

Command: 04 04 01 00

Get a list of connected devices.

Response

Confirmation: 04 04 03 Unknown: 19 03 Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Confirmation: 04 04 03 Unknown: 19 03 Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ?? Mac Address: ?? ?? ?? ?? ?? ??

A listing of mac addresses of connected devices. Originally twice the same set of different mac addresses.

Contains multiple mac addresses. The payload contains the same data twice.

Get device info

Request

Requests info about connected devices with those specific mac addresses.

Command: 04 05 01 Unknown: 06 (might be referring to six octects, maybe to differentiate between EUI-48 and EUI-64) Mac Address: ?? ?? ?? ?? ?? ??

This can repeat multiple times with different mac adresses within the payload.

For example:

Command: 04 05 01 Unknown: 06 Mac Address: ?? ?? ?? ?? ?? ?? Command: 04 05 01 Unknown: 06 Mac Address: ?? ?? ?? ?? ?? ?? Command: 04 05 01 Unknown: 06 Mac Address: ?? ?? ?? ?? ?? ??

Actual payload without the hints:

04 05 01 06 ?? ?? ?? ?? ?? ?? 04 05 01 06 ?? ?? ?? ?? ?? ?? 04 05 01 06 ?? ?? ?? ?? ?? ??

Response

This response contains mac addresses and corresponding device names.

Confirmation: 04 05 03 Unknown: 14 Mac Address: ?? ?? ?? ?? ?? ?? Unknown: 03 02 03 (might in some way indicate how long the name is that follows, some sort of checksum maybe) Device Name: 50 69 78 65 6c 20 36 20 50 72 6f (it says "Pixel 6 Pro")

This can repeat multiple times with different devices within the payload.

For example:

Confirmation: 04 05 03 Unknown: 14 Mac Address: ?? ?? ?? ?? ?? ?? Unknown: 03 02 03 Device Name: 50 69 78 65 6c 20 36 20 50 72 6f (it says "Pixel 6 Pro") Confirmation: 04 05 03 Unknown: 10 Mac Address: ?? ?? ?? ?? ?? ?? Unknown: 01 01 03 Device Name: ?? ?? ?? ?? ?? ?? ?? Confirmation: 04 05 03 Unknown: 0f Mac Address: ?? ?? ?? ?? ?? ?? Unknown: 00 01 03 Device Name: ?? ?? ?? ?? ?? ?? ??

Disconnecting From Device

Request

Requests disconnecting from the device with that specific mac address.

Command: 04 02 05 Unknown: 06 (might be referring to six octects, maybe to differentiate between EUI-48 and EUI-64) Mac: ?? ?? ?? ?? ?? ??

Response

Confirms disconnecting from the device with that specific mac address.

Confirmation: 04 02 07 Unknown: 07 21 Mac: ?? ?? ?? ?? ?? ??

Connecting To Device

Request

Requests connecting to the device with that specific mac address.

Command: 04 01 05 Unknown: 07 00 Mac: ?? ?? ?? ?? ?? ??

Response

Confirms connecting to the device with that mac address.

Command: 04 01 07 Unknown: 06 Mac: ?? ?? ?? ?? ?? ??

DC7IA commented 11 months ago

Therefore, what is required for a quick tile that disconnects all other devices:

Confirmation: 04 04 03
Unknown: 19 03
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Confirmation: 04 04 03
Unknown: 19 03
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
Mac Address: ?? ?? ?? ?? ?? ??
for i in $macaddresslist
do
  echo "04 02 05 06 $i
done
DC7IA commented 11 months ago

No idea how to compile this app (or how to write in Kotlin), otherwise I would have already tried to do this. :D

DC7IA commented 11 months ago

I suspect this would even work far more reliably than the Bose Music app, which crashes all the time... and is pretty slow.