-
Notifications
You must be signed in to change notification settings - Fork 33
Adapter: use heap memory to cache discovered devices. #396
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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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_twithstruct bt_br_discovery_paramand wire it throughbt_sal_start_discoveryandstart_discovery. - Introduce a global heap-allocated
g_discovery_resultsbuffer sized byBT_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.
27ba798 to
30ad8b2
Compare
30ad8b2 to
04770ce
Compare
| if (err != 0 && err != -ENODEV && err != -EALREADY) | ||
| BT_LOGE("failed to stop discovery, err = %d", err); | ||
|
|
||
| free(g_discovery_results); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
huangyulong3
left a comment
There was a problem hiding this 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>
No description provided.