Skip to content

Commit 57f82b6

Browse files
committed
gap/linux: workaround for muka/go-bluetooth#163
Signed-off-by: deadprogram <[email protected]>
1 parent 39e6a35 commit 57f82b6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

gap_linux.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ func (a *Adapter) Scan(callback func(*Adapter, ScanResult)) error {
198198
case "UUIDs":
199199
props.UUIDs = val.Value().([]string)
200200
case "ManufacturerData":
201-
props.ManufacturerData = val.Value().(map[uint16]interface{})
201+
// work around for https://github.com/muka/go-bluetooth/issues/163
202+
mData := make(map[uint16]interface{})
203+
for k, v := range val.Value().(map[uint16]dbus.Variant) {
204+
mData[k] = v.Value().(interface{})
205+
}
206+
props.ManufacturerData = mData
202207
}
203208
}
204209
callback(a, makeScanResult(props))
@@ -241,8 +246,12 @@ func makeScanResult(props *device.Device1Properties) ScanResult {
241246

242247
mData := make(map[uint16][]byte)
243248
for k, v := range props.ManufacturerData {
244-
temp := v.(dbus.Variant)
245-
mData[k] = temp.Value().([]byte)
249+
switch val := v.(type) {
250+
case dbus.Variant:
251+
mData[k] = val.Value().([]byte)
252+
case []byte:
253+
mData[k] = val
254+
}
246255
}
247256

248257
return ScanResult{

0 commit comments

Comments
 (0)