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.
The memory from the advertisement payload must be kept alive until the
advertisement is stopped. Therefore, it is not allowed to use a local
variable for it. Instead, it is now part of the defaultAdvertisement
global which of course is alive as long as the program runs.
Unlike what I previously thought, BlueZ does expose it. Unfortunately it
doesn't seem to respect it: the bit is not included in D-Bus paths.
Windows also supports the bit, which I hope to fix in a future commit.
Like BlueZ, it appears to ignore it when connecting to a device.
Use a new Duration type, which is used throughout the BLE stack for
durations. The resolutions are sometimes different (connection
parameters have half the resolution) but overall it should improve the
ease of use of this type.
This commit also provides a default advertisement interval that is
recommended by Apple (which I think is as good as any recommendation).
This might help to speed up discovery by Apple (and Android?) phones.
I have intentionally chosen to implement HasServiceUUID() and not
ServiceUUIDs() because returning a slice of UUIDs will likely cause a
heap allocation. And perhaps the most common use may be checking whether
a packet has a particular UUID, so no list is necessary. Getting the
full list can of course be implemented in the future, if needed.
This is necessary when connecting to a device when using the SoftDevice.
The information is not set on Linux and Windows and is ignored on those
platform when connecting.
There used to be GAP events (connect/disconnect). The main purpose for
these events was to allow applications to re-start advertisement when a
connection was lost - on nrf. Unfortunately things work differently on
Linux, which already has this behavior and for which I haven't yet
implemented these events. Therefore I have removed these events and
instead added code to automatically restart advertisement on connection
loss.
Supporting multiple (incoming) connections as a peripheral would be
useful, but is not currently supported.
This changes the previous raw advertisement packets to structured
advertisement configuration. That means you can set the local name not
with a raw byte array but with a normal string.
While this departs a bit from the original low-level interface as is
often used on microcontroller BLE stacks, it is certainly easier to use
and better matches higher level APIs that are commonly provided by
general-purpose operating systems. If there is a need for raw BLE
packets (for baremetal systems only), this can easily be added in the
future.