Skip to content

Add TAP commands mode#12

Merged
tchebb merged 5 commits into
tchebb:mainfrom
hakanf:TAP_commands
Jul 28, 2025
Merged

Add TAP commands mode#12
tchebb merged 5 commits into
tchebb:mainfrom
hakanf:TAP_commands

Conversation

@hakanf

@hakanf hakanf commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

A minor change to allow a sort of terminal command mode (a la Polycomm.zip) used for servicing. In particular useful to put a device in shipmode for a more safe battery replacement, see Soundlink mini II service manual page 30 and on for some example uses...

@namidairo

namidairo commented Jul 27, 2025

Copy link
Copy Markdown

The simple functions like pl/sn/vr/sh work fine, but the parameterized ones from the manual don't seem to return anything but a blank report.

I wondered if they were nulling the whitespace but that does not seem to be the case.

Perhaps it is something like Command + atoi(parameter) + 0x00, will have to experiment or disassemble the DFU image to find out.

Edit: Sending 'ba' + 0x4 just reboots the unit due to presumed malformed command, 'ba' + 0x4 + 0x00 still just sends back an empty response. (As opposed to the battery percentage)

@tchebb tchebb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! I'm happy to add this functionality—I'd seen that manual before, but I'd never noticed the section on TAP commands. Good to know what they're called.

I left a few comments on the code. Can you also update the usage block in the README and maybe provide a brief description of what this subcommand is for? Something like what you already wrote in the PR is just fine.

Sorry about the clippy failures on main. I've pushed a commit to fix those, so if you rebase the builds should succeed.

Comment thread src/protocol.rs Outdated
Comment thread src/protocol.rs Outdated
Comment thread src/protocol.rs Outdated
Comment thread src/protocol.rs Outdated
@tchebb

tchebb commented Jul 27, 2025

Copy link
Copy Markdown
Owner

The simple functions like pl/sn/vr/sh work fine, but the parameterized ones from the manual don't seem to return anything but a blank report.=

There's a known issue #5 that the SoundLink Mini II omits the first byte from TAP responses. If the response is only supposed to be one byte, that could explain what you're seeing.

I think the most likely cause is that the SoundLink Mini II, unlike the SoundLink Color II, only has one HID report in normal mode, which per the spec means the report ID is omitted. Since we don't parse the HID descriptor, we strip the report ID unconditionally. (Or maybe hidapi does for us? It's been a while since I looked at that.)

I'm not at my main computer now and don't have access to my speaker, but I'll try to get that issue fixed in a few days when I get back. That should make this mode much more useful.

@hakanf

hakanf commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

OK, I'm making those changes, hold on...
I have been wondering if the report ID is not really a report ID as such, and perhaps is the length of the command instead? (Just because of the coincidence that 2 is the length of all commands that do work, not because of anything I know or have tested...)

1: use .is_empty()
2: use rustyline
3: reduce common code
4: move tap loop into main.rs
I also did a minor change to only strip the first byte of the response if it matches the report ID
@hakanf

hakanf commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

I cant figure out why rustyline wont save the history file, or indeed do anything with the history, but line editing seems to work...

@tchebb tchebb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, this is almost ready to merge now! Just minor feedback left.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread src/main.rs
Comment thread src/main.rs Outdated
Comment thread Cargo.toml Outdated
Comment thread src/protocol.rs Outdated
Comment thread src/protocol.rs Outdated
Comment thread src/protocol.rs Outdated
@tchebb

tchebb commented Jul 28, 2025

Copy link
Copy Markdown
Owner

I have been wondering if the report ID is not really a report ID as such

On your device, it might not be—it definitely doesn't seem to be included in responses like it was on the device I tested with. But on my device (SoundLink Color II), it definitely is a Report ID, since there are other HID reports that I also observed in the USB capture.

If increasing that number makes commands work for you, let me know. That'd be an interesting difference between devices.

@hakanf

hakanf commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

I have been wondering if the report ID is not really a report ID as such

On your device, it might not be—it definitely doesn't seem to be included in responses like it was on the device I tested with. But on my device (SoundLink Color II), it definitely is a Report ID, since there are other HID reports that I also observed in the USB capture.

If increasing that number makes commands work for you, let me know. That'd be an interesting difference between devices.

No, it does not work on my device, instead I get a DeviceIoError...

Err(DeviceIoError { source: HidApiError { message: "ioctl (GFEATURE): Broken pipe" }, action: "reading TAP command response" })

1: Remove unneccesary features from rustyline
2: Fix command history
3: Remove history file
4: Fix typo's in README.md
5: Fix comment in run_tap_command
6: Use escape_ascii instead of from_utf8
7: Remove Soundlink mini II hack to get full output string
@hakanf

hakanf commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

Hm, perhaps we should step version number to 1.2.0?
Sorry about all the newbie errors, first time I am writing rust...

@tchebb

tchebb commented Jul 28, 2025

Copy link
Copy Markdown
Owner

Hm, perhaps we should step version number to 1.2.0?

I'll handle a version bump and release in a separate commit.

Sorry about all the newbie errors, first time I am writing rust...

No need to apologize! I really appreciate the contribution.

@tchebb tchebb merged commit 4937bcf into tchebb:main Jul 28, 2025
2 checks passed
@tchebb

tchebb commented Jul 28, 2025

Copy link
Copy Markdown
Owner

Merged! Thanks again.

@tchebb

tchebb commented Jul 28, 2025

Copy link
Copy Markdown
Owner

It'll probably be a week or so before I can cut a new release, since I'd like to get back home to my own device and do some testing first.

@hakanf

hakanf commented Jul 28, 2025

Copy link
Copy Markdown
Contributor Author

No worries, take your time

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.

3 participants