Skip to content

Conversation

@anhmolt
Copy link
Contributor

@anhmolt anhmolt commented Oct 28, 2025

Fixes for using Peer Manager with S145 SoftDevice.

@anhmolt anhmolt requested review from a team as code owners October 28, 2025 15:34
@github-actions github-actions bot added changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. doc-required PR must not be merged without tech writer approval. labels Oct 28, 2025
@anhmolt anhmolt requested review from asilz and sondrep October 28, 2025 15:35
@github-actions
Copy link

You can find the documentation preview for this PR here.

#endif /* CONFIG_SOFTDEVICE_CENTRAL */
#endif /* CONFIG_PM_CENTRAL_FUNCTIONALITY */

#ifdef BLE_GAP_ROLE_PERIPH
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we use three different switches within Peer Manager to decide when to compile functionality releated to the BLE role:

  • BLE_GAP_ROLE_* defines coming from SoftDevice
  • SOFTDEVICE_* coming from the SoftDevice Kconfig
  • PM_CENTRAL_FUNCTIONALITY coming in this PR

I think we should stick with one, possibly the SOFTDEVICE_* which can be used everywhere regardless of whether ble_gap.h is included or the Peer Manager is enabled.

Copy link
Contributor

@eivindj-nordic eivindj-nordic Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, using the SOFTDEVICE_* Kconfig will increase a peripheral application using S145 by ~400 bytes, compared to the option of disabling PM_CENTRA_FUNCTIONALITY.
BLE_GAP_ROLE_* is mainly used for peripheral, which will be defined for all our SoftDevice variants.

I am fine with using SOFTDEVICE_* Kconfig for this.

Copy link
Contributor

@lemrey lemrey Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see, using the SOFTDEVICE_* Kconfig will increase a peripheral application using S145 by ~400 bytes, compared to the option of disabling PM_CENTRA_FUNCTIONALITY.

Why would an application that only acts as a peripheral use the S145?
And there shouldn't be any difference in size when using one Kconfig or the other..

BLE_GAP_ROLE_* is mainly used for peripheral, which will be defined for all our SoftDevice variants.

Imo we could either get rid of it entirely or switch on SOFTDEVICE_PERIPHERAL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good discussion. Went back on the introduction of Kconfig PM_CENTRA_FUNCTIONALITY in favor of using SOFTDEVICE_CENTRAL.

Added a commit for updating #ifdef BLE_GAP_ROLE_PERIPH to #if defined(CONFIG_SOFTDEVICE_PERIPHERAL)

@anhmolt anhmolt force-pushed the pm-fix-for-central-role branch from 368f88e to 20b6940 Compare October 29, 2025 17:01
@github-actions github-actions bot removed the doc-required PR must not be merged without tech writer approval. label Oct 29, 2025
const ble_gap_enc_key_t *existing_key = NULL;
bool lesc = false;
struct pm_peer_data_bonding bonding_data = { 0 };
struct pm_peer_data_bonding bonding_data = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use {0} if you want to zero it

bool lesc = false;
struct pm_peer_data_bonding bonding_data = { 0 };
struct pm_peer_data_bonding bonding_data = {};
const uint32_t buf_size = sizeof(struct pm_peer_data_bonding);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a constant if it's passed by reference to pds_peer_data_read()?
Does that function not modify the size?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the signature of pds_peer_data_read:
uint32_t pds_peer_data_read(uint16_t peer_id, enum pm_peer_data_id data_id, struct pm_peer_data *const data, const uint32_t *const buf_len)

so buf_len is constant.

Copy link
Contributor Author

@anhmolt anhmolt Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In nRF5 SDK this would allow setting buf_size to NULL to only have the pointer to memory being copied, but this is not supported with the new file system. So some cleanup is in order here I think.

Fix incorrect pds_peer_data_read() call from the peer manager
central specific function link_secure_central_encryption().

Signed-off-by: Andreas Moltumyr <[email protected]>
Fix use of incorrect logging macro in the security dispatcher
link_secure_central_encryption() function.
It incorrectly used the nRF5 SDK macro.

Signed-off-by: Andreas Moltumyr <[email protected]>
Add missing central functionality for handling
BLE event BLE_GAP_EVT_SEC_REQUEST from the SoftDevice.

Signed-off-by: Andreas Moltumyr <[email protected]>
Switch on Kconfig CONFIG_SOFTDEVICE_PERIPHERAL instead of
SoftDevice define BLE_GAP_ROLE_PERIPH when adding peripheral
specific code in security dispatcher module of the peer manager.

Signed-off-by: Andreas Moltumyr <[email protected]>
@anhmolt anhmolt force-pushed the pm-fix-for-central-role branch from 20b6940 to ae6bf33 Compare October 31, 2025 08:46
@eivindj-nordic eivindj-nordic removed the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Nov 3, 2025
@eivindj-nordic eivindj-nordic merged commit 599b319 into nrfconnect:main Nov 3, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants