This seems to have been broken since
https://github.com/tinygo-org/bluetooth/pull/192, I suspect it's a
problem with the struct calling convention (which most certainly is a
TinyGo CGo bug, but at least this works around the problem).
For details, see: https://github.com/tinygo-org/tinygo/pull/3927
I ran the smoke tests and the binaries are exactly identical to what
they were before, so this change cannot have had an effect on these
smoke tests (which is expected, as this is mostly just changing some
types without changing the machine data type).
This version fixes critical bugs that caused random errors at runtime.
For more details see saltosystems/winrt-go/issues#71 and
saltosystems/winrt-go/issues#72. Diff:
e096b9a...c792451
Make use of a few new features in TinyGo:
* Functions and globals in header files are supported.
* Static functions are supported.
This allows us to remove workarounds specifically used for the lack of
support for static functions.
Previously the list of services and characteristics wasn't sorted, and
because of the way Go maps work they were in fact randomized.
This commit fixes the sorting for services and characteristics, which
both suffered from the same lack of sorting.
This fixes https://github.com/tinygo-org/bluetooth/issues/135.
This is very much like https://github.com/tinygo-org/bluetooth/pull/161,
but for Linux instead. In fact, I've copied the structure of the code
because it works for macOS.
I have tested that the scan order is now as requested. I also verified
that multiple characteristics with the same UUID are now supported, but
support is still a bit buggy: they appear in a random order (due to Go
map iteration order). I will fix this in the next commit.
This fixes two bugs actually:
1. The returned characteristics weren't in the order as given in the
UUID slice.
2. Duplicate characteristics weren't handled correctly.
I tested the first point, and it now works correctly.
I did not fully test the second point, it probably doesn't work
correctly yet because of the Device.characteristics map that is indexed
by UUID. This should be fixed in a separate change.
Without it, these calls are a no-op.
Fixes: https://github.com/tinygo-org/bluetooth/issues/144
In particular, this fixes a problem where IsRandom() would always return
false on Linux. With this fix, it correctly returns whether the address
is a random address.
Remove the Addresser type. It isn't really necessary (the Address type
can change between OSes) and makes it difficult to fix a heap allocation
in interrupts (on the Nordic SoftDevices).
This is a backwards incompatible change, but only programs that use
SetConnectHandler should notice this.
Events are delivered using interrupts. But there was an accidental heap
allocation in the interrupt.
Fix it by using a global instead. This is safe (and doesn't need
volatile accesses), as the global is only ever accessed from that
particular interrupt.