This SoftDevice is used by default on the BBC micro:bit v2 so it's a
good idea to add support here.
Unfortunately this SoftDevice does not support scanning and connecting
to other devices. This means that I unfortunately had to duplicate the
event handler. I managed to refactor most other code to avoid
duplicating much more. (This is when macros would have been useful in
Go...)
This makes sure the SoftDevice start address is configured in only one
place, and thus avoid potential issues when it is changed. It also will
allow setting a different SoftDevice RAM size with a linker flag
starting with LLVM 11 (when expressions are allowed in the MEMORY part
of a linker script).
Not using the right signature led to a compiler crash.
The compiler should probably be fixed in this case (to report an error
instead), but this at least fixes the issue.
Fix up the heart rate example so that it conforms to the Heart Rate Service specification: https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=239866
This will let this example work with external clients like exercise equipment and fitness apps.
Changes:
- Advertise the HR service UUID instead of the HRM characteristic UUID.
- Change HRM characteristic to notify only.
- HRM payload needs to be two bytes:
- 1st byte is flags specifying data type and sensor capabilities: this can be set to zero.
- 2nd byte is HR measurement in bpm.
Tested on Raspberry Pi with nRF Connect app and exercise bike. Peripheral shows up as HR monitor and data is interpreted correctly.
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>