summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--soundbox.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/soundbox.go b/soundbox.go
index 389d1da..d6a0a34 100644
--- a/soundbox.go
+++ b/soundbox.go
@@ -18,12 +18,14 @@ func NewSoundbox(mac string) (Soundbox, error) {
if err != nil {
return Soundbox{}, err
}
-
- if len(hardwareAddr) != 6 {
+
+ return fromHardwareAddr(hardwareAddr)
+}
+
+func fromHardwareAddr(addr net.HardwareAddr) (Soundbox, error) {
+ if len(addr) != 6 {
return Soundbox{}, fmt.Errorf("Only IEEE 802 MAC-48 addresses supported")
}
- return Soundbox{
- HardwareAddr: hardwareAddr,
- }, nil
+ return Soundbox{HardwareAddr: addr}, nil
}