gap: change signature for Addresser interface Set() function to accept string and then parse it as needed

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2020-09-20 11:28:39 +02:00 committed by Ayke
parent f04c1cbe78
commit 281d195e75
2 changed files with 13 additions and 5 deletions

10
gap.go

@ -30,8 +30,12 @@ func (mac MACAddress) SetRandom(val bool) {
}
// Set the address
func (mac MACAddress) Set(val interface{}) {
m := val.(MAC)
func (mac MACAddress) Set(val string) {
m, err := ParseMAC(val)
if err != nil {
return
}
mac.MAC = m
}
@ -72,7 +76,7 @@ type Addresser interface {
String() string
// Set the address
Set(val interface{})
Set(val string)
// Is this address a random address?
// Bluetooth addresses are roughly split in two kinds: public

@ -24,8 +24,12 @@ func (ad Address) SetRandom(val bool) {
}
// Set the address
func (ad Address) Set(val interface{}) {
ad.UUID = val.(UUID)
func (ad Address) Set(val string) {
uuid, err := ParseUUID(val)
if err != nil {
return
}
ad.UUID = uuid
}
// Scan starts a BLE scan. It is stopped by a call to StopScan. A common pattern