samples: bluetooth: fixes and cleanup central samples#799
Open
anhmolt wants to merge 5 commits into
Open
Conversation
|
You can find the documentation preview for this PR here. |
c0e87c9 to
4de76da
Compare
eivindj-nordic
approved these changes
May 27, 2026
| case BLE_NUS_CLIENT_EVT_DISCONNECTED: | ||
| LOG_INF("Disconnected"); | ||
| (void)scan_start(); | ||
| LOG_INF("NUS Disconnected"); |
Contributor
There was a problem hiding this comment.
NUS disconnected (lower case in disconnected) to align with others.
| /* GATT queue instance. */ | ||
| BLE_GQ_DEF(ble_gq); | ||
| /* DB discovery module instance. */ | ||
| /* Database discovery instance. */ |
Contributor
There was a problem hiding this comment.
nit: extra whitespace after /*
4de76da to
1905014
Compare
lemrey
reviewed
May 27, 2026
Comment on lines
+599
to
+601
| nrf_err = ble_scan_filter_add(&ble_scan, BLE_SCAN_NAME_FILTER, &filter_data); | ||
| if (nrf_err) { | ||
| LOG_ERR("nrf_ble_scan_filter_add name failed, nrf_error %#x", nrf_err); |
Contributor
There was a problem hiding this comment.
The function being logged does not match the function being called?
Contributor
Author
There was a problem hiding this comment.
Thanks. Fixed in both samples.
1905014 to
d4a0641
Compare
* Update header include list. Remove unused and reorder list. * Update return type of scan_start and delete_bonds functions to void because the returned error values are not used. * Update some comments. * Align names some event handlers and init functions. * Align setup of scan filters with other central samples. * Move initialization of buttons and leds to a static function to align with other central samples. * Use BLE_GAP_WHITELIST_ADDR_MAX_COUNT instead of hardcoding length of arrays used for allow lists to 8. * Remove some duplicate logs. * Remove gatt_init static function "shell" and set conn_params event handler directly from main. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
* Update header include list. Add missing and reorder. * Update return type of scan_start function to void because the returned error values are not used. * Align the placement of const keyword for some parameters and variables. * Align names some event handlers and init functions. * Align setup of scan filters with other central samples. * Removed call to ble_nus_client_handles_assign from BLE_GAP_EVT_CONNECTED evt handling (it is done from BLE_NUS_CLIENT_EVT_DISCOVERY_COMPLETE event handling) and moved a call to scan_start() from BLE_NUS_CLIENT_EVT_DISCONNECTED event handling to BLE_GAP_EVT_DISCONNECTED event handling to align with ble_hrs_central sample. * Removed application specific handling of the BLE_GAP_EVT_PHY_UPDATE_REQUEST event. It is now handled by the conn_params library. * Removed some duplicate logging of ATT MTU and data length updates. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
The address set with the CONFIG_SAMPLE_TARGET_PERIPHERAL_ADDR Kconfig was incorrectly converted to big-endian before being passed to the SoftDevice API (which uses little-endian for the address). In turn, the address printed on a BLE_SCAN_EVT_CONNECTED event was also incorrect (displayed inverted). Fix both these issues so that the Kconfig and address print uses big-endian (standard way to display an address), while the libraries and SoftDevice use addresses in little-endian. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
The Kconfig options for address scan filter was there, but the code to set it up was missing. Add the missing bits. Change print format for logging the address of a connected peer device. Invert the bytes to correctly print the address and add colons. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
Updated to use button 1 to disconnect from target peripheral to align with other central samples. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
d4a0641 to
822f13d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ble_hrs_centralandble_nus_centralmain source files.target_periph_addrhad wrong endianness in theble_hrs_centralsample.ble_nus_centralsample.ble_nus_centralsample to use button 1 to disconnect from peripheral device.