Skip to content

Conversation

MirkoCovizzi
Copy link
Contributor

@MirkoCovizzi MirkoCovizzi commented Sep 19, 2025

Refactor Peer Manager Kconfig options.

@MirkoCovizzi MirkoCovizzi self-assigned this Sep 19, 2025
@MirkoCovizzi MirkoCovizzi requested review from a team as code owners September 19, 2025 12:20
@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Sep 19, 2025
@MirkoCovizzi MirkoCovizzi changed the title lib: peer_manager: rename PM_SERVICE_CHANGED_ENABLED lib: peer_manager: refactor Kconfig options Sep 19, 2025
Copy link

You can find the documentation preview for this PR here.

@MirkoCovizzi MirkoCovizzi marked this pull request as draft September 19, 2025 12:21
@MirkoCovizzi MirkoCovizzi added the DNM Do not merge label Sep 19, 2025
Comment on lines 45 to 46
default y if NRF_SDH_BLE_SERVICE_CHANGED
default n
Copy link
Contributor

Choose a reason for hiding this comment

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

This feature depends on the service changed characteristic being enabled in the SoftDevice, which happens automatically when NRF_SDH_BLE_SERVICE_CHANGED is set.

So this should rather be:
depends on NRF_SDH_BLE_SERVICE_CHANGED
default y

Otherwise this could still be enabled when the NRF_SDH_BLE_SERVICE_CHANGED is not enabled, and that would be an error.

@MirkoCovizzi MirkoCovizzi added this to the v1.0.0 milestone Sep 29, 2025
@MirkoCovizzi MirkoCovizzi force-pushed the peer-manager-k branch 3 times, most recently from 2e92b15 to 24b546d Compare September 30, 2025 08:24
@github-actions github-actions bot added the doc-required PR must not be merged without tech writer approval. label Sep 30, 2025
@MirkoCovizzi MirkoCovizzi marked this pull request as ready for review October 2, 2025 08:16
@MirkoCovizzi MirkoCovizzi requested a review from a team as a code owner October 2, 2025 08:16
@MirkoCovizzi MirkoCovizzi removed the DNM Do not merge label Oct 2, 2025
@MirkoCovizzi MirkoCovizzi requested a review from lemrey October 2, 2025 08:17
Copy link
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

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

Seems commits might need squashing?


config PM_SERVICE_CHANGED_ENABLED
config PM_SERVICE_CHANGED
bool "Enable/disable the service changed management for GATT server in Peer Manager."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool "Enable/disable the service changed management for GATT server in Peer Manager."
bool "Service changed management for GATT server in Peer Manager."

Copy link
Contributor Author

@MirkoCovizzi MirkoCovizzi Oct 3, 2025

Choose a reason for hiding this comment

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

Please have another look, this was addressed in a separate commit.

}

#if CONFIG_PM_SERVICE_CHANGED_ENABLED
#if CONFIG_PM_SERVICE_CHANGED
Copy link
Contributor

Choose a reason for hiding this comment

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

these are defines, change them all to #ifdef or #if defined(CONFIG_...

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 not fixed

* @retval NRF_ERROR_INTERNAL If an internal error occurred.
* @retval NRF_ERROR_NOT_SUPPORTED If peer rank functionality has been disabled via the @ref
* PM_PEER_RANKS_ENABLED configuration option.
* PM_PEER_RANKS configuration option.
Copy link
Contributor

Choose a reason for hiding this comment

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

@ before will link to it

Copy link
Contributor Author

@MirkoCovizzi MirkoCovizzi Oct 3, 2025

Choose a reason for hiding this comment

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

Please have another look, this was addressed in a separate commit.


config PM_PEER_RANKS_ENABLED
config PM_PEER_RANKS
bool "Enable/disable the peer rank management in Peer Manager."
Copy link
Contributor

Choose a reason for hiding this comment

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

fix above issues in whole PR, never start a Kconfig prompt with enable

Copy link
Contributor Author

@MirkoCovizzi MirkoCovizzi Oct 3, 2025

Choose a reason for hiding this comment

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

Please have another look, this was addressed in a separate commit.

config PM_LESC_ENABLED
config PM_LESC
bool "Enable/disable LESC support in Peer Manager."
default n
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
default n

@MirkoCovizzi
Copy link
Contributor Author

Seems commits might need squashing?

I don't see why they should be squashed. It's very clear what each commit does and how they separate each atomic change.

}

#if CONFIG_PM_SERVICE_CHANGED_ENABLED
#if CONFIG_PM_SERVICE_CHANGED
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 not fixed

Copy link
Contributor

@anhmolt anhmolt left a comment

Choose a reason for hiding this comment

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

Could you add a commit where you change CONFIG_REQ to PM_EVT_CONN_SEC_CONFIG_REQ here

* @brief Function for sending a CONFIG_REQ event.

The CONFIG_ namespace is for Kconfigs.

