6 Commits
Author SHA1 Message Date
Tobias GesellchenandClaude Opus 4.7 29a462da2b feat(setup): add CLI setup command group for end-to-end speaker provisioning
Add `soundtouch-cli setup` subcommand group covering the full reset →
re-provision → pair lifecycle as a scriptable alternative to the web UI:

  inspect, verify, plan, factory-reset, wait-ap, wifi-push, wait-online,
  ssh-check, install-ca, migrate, reboot, pair (bare | full state machine)

Supporting library code lives in pkg/service/setup: factory_reset.go,
wifi_provision.go, inspect.go, init_plan.go, setup_session.go.

Confirmed against ST10 firmware 27.0.6 that bare setMargeAccount over
WebSocket — no SETUP_START/SETUP_ENTER/SETUP_LEAVE bracket — is
sufficient to pair a factory-reset speaker; the firmware materializes
SystemConfigurationDB.xml and Sources.xml itself and the pairing
survives reboot. Result and field-by-field SystemConfigurationDB
comparison documented in docs/analysis/SETUP-WEBSOCKET-EXPERIMENT.md.
Captures the device's pre-reset DELETE-to-marge plus its LAN peer
notification flow in docs/analysis/FACTORY-RESET-PROTOCOL.md.

Perf: batch GetMigrationSummary's SSH probes into one Run() call via
ssh_probe.go / ssh_probe_apply.go — was ~8 sequential dials at
500-1000 ms each on FW 27 crypto, now one round-trip. Same data shape,
same MigrationSummary fields populated.

Fixes /clockTime and /clockDisplay wire formats — firmware 27 rejects
the legacy flat XML ("Error parsing request"). ClockTimeRequest now
uses utcTime attribute; ClockDisplayRequest emits the nested
<clockConfig> envelope with timezoneInfo/timeFormat/brightnessLevel.

Removes cmd/example-init-speaker (superseded by setup pair).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 18:43:36 +02:00
Tobias Gesellchen 6a815219f6 Implement /requestToken API and fix clock time display
Major Features:
• Implement complete /requestToken API endpoint for bearer token generation
• Fix clock time parsing and display with comprehensive time information
• Add comprehensive API documentation for 103 discovered endpoints

/requestToken Implementation:
• Add BearerToken model with full XML marshaling support
• Add RequestToken() client method with proper error handling
• Add 'soundtouch-cli token request' CLI command with security features
• Token validation, formatting, and secure display (truncated for security)
• Comprehensive unit tests and integration tests
• Support for Authorization header formatting and raw token extraction

Clock Time Fixes:
• Fix ClockTime model to match actual device XML response structure
• Add LocalTime component for nested time details
• Support for utcTime, timeFormat, brightness, clockError attributes
• Enhanced CLI display with comprehensive time information
• Fixed month conversion (device uses 0-11, Go uses 1-12)

Documentation Enhancements:
• Add comprehensive /supportedURLs endpoint analysis (103 endpoints discovered)
• Create detailed unimplemented endpoints documentation with examples
• Update API coverage from 34% implemented to full endpoint catalog
• Add SoundTouch End of Life notice with May 6, 2026 details
• Enhanced endpoint descriptions with real device response examples

Security:
• All tests use generic token examples (no real tokens exposed)
• Integration tests validate token properties without exposing values
• Secure token display with truncation in CLI and string representations
• Environment variable based testing for real devices

Testing:
• 15+ new test functions with comprehensive coverage
• Real device validation on 192.168.178.28 and 192.168.178.35
• Mock server tests and XML marshaling validation
• Integration tests with SOUNDTOUCH_TEST_HOST environment variable

CLI Enhancements:
• Enhanced clock time display with local time details and device settings
• New token management commands with usage instructions
• Improved error handling and user-friendly output formatting
2026-01-11 23:09:29 +01:00
Tobias Gesellchen ccd19d97a5 docs: add attribution to official Bose SoundTouch Web API documentation
- Reference original API documentation source from Bose Corporation
- Link to official Bose SoundTouch End-of-Life page
- Clarify this is an independent implementation
- Add disclaimer about non-affiliation with Bose Corporation
- Provide both online and local documentation references
2026-01-10 00:34:54 +01:00
Tobias Gesellchen 62a67818d2 Fix golangci-lint issues: resolve range copy, naming, and whitespace violations
- Fix range copy issues in cmd_network.go (use indexing instead of copying 168-byte structs)
- Rename DiscoveryService to Service to avoid package name stuttering
- Update all references to use new Service constructor names
- Apply automatic whitespace fixes using golangci-lint --fix
- Reduce linting issues from 32 to 7 (only cyclomatic complexity remains)

Remaining issues are architectural complexity violations that require manual refactoring.
2026-01-10 00:02:59 +01:00
Tobias Gesellchen 433368788b feat: complete CLI feature parity with original main.go
🎉 100% Feature Complete CLI Refactoring

MAJOR IMPROVEMENTS:
- Refactored from monolithic 149-complexity main.go to modular urfave/cli structure
- Added ALL missing commands for complete feature parity (47/47 features)
- Reduced golangci-lint issues by 70% (108+ → 32)

