Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gap/linux: correct issue with new Bluez and manufacturer data #121

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 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,13 @@ 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)
// can be either variant or just byte value
switch val := v.(type) {
case dbus.Variant:
mData[k] = val.Value().([]byte)
case []byte:
mData[k] = val
}
}

return ScanResult{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/go-ole/go-ole v1.2.6
github.com/godbus/dbus/v5 v5.0.3
github.com/muka/go-bluetooth v0.0.0-20220323170840-382ca1d29f29
github.com/muka/go-bluetooth v0.0.0-20220830075246-0746e3a1ea53
github.com/saltosystems/winrt-go v0.0.0-20220826130236-ddc8202da421
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/tinygo-org/cbgo v0.0.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/muka/go-bluetooth v0.0.0-20220323170840-382ca1d29f29 h1:kktgrt46k7/jbIpOpcOvULZgMYlTkgq4BJJ3fhT27Dc=
github.com/muka/go-bluetooth v0.0.0-20220323170840-382ca1d29f29/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0=
github.com/muka/go-bluetooth v0.0.0-20220830075246-0746e3a1ea53 h1:zfLHhuGzmSbthZ00FfbEjgAHUOOj7NGiITojMTCFy6U=
github.com/muka/go-bluetooth v0.0.0-20220830075246-0746e3a1ea53/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/paypal/gatt v0.0.0-20151011220935-4ae819d591cf/go.mod h1:+AwQL2mK3Pd3S+TUwg0tYQjid0q1txyNUJuuSmz8Kdk=
Expand Down