MAC Address to Serial Number Mapping
MAC Address to Serial Number Mapping
Understanding and troubleshooting device identification in SoundTouch service
This guide explains how the SoundTouch service handles device identification through MAC address to serial number mapping, and how to troubleshoot related issues.
π Overview
The SoundTouch service uses two different identifiers for devices:
- MAC Address (
AABBCCDDEEFF) - Used in HTTP API requests and UPnP discovery - Serial Number (
I6332527703739342000020) - Used for internal file storage
The service automatically maps between these identifiers so that API requests using MAC addresses can access files stored using serial numbers.
π How It Works
Request Flow
1. HTTP Request: GET /streaming/account/1000001/device/AABBCCDDEEFF/presets
2. MAC Resolution: AABBCCDDEEFF β I6332527703739342000020
3. File Access: accounts/1000001/devices/I6332527703739342000020/Presets.xmlUPnP Discovery Integration
The service extracts MAC addresses from UPnP device descriptions:
<!-- From http://192.0.2.100:8091/XD/BO5EBO5E-F00D-F00D-FEED-AABBCCDDEEFF.xml -->
<root xmlns="urn:schemas-upnp-org:device-1-0">
<device>
<friendlyName>Sound Machinery</friendlyName>
<modelName>SoundTouch 10</modelName>
<serialNumber>AABBCCDDEEFF</serialNumber> <!-- MAC address here -->
</device>
</root>βοΈ Automatic Setup
The mapping is created automatically when the service starts:
- Directory Scan: Service scans
data/accounts/{account}/devices/{serial}/ - DeviceInfo.xml: Reads MAC address from each device’s info file
- Mapping Creation: Creates MAC β Serial mapping in memory
- Normalization: Handles different MAC address formats automatically
π οΈ Supported MAC Address Formats
The service handles all common MAC address formats automatically:
| Format | Example | Status |
|---|---|---|
| Standard | AABBCCDDEEFF | β Supported |
| Lowercase | a81b6a536a98 | β Supported |
| With Colons | AA:BB:CC:DD:EE:FF | β Supported |
| With Dashes | AA-BB-CC-DD-EE-FF | β Supported |
| Mixed Case | a81B6a536A98 | β Supported |
| With Spaces | AABBCCDDEEFF | β Supported |
π§ Troubleshooting
Problem: API requests fail with “file not found” errors
Symptoms:
GET /streaming/account/1000001/device/AABBCCDDEEFF/presets
β 500 Internal Server Error
β Log: "open .../devices/AABBCCDDEEFF/Presets.xml: no such file or directory"Diagnosis:
Check if mapping exists:
# Look for device directory ls data/accounts/1000001/devices/ # Should show serial numbers like: I6332527703739342000020Check DeviceInfo.xml:
cat data/accounts/1000001/devices/I6332527703739342000020/DeviceInfo.xml # Look for <macAddress> field
Solutions:
Solution 1: Restart the Service
The mapping is created at startup. Simply restart:
sudo systemctl restart soundtouch-serviceSolution 2: Check DeviceInfo.xml Format
Ensure the MAC address is present:
<info deviceID="I6332527703739342000020">
<networkInfo type="SCM">
<macAddress>AABBCCDDEEFF</macAddress> <!-- Must be present -->
<ipAddress>192.0.2.10</ipAddress>
</networkInfo>
</info>Solution 3: Manual Device Addition
If the device was added manually, ensure proper structure:
# Create device directory using serial number
mkdir -p data/accounts/1000001/devices/I6332527703739342000020
# Create DeviceInfo.xml with MAC address
cat > data/accounts/1000001/devices/I6332527703739342000020/DeviceInfo.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<info deviceID="I6332527703739342000020">
<name>My SoundTouch Device</name>
<networkInfo type="SCM">
<macAddress>AABBCCDDEEFF</macAddress>
<ipAddress>192.0.2.100</ipAddress>
</networkInfo>
</info>
EOFProblem: UPnP discovery not creating mappings
Check UPnP accessibility:
# Test UPnP endpoint directly
curl http://192.0.2.100:8091/XD/BO5EBO5E-F00D-F00D-FEED-AABBCCDDEEFF.xml
# Should return XML with <serialNumber> fieldEnable debug logging:
# Check service logs for UPnP activity
journalctl -u soundtouch-service -f | grep UPnPProblem: Case or format mismatches
This should be handled automatically, but you can verify:
Test different formats:
# All of these should work the same:
curl http://localhost:8000/streaming/account/1000001/device/AABBCCDDEEFF/presets
curl http://localhost:8000/streaming/account/1000001/device/a81b6a536a98/presets
curl http://localhost:8000/streaming/account/1000001/device/AA:BB:CC:DD:EE:FF/presetsπ Monitoring and Diagnostics
Check Current Mappings
The service logs mapping creation at startup:
journalctl -u soundtouch-service | grep "MAC.*serial"Verify File Structure
Ensure proper directory organization:
data/
βββ accounts/
βββ 1000001/
βββ devices/
βββ I6332527703739342000020/ # Serial number directory
βββ DeviceInfo.xml # Contains MAC address
βββ Presets.xml
βββ Sources.xmlπ Related Documentation
- Device Initial Setup - Setting up new devices
- Troubleshooting Guide - General troubleshooting steps
- SoundTouch Service - Service configuration and management
ποΈ Technical Implementation
For developers interested in the technical details:
Normalization Algorithm
// MAC addresses are normalized by:
// 1. Removing spaces, colons, and dashes
// 2. Converting to uppercase
// Examples:
// "a8:1b:6a:53:6a:98" β "AABBCCDDEEFF"
// "AA-BB-CC-DD-EE-FF" β "AABBCCDDEEFF"Lookup Process
// 1. Try exact match first
// 2. If not found, try normalized version
// 3. Return serial number for file accessPerformance
- Lookup Time: O(1) - Hash map lookup
- Memory Usage: ~40 bytes per device mapping
- Initialization: Scans all devices once at startup
π Best Practices
- Use Discovery: Let UPnP discovery create mappings automatically
- Consistent Format: Store MAC addresses consistently in DeviceInfo.xml
- Service Restart: Restart service after manual device additions
- Monitoring: Check logs for mapping creation during startup
- Backup: Keep DeviceInfo.xml files backed up
β οΈ Known Limitations
- Mappings are created only at service startup
- Manual device additions require service restart
- MAC addresses must be present in DeviceInfo.xml
- No automatic cleanup of stale mappings (restart required)