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.
* gattc: use UUID() to allow for bare metal to permit clean use of short UUIDs
Signed-off-by: deadprogram <ron@hybridgroup.com>
* gattc/macos: correct usage of UUID wrapper type alias
Signed-off-by: Ron Evans <ron@hybridgroup.com>
* gattc/sd: correct usage of UUID wrapper type alias
Signed-off-by: Ron Evans <ron@hybridgroup.com>
* gattc/sd, uuid/sd: changes intended to reduce memory allocations for service and characteristic discovery
Signed-off-by: deadprogram <ron@hybridgroup.com>
* gattc/sd: partial improvements to DiscoverServices/DiscoverCharacteristics
Signed-off-by: deadprogram <ron@hybridgroup.com>
* gattc/sd: mostly getting uuid back for services in DiscoverServices
Signed-off-by: deadprogram <ron@hybridgroup.com>
* uuid/sd: correct way to calculate UUID from shortUUID
Signed-off-by: deadprogram <ron@hybridgroup.com>
* gattc/sd: able to discover services and characteristics
Signed-off-by: deadprogram <ron@hybridgroup.com>
* examples: updated discover example that can run with OS or bare metal
Signed-off-by: deadprogram <ron@hybridgroup.com>
* gattc/sd: ensure safe casts for length of returned struct when converting short UUID
Signed-off-by: deadprogram <ron@hybridgroup.com>
I couldn't measure a difference in my setup, apparently my multimeter is
not able to handle the high-to-low current transition when entering
sleep mode. But it _should_ reduce current consumption a little bit.
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.
The over-the-air newline format has been changed to LF always, for
simplicity. We might have used CR instead but LF works, and is the
newline format normally used on Unix (in files and stdio, except for raw
terminals).
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.
The DefaultAdapter was a regular value, not a pointer-to-struct. This
meant that simply copying bluetooth.DefaultAdapter caused a copy of the
object itself (instead of a copy of the reference, as intended). This
meant that write events did not arrive.