@MirkoCovizzi MirkoCovizzi force-pushed the peer-manager-k branch 2 times, most recently from a3d73d2 to 228427e Compare October 3, 2025 08:48
extern void pm_pdb_evt_handler(pm_evt_t *p_event);
extern void sm_pdb_evt_handler(pm_evt_t *p_event);
#if !defined(CONFIG_PM_SERVICE_CHANGED_ENABLED) || (CONFIG_PM_SERVICE_CHANGED_ENABLED == 1)
#if !defined(CONFIG_PM_SERVICE_CHANGED) || (CONFIG_PM_SERVICE_CHANGED == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not make sense with the (new) Kconfig system. This logic probably took care of the "default" behavior in the nRF5 SDK, when the config was not defined.

Suggested change
#if !defined(CONFIG_PM_SERVICE_CHANGED) || (CONFIG_PM_SERVICE_CHANGED == 1)
#if defined(CONFIG_PM_SERVICE_CHANGED)

Here and others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree

@eivindj-nordic
Copy link
Contributor

eivindj-nordic commented Oct 6, 2025

I don't see why they should be squashed. It's very clear what each commit does and how they separate each atomic change.

I see your point, though I think many of the changes are too small to deserve its own commit when the other commits are quite similar. For issues outside of these commits it also helps with bisectability to squash the commits, as it could remove the need for a couple of steps in the bisect process.


* Updated:

* The ``CONFIG_PM_SERVICE_CHANGED_ENABLED`` Kconfig option to :kconfig:option:`CONFIG_PM_SERVICE_CHANGED`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and others

Suggested change
* The ``CONFIG_PM_SERVICE_CHANGED_ENABLED`` Kconfig option to :kconfig:option:`CONFIG_PM_SERVICE_CHANGED`.
* The ``CONFIG_PM_SERVICE_CHANGED_ENABLED`` Kconfig option is renamed to :kconfig:option:`CONFIG_PM_SERVICE_CHANGED`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

*
* @note This function is deprecated. LESC keys are now handled internally if @ref PM_LESC_ENABLED
* is true. If @ref PM_LESC_ENABLED is false, this function works as before.
* @note This function is deprecated. LESC keys are now handled internally if the @c CONFIG_PM_LESC
Copy link
Contributor

Choose a reason for hiding this comment

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

Use @deprecated?

Suggested change
* @note This function is deprecated. LESC keys are now handled internally if the @c CONFIG_PM_LESC
* @deprecated LESC keys are now handled internally if the @c CONFIG_PM_LESC

Comment on lines +245 to +246
* Kconfig option is enabled. If the @c CONFIG_PM_LESC Kconfig option is disabled, this
* function works as before.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by this last sentence?

 If the @c CONFIG_PM_LESC Kconfig option is disabled, this function works as before.

If this is still meant to be used when CONFIG_PM_LESC Kconfig option is disabled, this is not deprecated.

Copy link
Contributor Author

@MirkoCovizzi MirkoCovizzi Oct 6, 2025

Choose a reason for hiding this comment

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

Not sure, this is from the original Doxygen. I merely changed the Kconfig reference.

@MirkoCovizzi MirkoCovizzi force-pushed the peer-manager-k branch 2 times, most recently from 89466e2 to 3eb8aea Compare October 6, 2025 11:35
@MirkoCovizzi
Copy link
Contributor Author

I don't see why they should be squashed. It's very clear what each commit does and how they separate each atomic change.

I see your point, though I think many of the changes are too small to deserve its own commit when the other commits are quite similar. For issues outside of these commits it also helps with bisectability to squash the commits, as it could remove the need for a couple of steps in the bisect process.

I squashed the mechanical commits that can make sense to squash.

@MirkoCovizzi MirkoCovizzi force-pushed the peer-manager-k branch 2 times, most recently from 5c34624 to 5272011 Compare October 6, 2025 12:17
* Renames the `PM_SERVICE_CHANGED_ENABLED`,
`PM_PEER_RANKS_ENABLED`, `PM_LESC_ENABLED`,
and `PM_RA_PROTECTION_ENABLED` kconfig options
to align with Zephyr's coding style.

* Improves prompts and descriptions of Kconfig options.

* Moves secondary `PM_RA_PROTECTION` Kconfigs inside conditional
block.

* Removes explicit `default n`.

* Fixes doxygen sections related to Kconfig options.

* Refactors the Peer Manager to use the `#if defined` (or
`#if !defined`) preprocessor pattern where appropriate.

Signed-off-by: Mirko Covizzi <[email protected]>
Conditionally compile Auth Status Tracker.

Signed-off-by: Mirko Covizzi <[email protected]>
If not using a GATT server, or using a server without a service changed
characteristic, this Kconfig option should be disabled to save code space.
Refactors this Kconfig option in order to represent this relationship
accordingly.

Signed-off-by: Mirko Covizzi <[email protected]>
* Fixes a typo.

* Removes extra newlines.

Signed-off-by: Mirko Covizzi <[email protected]>
@eivindj-nordic eivindj-nordic merged commit 6879627 into nrfconnect:main Oct 7, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants