Skip to content

Conversation

@huangyulong3
Copy link

Memory Optimization: Change the bluetooth bt_tool log module to const for reduce the ram size.

bug:v/84967

Rootcause: To reduce RAM resource consumption, the g_log_async_tables,
in the bt_tools log module must be marked with the const modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

…k to const for reduce the ram size.

bug: v/84934

Rootcause: To reduce RAM resource consumption, the `adv_callback`
in the ble impl module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
…re_gattc_cbs to const for reduce the ram size.

bug: v/84935

Rootcause: To reduce RAM resource consumption, the `s_feature_gattc_cbs`
in the gatt feature module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
…v_callback to const for reduce the ram size.

bug: v/84941

Rootcause: To reduce RAM resource consumption, the `g_advertiser_socket_cb`
in the socket advertiser module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…back to const for reduce the ram size.

bug: v/84944

Rootcause: To reduce RAM resource consumption, the `g_advertiser_socket_cb`
in the socket scan module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…ket_cb to const for reduce the ram size.

bug: v/84945

Rootcause: To reduce RAM resource consumption, the `g_spp_socket_cb`
in the socket spp module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…o const for reduce the ram size.

bug:v/84946

Rootcause: To reduce RAM resource consumption, the `deviceInterface`
in the hid device service module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
… for reduce the ram size.

bug:v/84947

Rootcause: To reduce RAM resource consumption, the `sppInterface`
in the spp service module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…o const for reduce the ram size.

bug:v/84950

Rootcause: To reduce RAM resource consumption, the `stream_ops`
in the sal a2dp interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…e to const for reduce the ram size.

bug:v/84951

Rootcause: To reduce RAM resource consumption, the `g_conn_cbs`, `g_setting_cbs`,
`g_conn_auth_info_cbs`and `g_br_discovery_cb`,
in the sal adapter interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…dule to const for reduce the ram size.

bug:v/84952

Rootcause: To reduce RAM resource consumption, the `g_conn_auth_info_cbs`, `g_conn_cbs`,
and `g_setting_cbs` in the sal adapter interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
…to const for reduce the ram size.

bug:v/84953

Rootcause: To reduce RAM resource consumption, the `avrcp_tg_cbks`,
in the sal avrcp interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
… to const for reduce the ram size.

bug:v/84954

Rootcause: To reduce RAM resource consumption, the `g_hfp_ag_cb`,
in the sal hfp ag interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
…e to const for reduce the ram size.

bug:v/84956

Rootcause: To reduce RAM resource consumption, the `hf_callbacks`,
in the sal hfp hf interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.
…dule to const for reduce the ram size.

bug:v/84957

Rootcause: To reduce RAM resource consumption, the `hid_attrs_template` and `hid_callback`,
in the sal hid device interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.
…dule to const for reduce the ram size.

bug:v/84958

Rootcause: To reduce RAM resource consumption, the `spp_attrs_template` and `g_rfcomm_ops`,
in the sal spp interface module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
…to const for reduce the ram size.

bug:v/84959

Rootcause: To reduce RAM resource consumption, the `g_a2dp_tables`,
in the bt_tools a2dp source module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
… for reduce the ram size.

bug:v/84960

Rootcause: To reduce RAM resource consumption, the `adv_options`,a dv_stop_options,
`g_adv_tables` and `adv_callback` in the bt_tools adv module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
… const for reduce the ram size.

bug:v/84961

Rootcause: To reduce RAM resource consumption, the `adv_options`, `adv_stop_options`,
`g_adv_async_tables` and `adv_callback` in the bt_tools async adv module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
… const for reduce the ram size.

bug:v/84961

Rootcause: To reduce RAM resource consumption, the `le_conn_options`, `g_set_cmd_tables`,
`g_get_cmd_tables` and `g_pair_cmd_tables` in the bt_tools async gap module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com
…odule to const for reduce the ram size.

bug:v/84966

Rootcause: To reduce RAM resource consumption, the `g_gattc_async_tables`, `gattc_cbs`,
in the bt_tools async gatt client module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
… for reduce the ram size.

bug:v/84967

Rootcause: To reduce RAM resource consumption, the `g_log_async_tables`,
in the bt_tools log module must be marked with the `const` modifier.
This ensures it is compiled and linked into Flash memory instead of RAM.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
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 implements a memory optimization by marking static data structures as const to ensure they are compiled and linked into Flash memory instead of RAM. The changes apply this optimization to command tables, option structures, and callback structures across multiple Bluetooth tool and service modules.

Changes:

  • Static command tables (bt_command_t), option structures (struct option), and callback structures (various types) are marked as const
  • Cast operations added when passing const structures to APIs that expect non-const pointers
  • Forward declarations added where needed to maintain compilation order

Reviewed changes

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

Show a summary per file
File Description
tools/async/log.c Made g_log_async_tables const with cast when passing to execute_command_in_table
tools/async/gatt_client.c Made g_gattc_async_tables and gattc_cbs const with appropriate casts
tools/async/gap.c Made le_conn_options, g_set_cmd_tables, g_get_cmd_tables, and g_pair_cmd_tables const with casts
tools/async/adv.c Made adv_options, adv_stop_options, g_adv_async_tables, and adv_callback const with casts
tools/adv.c Made adv_options, adv_stop_options, g_adv_tables, and adv_callback const with casts
tools/a2dp_source.c Made g_a2dp_tables const with cast when passing to execute_command_in_table
service/stacks/zephyr/sal_spp_interface.c Made spp_attrs_template and g_rfcomm_ops const with cast when assigning ops pointer
service/stacks/zephyr/sal_hid_device_interface.c Made hid_attrs_template and hid_callback const with cast when registering
service/stacks/zephyr/sal_hfp_hf_interface.c Made hf_callbacks const with cast when registering
service/stacks/zephyr/sal_hfp_ag_interface.c Made g_hfp_ag_cb const with cast when registering
service/stacks/zephyr/sal_avrcp_interface.c Made avrcp_tg_cbks const (only declaration shown, usage not in diff)
service/stacks/zephyr/sal_adapter_le_interface.c Made g_conn_cbs, g_conn_auth_info_cbs, and g_setting_cbs const with casts; added forward declarations
service/stacks/zephyr/sal_adapter_interface.c Made g_conn_cbs, g_setting_cbs, g_conn_auth_info_cbs, and g_br_discovery_cb const with casts
service/stacks/zephyr/sal_a2dp_interface.c Made sbc_src_ie, stream_ops, and a2dp_cbks const with casts
service/profiles/spp/spp_service.c Made sppInterface const (only definition shown, usage not in diff)
service/profiles/hid/hid_device_service.c Made deviceInterface const (only definition shown, usage not in diff)
service/ipc/socket/src/bt_socket_spp.c Made g_spp_socket_cb const with cast when registering
service/ipc/socket/src/bt_socket_scan.c Made g_scanner_socket_cb const with cast when starting scan
service/ipc/socket/src/bt_socket_advertiser.c Made g_advertiser_socket_cb const with cast when starting advertising
framework/btwrap/async/bt_gatt_feature.c Made s_feature_gattc_cbs const with cast when creating client
feature/feature_async/src/bluetooth_ble_impl.c Made adv_callback and gattc_cbs const with casts

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

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.

1 participant