Add NC 700 support, logging, and CMake build#22
Open
JohnMansell wants to merge 1 commit into
Open
Conversation
Note: This contribution was developed with AI assistance (Claude by Anthropic). Issue ----- The NC 700 was not recognised by the tool and the protocol handling assumed fixed-size responses, which broke on devices that return different payload lengths. Most set commands on the NC 700 do not send a confirmation packet, causing the tool to report failure even when the setting was applied. The original read() calls did not retry on short reads, making them fragile over RFCOMM. There was no way to inspect raw packet traffic when debugging a new device. Solution -------- Add explicit NC 700 support and harden the protocol layer to handle variable-length, length-prefixed responses. Treat EAGAIN on a confirmation read as success for devices that do not send one. Loop inside read() until exactly N bytes are received. Add a leveled logging system so packet-level traces can be enabled on demand without recompiling. Changes ------- - based.h: add DeviceId enum (QC35, QC35_II, SOUNDLINK_II, NC700); expand VER_STR_LEN from 6 to 32; fix send_packet parameter name typo. - based.c: add DEVICE_NC700 to has_noise_cancelling(); add read_exact() helper that retries short reads; refactor init_connection, get_device_id, get_firmware_version, and get_battery_level to read a 4-byte header and drain a length-prefixed payload; handle EAGAIN-as-success in all set commands; fix get_name mask to accept NC 700 encoding byte; simplify set_voice_prompts to not fetch full device status first; replace abs() difference comparisons with != for enum return values. - main.c: add -D / --debug flag wired to log_set_level(LOG_LEVEL_DEBUG); increase SO_RCVTIMEO from 1 s to 5 s; fix receive typo; improve error reporting when a command returns non-zero. - log.c / log.h: new leveled logging module (DEBUG/INFO/WARN/ERROR), off by default, writes to stderr with file/line/function prefix and a hex-dump helper for packet bytes. - CMakeLists.txt: new CMake build (C11, -Wall -Wextra -Wpedantic). - COMPATIBILITY.md: per-device feature matrix and per-device protocol notes covering QC35, SoundLink II, and NC 700. - README.txt: document -D flag, update disclaimer, expand todo list, add contributing / adding device support guide with HCI capture instructions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Confirmed on my NC 700 FW 1.8.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: This contribution was developed with AI assistance (Claude by Anthropic).
Issue
The NC 700 was not recognised by the tool and the protocol handling assumed fixed-size responses, which broke on devices that return different payload lengths. Most set commands on the NC 700 do not send a confirmation packet, causing the tool to report failure even when the setting was applied. The original read() calls did not retry on short reads, making them fragile over RFCOMM. There was no way to inspect raw packet traffic when debugging a new device.
Solution
Add explicit NC 700 support and harden the protocol layer to handle variable-length, length-prefixed responses. Treat EAGAIN on a confirmation read as success for devices that do not send one. Loop inside read() until exactly N bytes are received. Add a leveled logging system so packet-level traces can be enabled on demand without recompiling.
Changes