Skip to content

Commit

Permalink
gap/linux: workaround for muka/go-bluetooth#163
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <ron@hybridgroup.com>
  • Loading branch information
deadprogram committed Sep 26, 2022
1 parent 9052d65 commit 1aa87a1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions gap_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ func (a *Adapter) Scan(callback func(*Adapter, ScanResult)) error {
case "UUIDs":
props.UUIDs = val.Value().([]string)
case "ManufacturerData":
props.ManufacturerData = val.Value().(map[uint16]interface{})
// work around for https://github.com/muka/go-bluetooth/issues/163
mData := make(map[uint16]interface{})
for k, v := range val.Value().(map[uint16]dbus.Variant) {
mData[k] = v.Value().(interface{})
}
props.ManufacturerData = mData
}
}
callback(a, makeScanResult(props))
Expand Down Expand Up @@ -241,8 +246,12 @@ func makeScanResult(props *device.Device1Properties) ScanResult {

mData := make(map[uint16][]byte)
for k, v := range props.ManufacturerData {
temp := v.(dbus.Variant)
mData[k] = temp.Value().([]byte)
switch val := v.(type) {
case dbus.Variant:
mData[k] = val.Value().([]byte)
case []byte:
mData[k] = val
}
}

return ScanResult{
Expand Down

0 comments on commit 1aa87a1

Please sign in to comment.