Skip to content

Comments

Bugfix/fix bluetooth sal hid device interface moudle cb change to const#432

Open
huangyulong3 wants to merge 14 commits intoopen-vela:devfrom
huangyulong3:bugfix/fix_bluetooth_sal_hid_device_interface_moudle_cb_change_to_const
Open

Bugfix/fix bluetooth sal hid device interface moudle cb change to const#432
huangyulong3 wants to merge 14 commits intoopen-vela:devfrom
huangyulong3:bugfix/fix_bluetooth_sal_hid_device_interface_moudle_cb_change_to_const

Conversation

@huangyulong3
Copy link

Memory Optimization: Change the bluetooth sal hid device interface module 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.

…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.
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 to reduce RAM usage by marking callback and configuration structures as const, which causes them to be stored in Flash memory instead of RAM.

Changes:

  • Modified static callback and configuration structures to be const across multiple Bluetooth service stack files
  • Added explicit casts when passing const structures to registration APIs that don't accept const parameters
  • Applied the optimization consistently across HID, HFP, A2DP, AVRCP, SPP, GATT, advertising, and scanning modules

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
service/stacks/zephyr/sal_hid_device_interface.c Made HID device callback structures const; added cast for registration
service/stacks/zephyr/sal_hfp_hf_interface.c Made HFP HF callback structures const; added cast for registration
service/stacks/zephyr/sal_hfp_ag_interface.c Made HFP AG callback structures const; added cast for registration
service/stacks/zephyr/sal_avrcp_interface.c Made AVRCP target callback structures const
service/stacks/zephyr/sal_adapter_le_interface.c Made LE adapter callback structures const; added casts and forward declarations
service/stacks/zephyr/sal_adapter_interface.c Made BR/EDR adapter callback structures const; added casts for registration
service/stacks/zephyr/sal_a2dp_interface.c Made A2DP callback and codec structures const; added casts for registration
service/profiles/spp/spp_service.c Made SPP interface structure const
service/profiles/hid/hid_device_service.c Made HID device interface structure const
service/ipc/socket/src/bt_socket_spp.c Made socket SPP callback structure const; added cast for registration
service/ipc/socket/src/bt_socket_scan.c Made scanner callback structure const; added cast for registration
service/ipc/socket/src/bt_socket_advertiser.c Made advertiser callback structure const; added cast for registration
framework/btwrap/async/bt_gatt_feature.c Made GATT client callback structure const; added cast for registration
feature/feature_async/src/bluetooth_ble_impl.c Made advertiser and GATT client callback structures const; added casts

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

Comment on lines +110 to +112
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);

Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

These forward declarations for le_conn_add and le_conn_find appear to be unused. A search of the file shows these functions are neither called nor defined anywhere in this file. If these are not used, they should be removed to avoid confusion.

Suggested change
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);

Copilot uses AI. Check for mistakes.
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