Skip to content

Conversation

@gzh-terry
Copy link
Contributor

No description provided.

Copy link

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 refactors BR/EDR discovery in the Zephyr SAL to use heap-allocated storage for discovery results and to pass Zephyr’s bt_br_discovery_param directly, with additional logging and state checks.

Changes:

  • Replace the ad‑hoc discovery timeout/limited struct in sal_adapter_args_t with struct bt_br_discovery_param and wire it through bt_sal_start_discovery and start_discovery.
  • Introduce a global heap-allocated g_discovery_results buffer sized by BT_DISCOVERY_DEVICE_MAX, with allocation on discovery start and cleanup on completion/stop.
  • Add discovery-related logging and guard redundant start/stop calls by checking g_discovery_results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gzh-terry gzh-terry force-pushed the memory branch 2 times, most recently from 27ba798 to 30ad8b2 Compare January 26, 2026 03:38
@gzh-terry gzh-terry force-pushed the memory branch 2 times, most recently from 30ad8b2 to 04770ce Compare January 27, 2026 02:16
chengkai15
chengkai15 previously approved these changes Jan 27, 2026
if (err != 0 && err != -ENODEV && err != -EALREADY)
BT_LOGE("failed to stop discovery, err = %d", err);

free(g_discovery_results);
Copy link
Contributor

Choose a reason for hiding this comment

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

note: g_discovery_results maybe reused by zblue stack

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost safe, if zephyr codes are not changed in the future.

There is a hdev->discovery_results = NULL; within bt_br_discovery_stop_mc, regardless of success or failure.

Copy link

@huangyulong3 huangyulong3 left a comment

Choose a reason for hiding this comment

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

LGTM.

Bug: v/84859

Root cause: The inquiry command currently takes static memory, consuming 7620 bytes even when not in use.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
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.

3 participants