Skip to content

Commit 281d195

Browse files
deadprogramaykevl
authored andcommitted
gap: change signature for Addresser interface Set() function to accept string and then parse it as needed
Signed-off-by: deadprogram <ron@hybridgroup.com>
1 parent f04c1cb commit 281d195

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

gap.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ func (mac MACAddress) SetRandom(val bool) {
3030
}
3131

3232
// Set the address
33-
func (mac MACAddress) Set(val interface{}) {
34-
m := val.(MAC)
33+
func (mac MACAddress) Set(val string) {
34+
m, err := ParseMAC(val)
35+
if err != nil {
36+
return
37+
}
38+
3539
mac.MAC = m
3640
}
3741

@@ -72,7 +76,7 @@ type Addresser interface {
7276
String() string
7377

7478
// Set the address
75-
Set(val interface{})
79+
Set(val string)
7680

7781
// Is this address a random address?
7882
// Bluetooth addresses are roughly split in two kinds: public

gap_darwin.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ func (ad Address) SetRandom(val bool) {
2424
}
2525

2626
// Set the address
27-
func (ad Address) Set(val interface{}) {
28-
ad.UUID = val.(UUID)
27+
func (ad Address) Set(val string) {
28+
uuid, err := ParseUUID(val)
29+
if err != nil {
30+
return
31+
}
32+
ad.UUID = uuid
2933
}
3034

3135
// Scan starts a BLE scan. It is stopped by a call to StopScan. A common pattern

0 commit comments

Comments
 (0)