Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Device1.GetManufacturerData() fails #163

Open
fazalmajid opened this issue Jun 23, 2022 · 4 comments
Open

Device1.GetManufacturerData() fails #163

fazalmajid opened this issue Jun 23, 2022 · 4 comments

Comments

@fazalmajid
Copy link

It fails with this panic:

2022/06/23 19:33:39 new event: 1 &{/org/bluez/hci0/dev_5B_85_EF_47_EC_5D 1} &{0xc00019bfe0 <nil> <nil> <nil> 0xc0001da000 <nil>}
panic: interface conversion: interface {} is map[uint16]dbus.Variant, not map[string]interface {}

goroutine 38 [running]:
github.com/muka/go-bluetooth/bluez/profile/device.(*Device1).GetManufacturerData(0xc0000edf78?)
	/home/majid/go/pkg/mod/github.com/muka/go-bluetooth@v0.0.0-20220604035144-0b043d86dc03/bluez/profile/device/gen_Device1.go:422 +0x7c
main.stream(0xc0000d80c0?)
	/home/majid/thass/thass.go:78 +0x15c
created by main.main
	/home/majid/thass/thass.go:114 +0x2b7

According to the BlueZ DBus API specs, the keys are indeed uint16, not string:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/device-api.txt#n249

I don't know if this API changed. Using BlueZ 5.64 on Alpine Linux 3.16

@sam-mathews
Copy link
Contributor

I believe there are two issues at play here. The first is that types that have been overridden, don't carry the override through to the access methods, I've created #166 to address this.

The second issue is that the property is set to a map with a dbus.Variant instead of interface{}. The type assertion cannot seamlessly do that conversion for us - we would need to recreate the map. I haven't wrapped my head around the codebase enough to understand what the correct solution is for this. As I understand it, one of the following needs to be done:

  • The template needs to be modified with some smarts to recreate a new interface{} map
  • The value needs to be coerced to an interface{} when the property is set

@sam-mathews
Copy link
Contributor

By the way, there is a workaround to this. If you call GetProperty and specify ManufacturerData instead of using the ManufacturerData() API you will get an interface back that you can pull the data from.

@fazalmajid
Copy link
Author

Yes, that’s what I ended up doing. It’s less elegant, though.

@muka
Copy link
Owner

muka commented Aug 19, 2022

Hi during generation types can be overridden here

Glad to review a PR if you could sort this out. Thank you

deadprogram added a commit to tinygo-org/bluetooth that referenced this issue Sep 26, 2022
Signed-off-by: deadprogram <ron@hybridgroup.com>
deadprogram added a commit to tinygo-org/bluetooth that referenced this issue Sep 26, 2022
Signed-off-by: deadprogram <ron@hybridgroup.com>
deadprogram added a commit to tinygo-org/bluetooth that referenced this issue Sep 29, 2022
Signed-off-by: deadprogram <ron@hybridgroup.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants