Skip to content

Bugfix/fix bluetooth bt tool async gap moudle cb change to const#437

Open
huangyulong3 wants to merge 19 commits intoopen-vela:devfrom
huangyulong3:bugfix/fix_bluetooth_bt_tool_async_gap_moudle_cb_change_to_const
Open

Bugfix/fix bluetooth bt tool async gap moudle cb change to const#437
huangyulong3 wants to merge 19 commits intoopen-vela:devfrom
huangyulong3:bugfix/fix_bluetooth_bt_tool_async_gap_moudle_cb_change_to_const

Conversation

@huangyulong3
Copy link

Memory Optimization: Change the bluetooth bt_tool async gap module to 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.

…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
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 pull request implements a memory optimization for Bluetooth tools by adding the const qualifier to static data structures across multiple files. The optimization moves read-only data structures from RAM to Flash memory, reducing RAM consumption as described in bug v/84961.

Changes:

  • Added const qualifier to static command tables (bt_command_t arrays) and option arrays (struct option arrays) in tools modules
  • Added const qualifier to static callback structures (e.g., advertiser_callback_t, bt_conn_cb, bt_hfp_hf_cb) across service layers
  • Added explicit casts to remove const when passing these structures to functions that don't accept const pointers (API compatibility)

Reviewed changes

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

Show a summary per file
File Description
tools/async/gap.c Made command tables and connection options const; added casts when passing to execute_command_in_table
tools/async/adv.c Made advertising options, command tables, and callback structure const; added casts at usage sites
tools/adv.c Made advertising options, command tables, and callback structure const; added casts at usage sites
tools/a2dp_source.c Made A2DP command table const; added cast when passing to execute_command_in_table
service/stacks/zephyr/sal_spp_interface.c Made SDP attributes and RFCOMM operations callback structure const; added cast at assignment
service/stacks/zephyr/sal_hid_device_interface.c Made SDP attributes and HID callback structure const; added cast at registration
service/stacks/zephyr/sal_hfp_hf_interface.c Made HFP HF callback structure const; added cast at registration
service/stacks/zephyr/sal_hfp_ag_interface.c Made HFP AG callback structure const; added cast at registration
service/stacks/zephyr/sal_avrcp_interface.c Made AVRCP target callback structure const
service/stacks/zephyr/sal_adapter_le_interface.c Made LE adapter callback structures const; added forward declarations; added casts at registration
service/stacks/zephyr/sal_adapter_interface.c Made BR/EDR adapter callback structures const; added casts at registration
service/stacks/zephyr/sal_a2dp_interface.c Made A2DP codec info and callback structures const; added casts at usage sites
service/profiles/spp/spp_service.c Made SPP interface structure const; cast handled by return type
service/profiles/hid/hid_device_service.c Made HID device interface structure const; cast handled by return type
service/ipc/socket/src/bt_socket_spp.c Made SPP socket callback structure const; added cast at registration
service/ipc/socket/src/bt_socket_scan.c Made scanner socket callback structure const; added cast at usage
service/ipc/socket/src/bt_socket_advertiser.c Made advertiser socket callback structure const; added cast at usage
framework/btwrap/async/bt_gatt_feature.c Made GATT client callback structure const; added cast at usage
feature/feature_async/src/bluetooth_ble_impl.c Made advertiser and GATT client callback structures const; added casts at usage

💡 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