Skip to content

Add NC 700 support, logging, and CMake build#22

Open
JohnMansell wants to merge 1 commit into
Denton-L:masterfrom
JohnMansell:add-nc700
Open

Add NC 700 support, logging, and CMake build#22
JohnMansell wants to merge 1 commit into
Denton-L:masterfrom
JohnMansell:add-nc700

Conversation

@JohnMansell

Copy link
Copy Markdown

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.

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>
@zewelor

zewelor commented May 15, 2026

Copy link
Copy Markdown

Confirmed on my NC 700 FW 1.8.2

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