Skip to content

Bluetooth: Host: Add advertising state to bt_le_ext_adv_info #90185

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented May 19, 2025

The bt_le_ext_adv_info struct has been extended to also contain the advertising and periodic advertising states.

Additionally, the function verifies the input to avoid NULL pointer access, and more importantly does not return 0 with addr set to a valid that is not
used for advertising.

@Thalley
Copy link
Collaborator Author

Thalley commented May 19, 2025

There will be a use of these new fields in #85642:

  1. We need to start advertising if not already (or reject a function call if it's not, TBD)
  2. We need to reject a function call if periodic advertising is not configured

@Thalley Thalley marked this pull request as ready for review May 19, 2025 23:40
@github-actions github-actions bot added area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth labels May 19, 2025
@Thalley
Copy link
Collaborator Author

Thalley commented May 21, 2025

Did also consider to also add the options as field to the info, but I don't have a use case for it at this moment

@Thalley Thalley requested a review from Copilot May 25, 2025 14:43
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds tracking and reporting of extended and periodic advertising states to Bluetooth LE advertising info and shell output, with input validation to prevent NULL dereferences.

  • Extend bt_le_ext_adv_info with ext_adv_state and per_adv_state enums
  • Validate arguments and populate new state fields in bt_le_ext_adv_get_info
  • Print the new states in the shell command cmd_adv_info

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
subsys/bluetooth/host/shell/bt.c Print extended/periodic advertising states in shell output
subsys/bluetooth/host/adv.c Validate inputs and set advertising/periodic state in info struct
include/zephyr/bluetooth/bluetooth.h Add enums for advertising states and update struct documentation
Comments suppressed due to low confidence (1)

subsys/bluetooth/host/shell/bt.c:2573

  • [nitpick] Rename the label 'Per Adv state' to 'Periodic Adv state' to more clearly reflect its meaning.
shell_print(sh, "Per Adv state: %d", info.per_adv_state);

/** The advertising set is started */
BT_LE_EXT_ADV_STATE_STARTED,

/** Ther advertising set is temporarily paused */
Copy link
Preview

Copilot AI May 25, 2025

Choose a reason for hiding this comment

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

Fix typo in comment: change 'Ther' to 'The'.

Suggested change
/** Ther advertising set is temporarily paused */
/** The advertising set is temporarily paused */

Copilot uses AI. Check for mistakes.

@Thalley Thalley requested a review from Copilot May 25, 2025 14:55
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the advertising information structure to include extended and periodic advertising states, and improves input validation to prevent NULL pointer accesses.

  • Adds printing of advertising and periodic advertising states in the shell command output.
  • Introduces new pointer validations and state assignments in bt_le_ext_adv_get_info.
  • Updates header file with new state enums and refined documentation.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
subsys/bluetooth/host/shell/bt.c Prints new extended and periodic advertising state information.
subsys/bluetooth/host/adv.c Adds NULL checks, state assignments, and initializes info struct.
include/zephyr/bluetooth/bluetooth.h Introduces new advertising state enums and updates documentation.

The bt_le_ext_adv_info struct has been extended to also
contain the advertising and periodic advertising states.

Additionally, the function verifies the input to avoid
NULL pointer access, and the addr field is more
properly documented.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
@Thalley Thalley requested a review from Copilot May 25, 2025 15:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds explicit tracking and display of extended and periodic advertising states in the Bluetooth LE advertising APIs and shell.

  • Extend bt_le_ext_adv_info with ext_adv_state and per_adv_state enums.
  • Add input validation and state population in bt_le_ext_adv_get_info.
  • Update shell command to print the new advertising state fields.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
subsys/bluetooth/host/shell/bt.c Print extended and periodic advertising states and conditionally show address only when advertising is started.
subsys/bluetooth/host/adv.c Validate adv and info pointers, memset info, and set up new state fields based on flags.
include/zephyr/bluetooth/bluetooth.h Define enums for extended and periodic advertising states; update struct and function return documentation.
Comments suppressed due to low confidence (1)

subsys/bluetooth/host/shell/bt.c:2573

  • [nitpick] The abbreviation "Per Adv state" may not be immediately clear; consider using "Periodic Adv state" for consistency and clarity.
shell_print(sh, "Per Adv state: %d", info.per_adv_state);

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants