-
Notifications
You must be signed in to change notification settings - Fork 30
Scan, DB discovery library and hrs c sample. #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
You can find the documentation preview for this PR here. |
27651ce to
ccc67f8
Compare
f1b6f15 to
345c14e
Compare
def7c1f to
ff5b64e
Compare
| Bluetooth: Database Discovery library | ||
| ############################## |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Bluetooth: Database Discovery library | |
| ############################## | |
| Bluetooth: Database discovery library | |
| ##################################### |
| :local: | ||
| :depth: 2 | ||
|
|
||
| This module contains the APIs and types exposed by the Database Discovery module. These APIs and types can be used by the application to perform discovery of a service and its characteristics at the peer server. This module can also be used to discover the desired services in multiple remote devices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This module contains the APIs and types exposed by the Database Discovery module. These APIs and types can be used by the application to perform discovery of a service and its characteristics at the peer server. This module can also be used to discover the desired services in multiple remote devices. | |
| This module contains the APIs and types exposed by the Database discovery module. | |
| These APIs and types can be used by the application to discover a service and its characteristics at the peer server. | |
| This module can also be used to discover the desired services in multiple remote devices. |
| Configuration | ||
| ************* | ||
|
|
||
| The library is enabled and configured using the Kconfig system: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The library is enabled and configured using the Kconfig system: | |
| To enable and configure the library use the following Kconfig options: |
| ============== | ||
|
|
||
| The library is initialized by calling the :c:func:`ble_db_discovery_init` function. | ||
| See the :c:struct:`ble_db_discovery_config` struct for configuration details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| See the :c:struct:`ble_db_discovery_config` struct for configuration details. | |
| See the :c:struct:`ble_db_discovery_config` structure for configuration details. |
| After initialization, use :c:func:`ble_db_discovery_service_register` to register a callback that triggers when a service is discovered with a specific UUID. | ||
| To start discovering from a peer, you must use :c:func:`ble_db_discovery_start` with the connection handle of the peer device. | ||
| For example, you can call :c:func:`ble_db_discovery_start` when the ble event :c:enum:`BLE_GAP_EVT_CONNECTED` is triggered and use the connection handle from the event as the second argument in :c:func:`ble_db_discovery_start`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| After initialization, use :c:func:`ble_db_discovery_service_register` to register a callback that triggers when a service is discovered with a specific UUID. | |
| To start discovering from a peer, you must use :c:func:`ble_db_discovery_start` with the connection handle of the peer device. | |
| For example, you can call :c:func:`ble_db_discovery_start` when the ble event :c:enum:`BLE_GAP_EVT_CONNECTED` is triggered and use the connection handle from the event as the second argument in :c:func:`ble_db_discovery_start`. | |
| After initialization, use the :c:func:`ble_db_discovery_service_register` function to register a callback that triggers when a service is discovered with a specific UUID. | |
| To start discovering from a peer, use the :c:func:`ble_db_discovery_start` function with the connection handle of the peer device. | |
| For example, you can call the :c:func:`ble_db_discovery_start` function when the :c:enum:`BLE_GAP_EVT_CONNECTED` event is triggered and use the connection handle from the event as the second argument in the :c:func:`ble_db_discovery_start` function. |
| If the device is not advertising, you might need to use the :guilabel:`Reset Board` option in |VSC|. | ||
| #. :guilabel:`Connect` to your device. | ||
| The terminal output in |VSC| indicates ``Peer connected``. | ||
| #. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the Play button. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the Play button. | |
| #. Observe that the services are shown in the connected device and you can start receiving values for the Heart Rate and the Battery Service when you click the :guilabel:`Play` button. |
| #. In nRF Connect for Desktop, scan for advertising devices. | ||
| Your device should be advertising as ``nRF_BM_HRS``. | ||
| If the device is not advertising, you might need to use the :guilabel:`Reset Board` option in |VSC|. | ||
| #. :guilabel:`Connect` to your device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #. :guilabel:`Connect` to your device. | |
| #. Click :guilabel:`Connect` to connect your device. |
| #. :guilabel:`Connect` to your device. | ||
| The terminal output in |VSC| indicates ``Peer connected``. | ||
| #. Observe that the services are shown in the connected device and that you can start receiving values for the Heart Rate and the Battery Service by clicking the Play button. | ||
| Heart Rate notifications are received every second, and Battery Level notifications are received every two seconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Heart Rate notifications are received every second, and Battery Level notifications are received every two seconds. | |
| Heart Rate notifications are received every second, and Battery Level notifications every two seconds. |
| Otherwise, the :c:macro:`NRF_BLE_SCAN_EVT_NOT_FOUND` event is generated. | ||
|
|
||
| You can enable filters by calling the :c:func:`ble_scan_filters_enable` function after initialization. | ||
| You can activate filters for one filter type, or for a combination of several filter types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| You can activate filters for one filter type, or for a combination of several filter types. | |
| You can activate filters for one filter type, or for a combination of several filter types. | |
| Example code: |
| ======================= | ||
|
|
||
| The advanced initialization provides a larger configuration set for the library. | ||
| It is required when using scan filters or the whitelist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| It is required when using scan filters or the whitelist. | |
| It is required when using scan filters or the whitelist. | |
| Example code: |
|
|
||
| PREDEFINED = __DOXYGEN__ \ | ||
| CONFIG_BLE_QWR_MAX_ATTR=1 \ | ||
| CONFIG_BLE_SCAN_FILTER=1 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? We don't do this in zephyr and we don't do this in NCS, so why is this required in BM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required until we have #401 I think. After that doc generation will be the same as in NCS.
| * :kconfig:option:`CONFIG_BLE_SCAN_INTERVAL` - Determines the scan interval in units of 0.625 ms. | ||
| * :kconfig:option:`CONFIG_BLE_SCAN_DURATION` - Duration of a scanning session in units of 10 ms, if set to 0, the scanning continues until it is explicitly disabled. | ||
| * :kconfig:option:`CONFIG_BLE_SCAN_WINDOW` - Determines the scanning window in units of 0.625 ms. | ||
| * :kconfig:option:`CONFIG_BLE_SCAN_SLAVE_LATENCY` - Determines the slave latency in counts of connection events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
peripheral latency, as per BT SIG, update Kconfigs and names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hermabe The SoftDevice uses slave latency, I assume that is for legacy reasons (avoid breaking API)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the SoftDevice still refers to pre-5.3 naming in many places. We decided early on to not rename everything to not break the API.
You can call the Kconfig whatever you want. I am more concerned with why these are kconfigs at all, shouldnt the connection parameters be runtime configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were part of the sdk_config.h in nRF5. The ble_gap_scan_params_t provided are still configurable through ble_scan_params_set().
|
|
||
| .. note:: | ||
|
|
||
| When using the whitelist, filters are inactive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as other PR, allow list
1427e26 to
28eb23a
Compare
nordicjm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"HRS_C" Kconfig name is awful and non descriptive, use full word "HRS_CENTRAL"
| .filter_policy = BLE_GAP_SCAN_FP_WHITELIST, | ||
| .timeout = SCAN_DURATION_WHITELIST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these need updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top one is from SoftDevice, cannot be changed.
lib/bluetooth/ble_scan/Kconfig
Outdated
| Determines the scanning window in units of 0.625 milliseconds. | ||
|
|
||
| config BLE_SCAN_PERIPHERAL_LATENCY | ||
| int "Scan slave latency" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs update
| range 1 6 | ||
| default 6 | ||
| help | ||
| The maximum number of database characteristics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong indent for all these
| depends on BLE_GATT_QUEUE | ||
| select EXPERIMENTAL | ||
| help | ||
| database discovery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is going to be the help text, might as well remove it. Either that or expand it here properly, with capital first letter
| help | ||
| The total number of services that can be discovered by this module. | ||
|
|
||
| config SRV_DISC_START_HANDLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing prefix
| SVCALL_AS_NORMAL_FUNCTION=1 | ||
| NRF54L15_XXAA) | ||
|
|
||
| target_compile_definitions( app PRIVATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the old way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, updated locally.
samples/bluetooth/ble_hrs_c/Kconfig
Outdated
|
|
||
| menu "BLE HRS Central sample" | ||
|
|
||
| config APP_USE_TARGET_PERIPH_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*PERIPHERAL, these Kconfig names are not long, they can use full words
samples/bluetooth/ble_hrs_c/Kconfig
Outdated
| endif # APP_USE_TARGET_PERIPH_ADDR | ||
|
|
||
| module=APP_BLE_HRS_C_SAMPLE | ||
| module-dep=LOG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| module-dep=LOG |
samples/bluetooth/ble_hrs_c/Kconfig
Outdated
| module-str=BLE Heart Rate Central Service Sample | ||
| source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config" | ||
|
|
||
| endmenu # "BLE HRS sample" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mismatch
samples/bluetooth/ble_hrs_c/Kconfig
Outdated
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| menu "BLE HRS Central sample" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*central
28eb23a to
5c0c3ca
Compare
| .active = 0x01, | ||
| .interval = NRF_BLE_SCAN_INTERVAL, | ||
| .window = NRF_BLE_SCAN_WINDOW, | ||
| .filter_policy = BLE_GAP_SCAN_FP_WHITELIST, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BLE_GAP_SCAN_FP_WHITELIST is still not updated, this name is not acceptable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cannot be updated here. This is part of the SoftDevice deliverables.
| #define BLE_GAP_SCAN_FP_WHITELIST 0x01 /**< Accept advertising packets from devices in the whitelist except directed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #514 (comment)
| Configuration | ||
| ************* | ||
|
|
||
| To enable and configure the library use the following Kconfig options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| To enable and configure the library use the following Kconfig options: | |
| To enable and configure the library, use the following Kconfig options: |
Sorry, my bad forgetting the comma.
|
|
||
| The allow list (formerly known as whitelist) stores information about all the device connections and bonding. | ||
| If you enable the allow list, the application receives advertising packets only from the devices that are on the allow list. | ||
| An advertising package from a allow listed device generates an :c:macro:`BLE_SCAN_EVT_ALLOW_LIST_ADV_REPORT` event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| An advertising package from a allow listed device generates an :c:macro:`BLE_SCAN_EVT_ALLOW_LIST_ADV_REPORT` event. | |
| An advertising package from an allow-listed device generates an :c:macro:`BLE_SCAN_EVT_ALLOW_LIST_ADV_REPORT` event. |
| * Multifilter - At least one filter from each filter type you set must be matched to generate an event. | ||
| For UUID filters, all specified UUIDs must match in this mode. | ||
| To enabled multifilter, set the :c:macro:`match_all` argument to true when calling the :c:func:`ble_scan_filters_enable` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Multifilter - At least one filter from each filter type you set must be matched to generate an event. | |
| For UUID filters, all specified UUIDs must match in this mode. | |
| To enabled multifilter, set the :c:macro:`match_all` argument to true when calling the :c:func:`ble_scan_filters_enable` function. | |
| * Multifilter - At least one filter from each filter type you set must be matched to generate an event. | |
| For UUID filters, all specified UUIDs must match in this mode. | |
| To enabled multifilter, set the :c:macro:`match_all` argument to true when calling the :c:func:`ble_scan_filters_enable` function. |
| uint32_t ble_hrs_c_init(struct ble_hrs_c *ble_hrs_c, struct ble_hrs_c_config *ble_hrs_c_init); | ||
|
|
||
| /** | ||
| * @brief Handle BLE events from the SoftDevice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @brief Handle BLE events from the SoftDevice. | |
| * @brief Handle Bluetooth LE events from the SoftDevice. |
| * @details This function handles the BLE events received from the SoftDevice. If a BLE | ||
| * event is relevant to the Heart Rate Client module, the function uses the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @details This function handles the BLE events received from the SoftDevice. If a BLE | |
| * event is relevant to the Heart Rate Client module, the function uses the | |
| * @details This function handles the Bluetooth LE events received from the SoftDevice. If an | |
| * event is relevant to the Heart Rate Client module, the function uses the |
| * event's data to update interval variables and, if necessary, send events to the | ||
| * application. | ||
| * | ||
| * @param[in] ble_evt Pointer to the BLE event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * @param[in] ble_evt Pointer to the BLE event. | |
| * @param[in] ble_evt Pointer to the Bluetooth LE event. |
lib/bluetooth/ble_scan/Kconfig
Outdated
| # | ||
|
|
||
| menuconfig BLE_SCAN | ||
| bool "BLE Scan [EXPERIMENTAL]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| bool "BLE Scan [EXPERIMENTAL]" | |
| bool "Bluetooth LE Scan [EXPERIMENTAL]" |
| # | ||
|
|
||
| menuconfig BLE_HRS_CENTRAL | ||
| bool "BLE Heart rate service central [EXPERIMENTAL]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| bool "BLE Heart rate service central [EXPERIMENTAL]" | |
| bool "Bluetooth LE Heart rate service central [EXPERIMENTAL]" |
c153d9c to
9acf427
Compare
Agreed, and I think we should use |
Ok, I'll make the changes. |
5e6dae8 to
fd67120
Compare
| * has been reached. | ||
| */ | ||
| uint32_t ble_db_discovery_service_register(struct ble_db_discovery *db_discovery, | ||
| const ble_uuid_t *const uuid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. alignment is off
| @@ -0,0 +1,242 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit title is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated locally.
| /** | ||
| * @brief Heart Rate Measurement received from the peer. | ||
| */ | ||
| struct ble_hrm { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this conflict if you include the peripheral and central files in a .c file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only defined in ble_hrs_central.h.
ble_hrs.h defines heart rate service (hrs), not heart rate measurement (hrm).
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(ble_hrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| project(ble_hrs) | |
| project(ble_hrs_central) |
Add scan library. Co-authored-by: Sondre Pettersen <[email protected]> Co-authored-by: Asil Zogby <[email protected]> Signed-off-by: Eivind Jølsgard <[email protected]>
Add db_discovery library. Co-authored-by: Sondre Pettersen <[email protected]> Co-authored-by: Asil Zogby <[email protected]> Signed-off-by: Eivind Jølsgard <[email protected]>
bfc6b15 to
909a78f
Compare
Add BLE heart rate service central and sample. Co-authored-by: Asil Zogby <[email protected]> Signed-off-by: Sondre Pettersen <[email protected]> Signed-off-by: Eivind Jølsgard <[email protected]>
909a78f to
8fa7345
Compare
No description provided.