NEW COMMAND FILES:
- cmd_bass.go - Bass control (get/set/up/down/capabilities)
- cmd_balance.go - Balance control (get/set/left/right/center)
- cmd_clock.go - Clock management (time + display settings)
- cmd_network.go - Network information (info/ping/URL)
- cmd_zone.go - Multi-room zones (get/create/add/remove/dissolve)
- cmd_playback.go - Enhanced with key commands (volume-up/down, power, mute, etc.)
- cmd_info.go - Enhanced with preset selection and track info

COMPLETE FEATURE MAPPING:
 Discovery: discover devices [--all]
 Device Info: info, name get/set, capabilities, presets, track
 Playback: play start/pause/stop/next/prev, key send/power/mute/thumbs-up/down/volume-up/down
 Volume: volume get/set/up/down (with safety warnings, defaults: ±2)
 Bass: bass get/set/up/down/capabilities (defaults: ±1)
 Balance: balance get/set/left/right/center (defaults: ±5)
 Sources: source list/select/spotify/bluetooth/aux (with account support)
 Clock: clock get/set/now + display enable/disable/brightness/format (supports Unix timestamps, auto format)
 Network: network info/ping/url
 Zones: zone get/status/members/create/add/remove/dissolve/set
 Presets: preset selection by number (1-6)

PRESERVED FEATURES:
 All safety warnings and limits maintained
 Default increment/decrement values preserved
 Environment variable support (SOUNDTOUCH_HOST, SOUNDTOUCH_PORT)
 Extended format support (Unix timestamps, 'now', 'auto' clock format)
 Source account parameters for streaming services
 Zone deviceID@ip format support

ENHANCED USER EXPERIENCE:
 Organized subcommand hierarchy instead of 47 flat flags
 Comprehensive help system for each command
 Consistent flag naming (--host, --port, --timeout)
 Rich error messages with success/warning indicators
 Input validation and safety checks

ARCHITECTURAL IMPROVEMENTS:
 Modular command structure for better maintainability
 Shared utilities in common.go
 Consistent error handling and client configuration
 Clean separation of concerns

EXAMPLES:
# Discovery
soundtouch-cli discover devices --all --timeout 15s

# Volume control
soundtouch-cli volume set --host 192.168.1.100 --level 50
soundtouch-cli volume up --host 192.168.1.100 --amount 3

# Bass/Balance control
soundtouch-cli bass set --host 192.168.1.100 --level 3
soundtouch-cli balance left --host 192.168.1.100 --amount 5

# Key commands
soundtouch-cli key power --host 192.168.1.100
soundtouch-cli key send --host 192.168.1.100 --key SHUFFLE_ON

# Source selection
soundtouch-cli source select --host 192.168.1.100 --source SPOTIFY --account myaccount
soundtouch-cli source bluetooth --host 192.168.1.100

# Clock management
soundtouch-cli clock set --host 192.168.1.100 --time now
soundtouch-cli clock display format --host 192.168.1.100 --format 24

# Zone management
soundtouch-cli zone create --host 192.168.1.100 --members 192.168.1.101,192.168.1.102

Breaking Changes:
- CLI now uses subcommands instead of flat flags (functional equivalent provided for all commands)

RESULT: Transformed a 149-complexity monolithic CLI into a clean, organized,
feature-complete tool with 100% functionality preservation and significant UX improvements! 🚀
2026-01-09 23:54:10 +01:00
Tobias Gesellchen e203909697 feat: complete CLI refactoring with urfave/cli
- Refactored soundtouch-cli from monolithic main.go to modular command structure
- Added urfave/cli/v2 dependency for better CLI organization
- Created separate command files for all SoundTouch features:
  * cmd_discover.go - Device discovery commands
  * cmd_info.go - Device information commands
  * cmd_volume.go - Volume control commands
  * cmd_playback.go - Playback control commands
  * cmd_source.go - Source selection commands
  * cmd_bass.go - Bass control commands (NEW)
  * cmd_balance.go - Balance control commands (NEW)
  * cmd_clock.go - Clock/time management commands (NEW)
  * cmd_network.go - Network information commands (NEW)
  * cmd_zone.go - Multi-room zone management commands (NEW)
  * common.go - Shared utilities and client setup

- Fixed flag conflicts by using --verbose instead of -v and removing -h alias from --host
- Implemented comprehensive CLI with organized subcommands and consistent UX
- Added proper help documentation and parameter validation
- Reduced golangci-lint issues by 70% (108+ → 32)
- Added package comments to new command files

Breaking changes:
- CLI now uses subcommands instead of flat flags
- Old: soundtouch-cli -host 192.168.1.100 -volume
- New: soundtouch-cli volume get --host 192.168.1.100

Examples:
- soundtouch-cli discover devices --all
- soundtouch-cli volume set --host 192.168.1.100 --level 50
- soundtouch-cli bass get --host 192.168.1.100
- soundtouch-cli clock set --host 192.168.1.100 --time '14:30'
- soundtouch-cli zone create --host 192.168.1.100 --members 192.168.1.101,192.168.1.102
2026-01-09 23:45:48 +01:00