Skip to content

heartrate example panic #198

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

Closed
gitchander opened this issue Sep 27, 2023 · 12 comments
Closed

heartrate example panic #198

gitchander opened this issue Sep 27, 2023 · 12 comments

Comments

@gitchander
Copy link

gitchander commented Sep 27, 2023

I have next problem with standard example of heartrate-monitor:

panic: interface conversion: interface {} is map[string]map[string]dbus.Variant, not dbus.ObjectPath

goroutine 1 [running]:
tinygo.org/x/bluetooth.(*Adapter).Scan(0x786c00, 0xc0000bdea8)
.../pkg/mod/tinygo.org/x/[email protected]/gap_linux.go:177 +0xeb7

How I can fix it?

@TirelessDev
Copy link
Contributor

Can you provide a bit more information, please?

What are you running this on?
Are you using the latest release or a branch?
What version of DBus are you running?

Cheers

@gitchander
Copy link
Author

gitchander commented Oct 2, 2023

I do it on:
os Ubuntu 22.04.3 LTS

Adapter USB Bluetooth 5.1 USB 2.0 RTL8761B Chip

I used last version, not branch.

go.mod file:

go 1.21.0

require tinygo.org/x/bluetooth v0.8.0

require (
github.com/fatih/structs v1.1.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/muka/go-bluetooth v0.0.0-20221213043340-85dc80edc4e1 // indirect
github.com/saltosystems/winrt-go v0.0.0-20230921082907-2ab5b7d431e1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/tinygo-org/cbgo v0.0.4 // indirect
golang.org/x/sys v0.12.0 // indirect
)

go.sum file:

tinygo.org/x/bluetooth v0.7.0 h1:7lU0VrauwccbLvb6AKHf4ZedFlxZIFwwqHWQD2fLWvA=
tinygo.org/x/bluetooth v0.7.0/go.mod h1:2hZPpfPDMR7Vvi6yMvyi83o8gYXeMKKsLfUnvmtBcjM=
tinygo.org/x/bluetooth v0.8.0 h1:WmuRebsODcUUIlGhesyuNRIAEIUCErhKlrZ9K9aimdI=
tinygo.org/x/bluetooth v0.8.0/go.mod h1:cfsVc0/nGo3nzi6+CeQaXb+anNlmEnSABkKsxer8OAE=

@TirelessDev
Copy link
Contributor

Sweet thanks, what does bluetoothctl -v say?

@gitchander
Copy link
Author

bluetoothctl: 5.64

@TirelessDev
Copy link
Contributor

Okay, very peculiar. Everything checks out with the versions that I can see.

The panic seems to suggest that the dbus object that has been provided in the org.freedesktop.DBus.ObjectManager.InterfacesAdded signal is somehow backwards with the Variant map in index 0 and the object path in index 1. I have no idea how that would happen though.

bluetooth/gap_linux.go

Lines 177 to 178 in d0c7887

objectPath := sig.Body[0].(dbus.ObjectPath)
interfaces := sig.Body[1].(map[string]map[string]dbus.Variant)

maybe try monitor dbus with sudo busctl monitor org.bluez | grep -A4 "InterfacesAdded" you should get something like the following show up when new devices are found during the scan.

  Sender=:1.212  Path=/  Interface=org.freedesktop.DBus.ObjectManager  Member=InterfacesAdded
  UniqueName=:1.212
  MESSAGE "oa{sa{sv}}" {
          OBJECT_PATH "/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX";
          ARRAY "{sa{sv}}" {

You can also manually enable a scan without running any go code with the command bluetoothctl scan on.

@gitchander
Copy link
Author

I scanned and connected to BlueNRG-345 (dev kit STEVAL-IDB), discovered services and read characteristics. There was no problem.

@gitchander
Copy link
Author

gitchander commented Oct 3, 2023

len(sig.Body) => 1
sig.Body[0] type is "map[string]map[string]dbus.Variant"

map key "org.bluez.GattService1"
map values:
"Handle": @q 0
"Primary": true
"UUID": "0000180d-0000-1000-8000-00805f9b34fb"
"Characteristics": @ao []

@TirelessDev
Copy link
Contributor

Not too sure what could be going on then. If you haven't already I would try reinstalling BlueZ or maybe trying a different version.

@gitchander
Copy link
Author

Can I run heartrate server and client on one PC?

@deadprogram
Copy link
Member

Very good chance this is now fixed by #216 which was merged into dev branch.

@aykevl
Copy link
Member

aykevl commented Jan 5, 2024

Can I run heartrate server and client on one PC?

No. But you can use a smartphone app, for example "nRF Connect" on Android.
(I'm personally also using a Raspberry Pi for testing such stuff as a 2nd system).

@gitchander is this still a bug?

@gitchander
Copy link
Author

If you start the client first and then start the server on the same PC, this will still lead to panic. Maybe this can be fixed.
Thanks for your answer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants