Files
Bose-SoundTouch/pkg/models/device.go
T
Tobias Gesellchen 7de6b8246b Initial commit: Bose SoundTouch API Client PoC
- Implement HTTP client with XML support for SoundTouch Web API
- Add UPnP device discovery with SSDP protocol
- Create type-safe Go models for API responses
- Build CLI tool with device discovery and info commands
- Add comprehensive configuration management via .env and env vars
- Include extensive documentation (API endpoints, patterns, development guide)
- Translate all German documentation to English
- Set up modern Go project structure with testing framework
- Add Makefile for cross-platform builds and development workflow

Features:
 Device discovery (UPnP + manual configuration)
 Device information retrieval
 XML request/response handling
 CLI interface with flexible device targeting
 Cross-platform compatibility
 Comprehensive test coverage with mock data
 Production-ready configuration management
2026-01-08 23:01:32 +01:00

66 lines
1.9 KiB
Go

package models
import (
"encoding/xml"
"time"
)
// DeviceInfo represents the response from GET /info endpoint
type DeviceInfo struct {
XMLName xml.Name `xml:"info"`
DeviceID string `xml:"deviceID,attr"`
Name string `xml:"name"`
Type string `xml:"type"`
MargeAccountUUID string `xml:"margeAccountUUID"`
Components []Component `xml:"components>component"`
MargeURL string `xml:"margeURL"`
NetworkInfo []NetworkInfo `xml:"networkInfo"`
ModuleType string `xml:"moduleType"`
Variant string `xml:"variant"`
VariantMode string `xml:"variantMode"`
CountryCode string `xml:"countryCode"`
RegionCode string `xml:"regionCode"`
}
// Component represents a device component
type Component struct {
ComponentCategory string `xml:"componentCategory"`
SoftwareVersion string `xml:"softwareVersion"`
SerialNumber string `xml:"serialNumber"`
}
// NetworkInfo represents network information for the device
type NetworkInfo struct {
Type string `xml:"type,attr"`
MacAddress string `xml:"macAddress"`
IPAddress string `xml:"ipAddress"`
}
// XMLResponse is a generic wrapper for API responses
type XMLResponse struct {
XMLName xml.Name
Error *APIError `xml:"error,omitempty"`
}
// APIError represents an error response from the API
type APIError struct {
Code int `xml:"code,attr"`
Message string `xml:",chardata"`
}
// Error implements the error interface
func (e *APIError) Error() string {
return e.Message
}
// DiscoveredDevice represents a device found through UPnP discovery
type DiscoveredDevice struct {
Name string `json:"name"`
Host string `json:"host"`
Port int `json:"port"`
ModelID string `json:"model_id"`
SerialNo string `json:"serial_no"`
Location string `json:"location"`
LastSeen time.Time `json:"last_seen"`
}