tinygo-org / bluetooth

Cross-platform Bluetooth API for Go and TinyGo. Supports Linux, macOS, Windows, and bare metal using Nordic SoftDevice or HCI
https://tinygo.org
Other
728 stars 137 forks source link

Windows Implementation needs to use ReadValueWithCacheModeAsync #119

Closed KeganHollern closed 1 year ago

KeganHollern commented 2 years ago

Hello,

I am testing on the dev branch with an Aranet4 device.

The my sample code for reading characteristic values works from Linux and OSX, but the windows implementation is not functioning.

I believe this stackoverflow post explains the problem. By using the ReadWithAsync function exposed by winrt-go, you're using the windows cache. My BT device does not send notifications on value change, so this cache is never updated.

the iGattCharacteristic interface exposed by go-winrt contains ReadValueWithCacheModeAsync which allows you to specify the cache mode. I would need to call this method with BluetoothCacheModeUncached to get my device working on windows.

I need a way to specify that the read should not use the cache & should instead read directly from the device.

Please fix before the windows support is added to Release! 🙏

deadprogram commented 2 years ago

@jagobagascon have you seen this?

jagobagascon commented 2 years ago

This is something we encountered on service and characteristic discovery. And fixed it disabling the cache on those methods: https://github.com/tinygo-org/bluetooth/blob/8fae59774538b7110f95849c79cc9bde6c164459/gattc_windows.go#L35 https://github.com/tinygo-org/bluetooth/blob/8fae59774538b7110f95849c79cc9bde6c164459/gattc_windows.go#L152

And somehow we missed the read method. I added a PR to fix this #120

deadprogram commented 1 year ago

This was released in v0.6.0 so now closing. Thanks, everyone!