Bugfix/fix bluetooth bt tool moudle cb change to const#441
Bugfix/fix bluetooth bt tool moudle cb change to const#441huangyulong3 wants to merge 23 commits intoopen-vela:devfrom
Conversation
…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>
…t for reduce the ram size. bug:v/84968 Rootcause: To reduce RAM resource consumption, the `scan_options`, in the bt_tools 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>
… reduce the ram size. bug:v/84969 Rootcause: To reduce RAM resource consumption, the `le_conn_options`, `g_cmd_tables`, `g_set_cmd_tables` and `g_pair_cmd_tables` in the bt_tools 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>
There was a problem hiding this comment.
Pull request overview
This PR implements a memory optimization by marking multiple static structures as const in the Bluetooth bt_tool module and related service stack components to move them from RAM to Flash memory.
Changes:
- Static command tables, option structures, and callback structures are marked as
constacross multiple files - Cast operations are added when passing const structures to functions that expect non-const pointers
- Forward declarations added in sal_adapter_le_interface.c (appears unrelated to main changes)
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/bt_tools.c | Marked command tables and option structures as const, added casts when passing to execute_command_in_table |
| tools/async/scan.c | Marked scan options and command tables as const, added cast to execute_command_in_table_offset |
| tools/async/log.c | Marked log command tables as const, added cast to execute_command_in_table |
| tools/async/gatt_client.c | Marked GATT client command tables and callback structure as const, added casts when registering |
| tools/async/gap.c | Marked GAP command tables and connection options as const, added casts to execute_command_in_table |
| tools/async/adv.c | Marked advertising options, command tables, and callback structure as const, added casts |
| tools/adv.c | Marked advertising options, command tables, and callback structure as const, added casts |
| tools/a2dp_source.c | Marked A2DP command tables as const, added cast to execute_command_in_table |
| service/stacks/zephyr/sal_spp_interface.c | Marked SDP attributes and RFCOMM operations as const, added cast when assigning ops |
| service/stacks/zephyr/sal_hid_device_interface.c | Marked HID SDP attributes and callback structure as const, added cast when registering |
| service/stacks/zephyr/sal_hfp_hf_interface.c | Marked HFP HF callback structure as const, added cast when registering |
| service/stacks/zephyr/sal_hfp_ag_interface.c | Marked HFP AG callback structure as const, added cast when registering |
| service/stacks/zephyr/sal_avrcp_interface.c | Marked AVRCP target callback structure as const |
| service/stacks/zephyr/sal_adapter_le_interface.c | Marked LE adapter callback structures as const, added casts when registering, added unrelated forward declarations |
| service/stacks/zephyr/sal_adapter_interface.c | Marked BR/EDR adapter callback structures as const, added casts when registering |
| service/stacks/zephyr/sal_a2dp_interface.c | Marked A2DP codec IE and callback structures as const, added casts when registering |
| service/profiles/spp/spp_service.c | Marked SPP interface structure as const |
| service/profiles/hid/hid_device_service.c | Marked HID device interface structure as const |
| service/ipc/socket/src/bt_socket_spp.c | Marked SPP socket callback structure as const, added cast when registering |
| service/ipc/socket/src/bt_socket_scan.c | Marked scanner socket callback structure as const, added cast when starting scan |
| service/ipc/socket/src/bt_socket_advertiser.c | Marked advertiser socket callback structure as const, added cast when starting advertising |
| framework/btwrap/async/bt_gatt_feature.c | Marked GATT feature callback structure as const, added cast when creating client |
| feature/feature_async/src/bluetooth_ble_impl.c | Marked advertiser and GATT client callback structures as const, added casts when using |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| static le_conn_info_t* le_conn_add(const bt_address_t* addr); | ||
| static le_conn_info_t* le_conn_find(const bt_address_t* addr); | ||
|
|
There was a problem hiding this comment.
These forward declarations appear to be unnecessary and unrelated to the const changes in this PR. The functions le_conn_add and le_conn_find are not defined or used in this file, and these declarations do not appear to be related to the memory optimization goals of this PR. Consider removing these lines.
| static le_conn_info_t* le_conn_add(const bt_address_t* addr); | |
| static le_conn_info_t* le_conn_find(const bt_address_t* addr); |
Memory Optimization: Change the bluetooth bt_tool module to const for reduce the ram size.
bug:v/84969
Rootcause: To reduce RAM resource consumption, the
le_conn_options,g_cmd_tables,g_set_cmd_tablesandg_pair_cmd_tablesin the bt_tools module must be marked with the
constmodifier.This ensures it is compiled and linked into Flash memory instead of RAM.