From 102bb269fef1e9de6cd991b13366b305c1d766be Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Mon, 26 Jan 2026 22:37:08 +0800 Subject: [PATCH 01/29] Memory Optimization: Change the bluetooth ble impl module adv_callback 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 --- feature/feature_async/src/bluetooth_ble_impl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/feature/feature_async/src/bluetooth_ble_impl.c b/feature/feature_async/src/bluetooth_ble_impl.c index 2052fb16b..fe50d4314 100644 --- a/feature/feature_async/src/bluetooth_ble_impl.c +++ b/feature/feature_async/src/bluetooth_ble_impl.c @@ -299,7 +299,7 @@ static void on_advertising_stopped_cb(bt_advertiser_t* adv, uint8_t adv_id) adv_info->busy = false; } -static advertiser_callback_t adv_callback = { +static const advertiser_callback_t adv_callback = { sizeof(adv_callback), on_advertising_start_cb, on_advertising_stopped_cb @@ -595,7 +595,7 @@ void system_bluetooth_ble_Advertiser_interface_adv_startAdvertising(FeatureInter adv_info->start_userdata = (void*)data; status = bt_le_start_advertising_async(adv_info->ins, &adv_params, - p_adv_data, adv_len, p_scan_rsp_data, scan_rsp_len, &adv_callback, + p_adv_data, adv_len, p_scan_rsp_data, scan_rsp_len, (advertiser_callback_t *)&adv_callback, start_adv_cb, (void*)data); if (status != BT_STATUS_SUCCESS) { @@ -1563,7 +1563,7 @@ static void mtu_updated_callback(gattc_handle_t conn_handle, gatt_status_t statu bt_list_remove(gattc_info->userdata_list, data); } -static bt_gattc_feature_callbacks_t gattc_cbs = { +static const bt_gattc_feature_callbacks_t gattc_cbs = { sizeof(gattc_cbs), .on_connected = connect_callback, .on_disconnected = disconnect_callback, @@ -1761,7 +1761,7 @@ void system_bluetooth_ble_GattClient_interface_gattc_connect(FeatureInterfaceHan gattc_info->gattc->addr_type, gattc_connect_cb, (void*)data); } else { status = bt_gattc_feature_create_client_async(gattc_info->ins, &gattc_info->gattc->remote_address, gattc_create_cb, - &gattc_cbs, (void*)data); + (bt_gattc_feature_callbacks_t *)&gattc_cbs, (void*)data); } if (status != BT_STATUS_SUCCESS) { From 3a2296402140df6c280ef03ec536fb602470bf04 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Mon, 26 Jan 2026 22:43:13 +0800 Subject: [PATCH 02/29] Memory Optimization: Change the bluetooth gatt feature module s_feature_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 --- framework/btwrap/async/bt_gatt_feature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/btwrap/async/bt_gatt_feature.c b/framework/btwrap/async/bt_gatt_feature.c index 25b53a4a5..32fdd67d3 100644 --- a/framework/btwrap/async/bt_gatt_feature.c +++ b/framework/btwrap/async/bt_gatt_feature.c @@ -716,7 +716,7 @@ static void feature_on_mtu_updated(void* conn_handle, gatt_status_t status, uint client->conn, status, mtu); } -static gattc_callbacks_t s_feature_gattc_cbs = { +static const gattc_callbacks_t s_feature_gattc_cbs = { sizeof(s_feature_gattc_cbs), feature_on_connected, feature_on_disconnected, @@ -806,7 +806,7 @@ bt_status_t bt_gattc_feature_create_client_async(bt_instance_t* ins, bt_address_ bt_list_add_tail(g_gatt_client_list, client); status = bt_gattc_create_connect_async( - ins, &client->conn, &s_feature_gattc_cbs, create_client_cb, client); + ins, &client->conn, (gattc_callbacks_t *)&s_feature_gattc_cbs, create_client_cb, client); if (status != BT_STATUS_SUCCESS) { bt_list_remove(g_gatt_client_list, client); From c72026600fb9636f40e97280c6a4aede01b1cb33 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Mon, 26 Jan 2026 23:10:21 +0800 Subject: [PATCH 03/29] Memory Optimization: Change the bluetooth socket advertiser module adv_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 adv_pl._bt_le_start_advertising.adv_len, packet->adv_pl._bt_le_start_advertising.scan_rsp_data, packet->adv_pl._bt_le_start_advertising.scan_rsp_len, - &g_advertiser_socket_cb); + (advertiser_callback_t *)&g_advertiser_socket_cb); if (!packet->adv_r.remote) free(adver); From 87e380a157fac87e5111f3bfb130a3a4526a4231 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Mon, 26 Jan 2026 23:23:26 +0800 Subject: [PATCH 04/29] Memory Optimization: Change the bluetooth socket scan module adv_callback 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 ins = ins; scan->remote = packet->scan_pl._bt_le_start_scan.remote; - packet->scan_r.remote = PTR2INT(uint64_t) scanner_start_scan(scan, &g_scanner_socket_cb); + packet->scan_r.remote = PTR2INT(uint64_t) scanner_start_scan(scan, (scanner_callbacks_t *)&g_scanner_socket_cb); if (!packet->scan_r.remote) free(scan); break; From 23b4b65c149ff66df39cb12942bb121fad2ebd63 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Mon, 26 Jan 2026 23:29:20 +0800 Subject: [PATCH 05/29] Memory Optimization: Change the bluetooth socket spp module g_spp_socket_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 code) { case BT_SPP_REGISTER_APP: { if (ins->spp_cookie == NULL) { - ins->spp_cookie = profile->register_app(ins, packet->spp_pl._bt_spp_register_app.name_len ? packet->spp_pl._bt_spp_register_app.name : NULL, &g_spp_socket_cb); + ins->spp_cookie = profile->register_app(ins, packet->spp_pl._bt_spp_register_app.name_len ? packet->spp_pl._bt_spp_register_app.name : NULL, (spp_callbacks_t *)&g_spp_socket_cb); packet->spp_r.handle = PTR2INT(uint64_t) ins->spp_cookie; } else { packet->spp_r.handle = 0; From c18022b4780a799676ec41975d30862f42272b46 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Mon, 26 Jan 2026 23:37:33 +0800 Subject: [PATCH 06/29] Memory Optimization: Change the bluetooth hid device service module to 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 Date: Mon, 26 Jan 2026 23:50:44 +0800 Subject: [PATCH 07/29] Memory Optimization: Change the bluetooth spp service module to const 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 Date: Tue, 27 Jan 2026 00:01:17 +0800 Subject: [PATCH 08/29] Memory Optimization: Change the bluetooth sal a2dp interface module to 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 stream = (struct bt_a2dp_stream*)calloc(1, sizeof(struct bt_a2dp_stream)); - bt_a2dp_stream_cb_register(a2dp_info->stream, &stream_ops); + bt_a2dp_stream_cb_register(a2dp_info->stream, (struct bt_a2dp_stream_ops *)&stream_ops); if (a2dp_info->role == SEP_SRC) { #ifdef CONFIG_BLUETOOTH_A2DP_SOURCE @@ -1430,7 +1430,7 @@ static int zblue_on_config_req(struct bt_a2dp* a2dp, struct bt_a2dp_ep* ep, a2dp_info->stream = (struct bt_a2dp_stream*)calloc(1, sizeof(struct bt_a2dp_stream)); *stream = a2dp_info->stream; /* The a2dp_stream saved in SAL is assigned a value in zblue. */ - bt_a2dp_stream_cb_register(a2dp_info->stream, &stream_ops); + bt_a2dp_stream_cb_register(a2dp_info->stream, (struct bt_a2dp_stream_ops *)&stream_ops); *rsp_err_code = BT_AVDTP_SUCCESS; return 0; } @@ -1516,7 +1516,7 @@ static void zblue_on_suspend_rsp(struct bt_a2dp_stream* stream, uint8_t rsp_err_ BT_LOGE("%s, suspend fail: %d", __func__, rsp_err_code); } -static struct bt_a2dp_cb a2dp_cbks = { +static const struct bt_a2dp_cb a2dp_cbks = { .connected = zblue_on_connected, .disconnected = zblue_on_disconnected, .config_req = zblue_on_config_req, @@ -1565,7 +1565,7 @@ bt_status_t bt_sal_a2dp_source_init(uint8_t max_connections) } #endif /* CONFIG_BLUETOOTH_A2DP_AAC_CODEC */ - SAL_CHECK_RET(bt_a2dp_register_cb(&a2dp_cbks), 0); + SAL_CHECK_RET(bt_a2dp_register_cb((struct bt_a2dp_cb *)&a2dp_cbks), 0); return BT_STATUS_SUCCESS; #else @@ -1605,7 +1605,7 @@ bt_status_t bt_sal_a2dp_sink_init(uint8_t max_connections) } #endif /* CONFIG_BLUETOOTH_A2DP_AAC_CODEC */ - SAL_CHECK_RET(bt_a2dp_register_cb(&a2dp_cbks), 0); + SAL_CHECK_RET(bt_a2dp_register_cb((struct bt_a2dp_cb *)&a2dp_cbks), 0); return BT_STATUS_SUCCESS; #else From 620988d23617317ff4117f29bf3362114a4106ae Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Tue, 27 Jan 2026 00:10:44 +0800 Subject: [PATCH 09/29] Memory Optimization: Change the bluetooth sal adapter interface module 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 Date: Tue, 3 Feb 2026 23:14:38 +0800 Subject: [PATCH 10/29] Memory Optimization: Change the bluetooth sal le adapter interface module 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 --- .../stacks/zephyr/sal_adapter_le_interface.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/service/stacks/zephyr/sal_adapter_le_interface.c b/service/stacks/zephyr/sal_adapter_le_interface.c index 6eed0d1ec..a7f22f67f 100644 --- a/service/stacks/zephyr/sal_adapter_le_interface.c +++ b/service/stacks/zephyr/sal_adapter_le_interface.c @@ -107,7 +107,10 @@ static enum bt_security_err zblue_on_pairing_accept(struct bt_conn* conn, const static void zblue_register_callback(void); static void zblue_unregister_callback(void); -static struct bt_conn_cb g_conn_cbs = { +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); + +static const struct bt_conn_cb g_conn_cbs = { .connected = zblue_on_connected, .disconnected = zblue_on_disconnected, #ifdef CONFIG_BT_SMP @@ -119,7 +122,7 @@ static struct bt_conn_cb g_conn_cbs = { #endif }; -static struct bt_conn_auth_info_cb g_conn_auth_info_cbs = { +static const struct bt_conn_auth_info_cb g_conn_auth_info_cbs = { .pairing_complete_ctkd = zblue_on_pairing_complete_ctkd, .pairing_complete = zblue_on_pairing_complete, .pairing_failed = zblue_on_pairing_failed, @@ -127,7 +130,7 @@ static struct bt_conn_auth_info_cb g_conn_auth_info_cbs = { }; #if defined(CONFIG_SETTINGS_ZBLUE) -static struct bt_settings_zblue_cb g_setting_cbs = { +static const struct bt_settings_zblue_cb g_setting_cbs = { .irk_notify = zblue_on_irk_notify, .irk_load = zblue_on_irk_load, .ltk_notify = zblue_on_ltk_notify, @@ -758,22 +761,22 @@ static void zblue_on_bond_deleted(uint8_t id, const bt_addr_le_t* peer) static void zblue_register_callback(void) { - bt_conn_cb_register(&g_conn_cbs); + bt_conn_cb_register((struct bt_conn_cb *)&g_conn_cbs); #ifdef CONFIG_BT_SMP - bt_conn_le_auth_cb_register(&g_conn_auth_cbs); - bt_conn_auth_info_cb_register(&g_conn_auth_info_cbs); + bt_conn_le_auth_cb_register((struct bt_conn_auth_cb *)&g_conn_auth_cbs); + bt_conn_auth_info_cb_register((struct bt_conn_auth_info_cb *)&g_conn_auth_info_cbs); #endif #ifdef CONFIG_SETTINGS_ZBLUE - bt_setting_cb_register(&g_setting_cbs); + bt_setting_cb_register((struct bt_settings_zblue_cb *)&g_setting_cbs); #endif } static void zblue_unregister_callback(void) { - bt_conn_cb_unregister(&g_conn_cbs); + bt_conn_cb_unregister((struct bt_conn_cb *)&g_conn_cbs); #ifdef CONFIG_BT_SMP bt_conn_le_auth_cb_register(NULL); - bt_conn_auth_info_cb_unregister(&g_conn_auth_info_cbs); + bt_conn_auth_info_cb_unregister((struct bt_conn_auth_info_cb *)&g_conn_auth_info_cbs); #endif } From cb1ca151bc90903e337364b5f60b8a90aa988f91 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Tue, 3 Feb 2026 23:33:40 +0800 Subject: [PATCH 11/29] Memory Optimization: Change the bluetooth sal avrcp interface module 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 --- service/stacks/zephyr/sal_avrcp_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/stacks/zephyr/sal_avrcp_interface.c b/service/stacks/zephyr/sal_avrcp_interface.c index 171613db9..4cb8c6479 100644 --- a/service/stacks/zephyr/sal_avrcp_interface.c +++ b/service/stacks/zephyr/sal_avrcp_interface.c @@ -130,7 +130,7 @@ static void zblue_on_tg_register_notification_req(struct bt_avrcp_tg* tg, uint8_ static void zblue_on_tg_set_absolute_volume_req(struct bt_avrcp_tg* tg, uint8_t tid, uint8_t absolute_volume); #endif -static struct bt_avrcp_tg_cb avrcp_tg_cbks = { +static const struct bt_avrcp_tg_cb avrcp_tg_cbks = { #ifdef CONFIG_BLUETOOTH_AVRCP_TARGET .unit_info_req = zblue_on_tg_unit_info_req, .subunit_info_req = zblue_on_tg_subunit_info_req, From ed8fc42a96d1cafdd2df96cbf20c293546c73d72 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Tue, 3 Feb 2026 23:53:23 +0800 Subject: [PATCH 12/29] Memory Optimization: Change the bluetooth sal hfp ag interface module 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 --- service/stacks/zephyr/sal_hfp_ag_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/stacks/zephyr/sal_hfp_ag_interface.c b/service/stacks/zephyr/sal_hfp_ag_interface.c index e16e6d36a..0f1c43a5b 100644 --- a/service/stacks/zephyr/sal_hfp_ag_interface.c +++ b/service/stacks/zephyr/sal_hfp_ag_interface.c @@ -952,7 +952,7 @@ static void zblue_on_ag_transmit_dtmf_code(struct bt_hfp_ag* ag, char code) hfp_ag_on_received_dtmf(&sal_conn->addr, code); } -static struct bt_hfp_ag_cb g_hfp_ag_cb = { +static const struct bt_hfp_ag_cb g_hfp_ag_cb = { .connected = zblue_on_ag_connected, .disconnected = zblue_on_ag_disconnected, .sco_connected = zblue_on_ag_sco_connected, @@ -992,7 +992,7 @@ bt_status_t bt_sal_hfp_ag_init(uint32_t features, uint8_t max_connection) BT_LOGD("%s, HFP AG init", __func__); g_sal_ag_conn_list = bt_list_new(free_connection); - SAL_CHECK_RET(Z_API(bt_hfp_ag_register)(&g_hfp_ag_cb), 0); + SAL_CHECK_RET(Z_API(bt_hfp_ag_register)((struct bt_hfp_ag_cb *)&g_hfp_ag_cb), 0); return BT_STATUS_SUCCESS; } From 52fa65c3570fc8199390fff29ba56aa6b9ae018d Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:00:02 +0800 Subject: [PATCH 13/29] Mmemory Optimization: Change the bluetooth sal hfp hf interface module 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. --- service/stacks/zephyr/sal_hfp_hf_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/stacks/zephyr/sal_hfp_hf_interface.c b/service/stacks/zephyr/sal_hfp_hf_interface.c index 96674de12..7d9d764dd 100644 --- a/service/stacks/zephyr/sal_hfp_hf_interface.c +++ b/service/stacks/zephyr/sal_hfp_hf_interface.c @@ -888,7 +888,7 @@ static void zblue_on_current_call(struct bt_hfp_hf* hf, struct bt_hfp_hf_current hfp_hf_on_current_call_response(&sal_conn->addr, idx, dir, status, mpty, call->number, call->type); } -static struct bt_hfp_hf_cb hf_callbacks = { +static const struct bt_hfp_hf_cb hf_callbacks = { .connected = zblue_on_connected, .disconnected = zblue_hf_disconnected, .sco_connected = zblue_on_sco_connected, @@ -932,7 +932,7 @@ bt_status_t bt_sal_hfp_hf_init(uint32_t hf_features, uint8_t max_connection) int err; g_sal_hf_conn_list = bt_list_new(free_connection); - err = Z_API(bt_hfp_hf_register)(&hf_callbacks); + err = Z_API(bt_hfp_hf_register)((struct bt_hfp_hf_cb *)&hf_callbacks); if (err) { bt_list_free(g_sal_hf_conn_list); From acd98bd859030ef5f56703fc64c491ce164d9018 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:06:11 +0800 Subject: [PATCH 14/29] 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. --- service/stacks/zephyr/sal_hid_device_interface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/stacks/zephyr/sal_hid_device_interface.c b/service/stacks/zephyr/sal_hid_device_interface.c index de7c3968c..d0cb0fd3d 100644 --- a/service/stacks/zephyr/sal_hid_device_interface.c +++ b/service/stacks/zephyr/sal_hid_device_interface.c @@ -61,7 +61,7 @@ typedef struct sal_bt_hid_device_mgr { uint8_t* description; } sal_bt_hid_device_mgr_t; -static struct bt_sdp_attribute hid_attrs_template[] = { +static const struct bt_sdp_attribute hid_attrs_template[] = { BT_SDP_NEW_SERVICE, BT_SDP_LIST( BT_SDP_ATTR_SVCLASS_ID_LIST, @@ -539,7 +539,7 @@ void hid_vc_unplug_callback(struct bt_hid_device* hid) hid_device_on_virtual_cable_unplug(&hid_conn->addr); } -static struct bt_hid_device_cb hid_callback = { +static const struct bt_hid_device_cb hid_callback = { .accept = hid_accept_callback, .connected = hid_connect_callback, .disconnected = hid_disconnected_callback, @@ -556,7 +556,7 @@ bt_status_t bt_sal_hid_device_init() int err; sal_bt_hid_device_mgr_t* hid_mgr = &g_hid_device_mgr; - err = Z_API(bt_hid_device_register)(&hid_callback); + err = Z_API(bt_hid_device_register)((struct bt_hid_device_cb *)&hid_callback); if (err != 0) { BT_LOGE("HID register cb fail,err:%d", err); return BT_STATUS_FAIL; From 8cbc23df823e5a8fb82d702c67c6f6e272981bae Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:11:18 +0800 Subject: [PATCH 15/29] Memory Optimization: Change the bluetooth sal spp device interface module 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 --- service/stacks/zephyr/sal_spp_interface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/service/stacks/zephyr/sal_spp_interface.c b/service/stacks/zephyr/sal_spp_interface.c index 598d6b4b4..129723891 100644 --- a/service/stacks/zephyr/sal_spp_interface.c +++ b/service/stacks/zephyr/sal_spp_interface.c @@ -95,7 +95,7 @@ extern struct net_buf_pool sdp_pool; NET_BUF_POOL_FIXED_DEFINE(rfcomm_tx_pool, SPP_DEFAULT_CREDITS, SAL_SPP_RFCOMM_MFS + SPP_MFS_EXTRA_SIZE, CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL); -static struct bt_sdp_attribute spp_attrs_template[] = { +static const struct bt_sdp_attribute spp_attrs_template[] = { BT_SDP_NEW_SERVICE, BT_SDP_LIST( BT_SDP_ATTR_SVCLASS_ID_LIST, @@ -438,7 +438,7 @@ static void spp_rfcomm_sent(struct bt_rfcomm_dlc* rfcomm_dlc, int err) spp_conn_unlock(); } -static struct bt_rfcomm_dlc_ops g_rfcomm_ops = { +static const struct bt_rfcomm_dlc_ops g_rfcomm_ops = { .connected = spp_rfcomm_connected, .disconnected = spp_rfcomm_disconnected, .recv = spp_rfcomm_recv, @@ -523,7 +523,7 @@ static sal_spp_connection_t* spp_connection_new(bt_address_t* addr, uint16_t con return NULL; } - spp_conn->rfcomm_dlc.ops = &g_rfcomm_ops; + spp_conn->rfcomm_dlc.ops = (struct bt_rfcomm_dlc_ops *)&g_rfcomm_ops; spp_conn->rfcomm_dlc.mtu = SAL_SPP_RFCOMM_MFS; memcpy(&spp_conn->addr, addr, sizeof(bt_address_t)); From 4f8316b402f4f0e05826b7d2125ad02667e1155c Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:35:43 +0800 Subject: [PATCH 16/29] Memory Optimization: Change the bluetooth bt_tool a2dp source module 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 --- tools/a2dp_source.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/a2dp_source.c b/tools/a2dp_source.c index e48c25c7c..2e1af5947 100644 --- a/tools/a2dp_source.c +++ b/tools/a2dp_source.c @@ -27,7 +27,7 @@ static int connect_cmd(void* handle, int argc, char* argv[]); static int disconnect_cmd(void* handle, int argc, char* argv[]); static int get_state_cmd(void* handle, int argc, char* argv[]); -static bt_command_t g_a2dp_tables[] = { +static const bt_command_t g_a2dp_tables[] = { { "connect", connect_cmd, 0, "\"establish a2dp signal and stream connection, params:
\"" }, { "disconnect", disconnect_cmd, 0, "\"disconnect a2dp signal and stream connection, params:
\"" }, { "state", get_state_cmd, 0, "\"get a2dp connection or audio state , params:
\"" }, @@ -131,7 +131,7 @@ int a2dp_src_command_exec(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_a2dp_tables, ARRAY_SIZE(g_a2dp_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_a2dp_tables, ARRAY_SIZE(g_a2dp_tables), argc, argv); if (ret < 0) usage(); From 866dc40ca38f44658064ffd4d45fa8078e1ab263 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:45:47 +0800 Subject: [PATCH 17/29] Memory Optimization: Change the bluetooth bt_tool adv module to const 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 --- tools/adv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/adv.c b/tools/adv.c index 4eee9e210..c5ca5f78b 100644 --- a/tools/adv.c +++ b/tools/adv.c @@ -28,7 +28,7 @@ static int stop_adv_cmd(void* handle, int argc, char* argv[]); static int set_adv_data_cmd(void* handle, int argc, char* argv[]); static int dump_adv_cmd(void* handle, int argc, char* argv[]); -static struct option adv_options[] = { +static const struct option adv_options[] = { { "adv_type", required_argument, 0, 't' }, { "mode", required_argument, 0, 'm' }, { "interval", required_argument, 0, 'i' }, @@ -45,13 +45,13 @@ static struct option adv_options[] = { { 0, 0, 0, 0 } }; -static struct option adv_stop_options[] = { +static const struct option adv_stop_options[] = { { "advid", required_argument, 0, 'i' }, { "handle", required_argument, 0, 'h' }, { 0, 0, 0, 0 } }; -static bt_command_t g_adv_tables[] = { +static const bt_command_t g_adv_tables[] = { { "start", start_adv_cmd, 1, "start advertising\n" "\t -t or --adv_type, advertising type opt(adv_ind/direct_ind/nonconn_ind/scan_ind)\n" "\t -m or --mode, advertising mode opt(legacy/ext/auto, default auto)\n" @@ -98,7 +98,7 @@ static void on_advertising_stopped_cb(bt_advertiser_t* adv, uint8_t adv_id) PRINT("%s, handle:%p, adv_id:%d", __func__, adv, adv_id); } -static advertiser_callback_t adv_callback = { +static const advertiser_callback_t adv_callback = { sizeof(adv_callback), on_advertising_start_cb, on_advertising_stopped_cb @@ -404,7 +404,7 @@ static int start_adv_cmd(void* handle, int argc, char* argv[]) adv_handle = bt_le_start_advertising(handle, ¶ms, p_adv_data, adv_len, p_scan_rsp_data, scan_rsp_len, - &adv_callback); + (advertiser_callback_t *)&adv_callback); PRINT("Advertising handle:%p", adv_handle); /* free advertiser data */ @@ -482,7 +482,7 @@ int adv_command_exec(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table_offset(handle, g_adv_tables, ARRAY_SIZE(g_adv_tables), argc, argv, 0); + ret = execute_command_in_table_offset(handle, (bt_command_t *)g_adv_tables, ARRAY_SIZE(g_adv_tables), argc, argv, 0); if (ret < 0) usage(); From 2b5a4929573f51fa9aa3a77bfc2e4dcc5ef6c954 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:52:35 +0800 Subject: [PATCH 18/29] Memory Optimization: Change the bluetooth bt_tool async adv module to 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 --- tools/async/adv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/async/adv.c b/tools/async/adv.c index 665df8474..a2073df2c 100644 --- a/tools/async/adv.c +++ b/tools/async/adv.c @@ -33,7 +33,7 @@ static int stop_adv_cmd(void* handle, int argc, char* argv[]); static int set_adv_data_cmd(void* handle, int argc, char* argv[]); static int dump_adv_cmd(void* handle, int argc, char* argv[]); -static struct option adv_options[] = { +static const struct option adv_options[] = { { "adv_type", required_argument, 0, 't' }, { "mode", required_argument, 0, 'm' }, { "interval", required_argument, 0, 'i' }, @@ -49,13 +49,13 @@ static struct option adv_options[] = { { 0, 0, 0, 0 } }; -static struct option adv_stop_options[] = { +static const struct option adv_stop_options[] = { { "advid", required_argument, 0, 'i' }, { "handle", required_argument, 0, 'h' }, { 0, 0, 0, 0 } }; -static bt_command_t g_adv_async_tables[] = { +static const bt_command_t g_adv_async_tables[] = { { "start", start_adv_cmd, 1, "start advertising\n" "\t -t or --adv_type, advertising type opt(adv_ind/direct_ind/nonconn_ind/scan_ind)\n" "\t -m or --mode, advertising mode opt(legacy/ext/auto, default auto)\n" @@ -105,7 +105,7 @@ static void on_advertising_stopped_cb(bt_advertiser_t* adv, uint8_t adv_id) PRINT("%s, handle:%p, adv_id:%d", __func__, adv, adv_id); } -static advertiser_callback_t adv_callback = { +static const advertiser_callback_t adv_callback = { sizeof(adv_callback), on_advertising_start_cb, on_advertising_stopped_cb @@ -346,7 +346,7 @@ static int start_adv_cmd(void* handle, int argc, char* argv[]) bt_le_start_advertising_async(handle, ¶ms, p_adv_data, adv_len, p_scan_rsp_data, scan_rsp_len, - &adv_callback, + (advertiser_callback_t *)&adv_callback, start_advertising_callback_cb, NULL); /* free advertiser data */ @@ -421,7 +421,7 @@ int adv_command_exec_async(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table_offset(handle, g_adv_async_tables, ARRAY_SIZE(g_adv_async_tables), argc, argv, 0); + ret = execute_command_in_table_offset(handle, (bt_command_t *)g_adv_async_tables, ARRAY_SIZE(g_adv_async_tables), argc, argv, 0); if (ret < 0) usage(); From d7cf6aff60866ccd384ba20211dda454a1ca28cb Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 00:57:48 +0800 Subject: [PATCH 19/29] 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. Signed-off-by: huangyulong3 , range in 0x0-0xFFFFFC, the 2 least significant shall be 0b00, example: 0x00640404" #define SET_SCANPARAMS_USAGE "set scan parameters, params: (0: INQUIRY, 1: PAGE), (0: standard, 1: interlaced), (range in 18-4096), (range in 17-4096)" -static bt_command_t g_set_cmd_tables[] = { +static const bt_command_t g_set_cmd_tables[] = { { "scanmode", set_scanmode_cmd, 0, "params: (0:none, 1:connectable 2:connectable&discoverable)" }, { "iocap", set_iocap_cmd, 0, SET_IOCAP_USAGE }, { "name", set_local_name_cmd, 0, "params: , example \"vela-bt\"" }, @@ -223,7 +223,7 @@ static bt_command_t g_set_cmd_tables[] = { //{ "", , "set " }, }; -static bt_command_t g_get_cmd_tables[] = { +static const bt_command_t g_get_cmd_tables[] = { { "scanmode", get_scanmode_cmd, 0, "get adapter scan mode" }, { "iocap", get_iocap_cmd, 0, "get adapter io capability" }, { "addr", get_local_addr_cmd, 0, "get adapter local addr" }, @@ -240,7 +240,7 @@ static bt_command_t g_get_cmd_tables[] = { #define PAIR_PASSKEY_USAGE "input ssp passkey, params: (0:BLE, 1:BREDR)(0 :reject, 1: accept)" #define PAIR_CONFIRM_USAGE "set ssp confirmation, params: (0:BLE, 1:BREDR)(0 :reject, 1: accept)" -static bt_command_t g_pair_cmd_tables[] = { +static const bt_command_t g_pair_cmd_tables[] = { { "auto", pair_set_auto_cmd, 0, "enable pair auto reply, params: (0:disable, 1:enable)" }, { "reply", pair_reply_cmd, 0, "reply the pair request, params: (0 :reject, 1: accept)" }, { "pin", pair_set_pincode_cmd, 0, "input pin code, params: (0 :reject, 1: accept)" }, @@ -399,7 +399,7 @@ static int set_adapter_cmd(void* handle, int argc, char** argv) return CMD_PARAM_NOT_ENOUGH; } - int ret = execute_command_in_table(handle, g_set_cmd_tables, ARRAY_SIZE(g_set_cmd_tables), argc, argv); + int ret = execute_command_in_table(handle, (bt_command_t *)g_set_cmd_tables, ARRAY_SIZE(g_set_cmd_tables), argc, argv); if (ret != CMD_OK) set_usage(); @@ -413,7 +413,7 @@ static int get_adapter_cmd(void* handle, int argc, char** argv) return CMD_PARAM_NOT_ENOUGH; } - int ret = execute_command_in_table(handle, g_get_cmd_tables, ARRAY_SIZE(g_get_cmd_tables), argc, argv); + int ret = execute_command_in_table(handle, (bt_command_t *)g_get_cmd_tables, ARRAY_SIZE(g_get_cmd_tables), argc, argv); if (ret != CMD_OK) get_usage(); @@ -649,7 +649,7 @@ static int pair_cmd(void* handle, int argc, char** argv) return CMD_PARAM_NOT_ENOUGH; } - int ret = execute_command_in_table(handle, g_pair_cmd_tables, ARRAY_SIZE(g_pair_cmd_tables), argc, argv); + int ret = execute_command_in_table(handle, (bt_command_t *)g_pair_cmd_tables, ARRAY_SIZE(g_pair_cmd_tables), argc, argv); if (ret != CMD_OK) pair_usage(); From 368ba01f87d152c1abd2a018e0502b0330fcb472 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 01:02:30 +0800 Subject: [PATCH 20/29] Memory Optimization: Change the bluetooth bt_tool async gatt client module 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 --- tools/async/gatt_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/async/gatt_client.c b/tools/async/gatt_client.c index ed0cbee44..05e71dbe5 100644 --- a/tools/async/gatt_client.c +++ b/tools/async/gatt_client.c @@ -80,7 +80,7 @@ typedef struct { } \ } -static bt_command_t g_gattc_async_tables[] = { +static const bt_command_t g_gattc_async_tables[] = { { "create", create_cmd, 0, "\"create gatt client :\"" }, { "delete", delete_cmd, 0, "\"delete gatt client :\"" }, { "connect", connect_cmd, 0, "\"connect remote device :
[addr type(0:public,1:random,2:public_id,3:random_id)]\"" }, @@ -729,7 +729,7 @@ static void conn_param_updated_callback(void* conn_handle, bt_status_t status, u status, connection_interval, peripheral_latency, supervision_timeout); } -static gattc_callbacks_t gattc_cbs = { +static const gattc_callbacks_t gattc_cbs = { sizeof(gattc_cbs), connect_callback, disconnect_callback, @@ -761,7 +761,7 @@ static int create_cmd(void* handle, int argc, char* argv[]) int* conn_id = (int*)malloc(sizeof(int)); *conn_id = index; - if (bt_gattc_create_connect_async(handle, &g_gattc_devies[index].handle, &gattc_cbs, create_connect_cb, + if (bt_gattc_create_connect_async(handle, &g_gattc_devies[index].handle, (gattc_callbacks_t *)&gattc_cbs, create_connect_cb, conn_id) != BT_STATUS_SUCCESS) { free(conn_id); @@ -812,7 +812,7 @@ int gattc_command_exec_async(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_gattc_async_tables, ARRAY_SIZE(g_gattc_async_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_gattc_async_tables, ARRAY_SIZE(g_gattc_async_tables), argc, argv); if (ret < 0) usage(); From 7ce6ed88fd753bcd70fec8c87d80c3c515c98d97 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 09:23:05 +0800 Subject: [PATCH 21/29] 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. Signed-off-by: huangyulong3 --- tools/async/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/async/log.c b/tools/async/log.c index 033963679..f2738ae19 100644 --- a/tools/async/log.c +++ b/tools/async/log.c @@ -50,7 +50,7 @@ static int unfilter_cmd(void* handle, int argc, char* argv[]); static int unmask_cmd(void* handle, int argc, char* argv[]); static int level_cmd(void* handle, int argc, char* argv[]); -static bt_command_t g_log_async_tables[] = { +static const bt_command_t g_log_async_tables[] = { { "enable", enable_cmd, 0, "\"Enable param: (\"snoop\" or \"stack\")\"" }, { "disable", disable_cmd, 0, "\"Disable param: (\"snoop\" or \"stack\")\"" }, { "mask", mask_cmd, 0, "\"Enable Stack Profile & Protocol Log \"\n" @@ -243,7 +243,7 @@ int log_command_async(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_log_async_tables, ARRAY_SIZE(g_log_async_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_log_async_tables, ARRAY_SIZE(g_log_async_tables), argc, argv); if (ret < 0) usage(); From 2e94f8c459e17cc9eaf89f4d226231d800c0df58 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 09:33:23 +0800 Subject: [PATCH 22/29] Memory Optimization: Change the bluetooth bt_tool scan module to const 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 --- tools/async/scan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/async/scan.c b/tools/async/scan.c index ce6ff42a8..2442c9f96 100644 --- a/tools/async/scan.c +++ b/tools/async/scan.c @@ -34,7 +34,7 @@ static int dump_scan_cmd(void* handle, int argc, char* argv[]); static bt_scanner_t* g_scanner = NULL; -static struct option scan_options[] = { +static const struct option scan_options[] = { { "type", required_argument, 0, 't' }, { "phy", required_argument, 0, 'p' }, { "mode", required_argument, 0, 'm' }, @@ -43,7 +43,7 @@ static struct option scan_options[] = { { 0, 0, 0, 0 } }; -static bt_command_t g_scanner_async_tables[] = { +static const bt_command_t g_scanner_async_tables[] = { { "start", start_scan_cmd, 0, "start scan\n" "\t -t or --type, le scan type (0: passive, 1: active)\n" "\t -p or --phy, le scan phy (1M/2M/Coded)\n" @@ -226,7 +226,7 @@ int scan_command_exec_async(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table_offset(handle, g_scanner_async_tables, + ret = execute_command_in_table_offset(handle, (bt_command_t *)g_scanner_async_tables, ARRAY_SIZE(g_scanner_async_tables), argc, argv, 0); From 694820a01f4cf6a5c1bfc5cfa8cf4113405a77e5 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 09:44:29 +0800 Subject: [PATCH 23/29] 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_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 --- tools/bt_tools.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/bt_tools.c b/tools/bt_tools.c index 50cb9df1e..34b0e4646 100644 --- a/tools/bt_tools.c +++ b/tools/bt_tools.c @@ -111,7 +111,7 @@ static struct option main_options[] = { { 0, 0, 0, 0 } }; -static struct option le_conn_options[] = { +static const struct option le_conn_options[] = { { "addr", required_argument, 0, 'a' }, { "type", required_argument, 0, 't' }, { "defaults", no_argument, 0, 'd' }, @@ -150,7 +150,7 @@ static struct option le_conn_options[] = { #define SET_LE_PHY_USAGE "set le tx and rx phy, params: (0:1M, 1:2M, 2:CODED)" -static bt_command_t g_cmd_tables[] = { +static const bt_command_t g_cmd_tables[] = { { "enable", enable_cmd, 0, "enable stack" }, { "disable", disable_cmd, 0, "disable stack" }, { "state", get_state_cmd, 0, "get adapter state" }, @@ -250,7 +250,7 @@ static bt_command_t g_cmd_tables[] = { #define SET_CLASS_USAGE "params: , range in 0x0-0xFFFFFC, the 2 least significant shall be 0b00, example: 0x00640404" #define SET_SCANPARAMS_USAGE "set scan parameters, params: (0: INQUIRY, 1: PAGE), (0: standard, 1: interlaced), (range in 18-4096), (range in 17-4096)" -static bt_command_t g_set_cmd_tables[] = { +static const bt_command_t g_set_cmd_tables[] = { { "scanmode", set_scanmode_cmd, 0, "params: (0:none, 1:connectable 2:connectable&discoverable)" }, { "iocap", set_iocap_cmd, 0, SET_IOCAP_USAGE }, { "le_iocap", set_le_iocap_cmd, 0, SET_IOCAP_USAGE }, @@ -267,7 +267,7 @@ static bt_command_t g_set_cmd_tables[] = { //{ "", , "set " }, }; -static bt_command_t g_get_cmd_tables[] = { +static const bt_command_t g_get_cmd_tables[] = { { "scanmode", get_scanmode_cmd, 0, "get adapter scan mode" }, { "iocap", get_iocap_cmd, 0, "get adapter io capability" }, { "le_iocap", get_le_iocap_cmd, 0, "get adapter le io capability" }, @@ -285,7 +285,7 @@ static bt_command_t g_get_cmd_tables[] = { #define PAIR_PASSKEY_USAGE "input ssp passkey, params: (0:BLE, 1:BREDR)(0 :reject, 1: accept)" #define PAIR_CONFIRM_USAGE "set ssp confirmation, params: (0:BLE, 1:BREDR)(0 :reject, 1: accept)" -static bt_command_t g_pair_cmd_tables[] = { +static const bt_command_t g_pair_cmd_tables[] = { { "auto", pair_set_auto_cmd, 0, "enable pair auto reply, params: (0:disable, 1:enable)" }, { "reply", pair_reply_cmd, 0, "reply the pair request, params: (0 :reject, 1: accept)" }, { "pin", pair_set_pincode_cmd, 0, "input pin code, params: (0 :reject, 1: accept)" }, @@ -554,7 +554,7 @@ static int set_adapter_cmd(void* handle, int argc, char** argv) return CMD_PARAM_NOT_ENOUGH; } - int ret = execute_command_in_table(handle, g_set_cmd_tables, ARRAY_SIZE(g_set_cmd_tables), argc, argv); + int ret = execute_command_in_table(handle, (bt_command_t *)g_set_cmd_tables, ARRAY_SIZE(g_set_cmd_tables), argc, argv); if (ret != CMD_OK) set_usage(); @@ -568,7 +568,7 @@ static int get_adapter_cmd(void* handle, int argc, char** argv) return CMD_PARAM_NOT_ENOUGH; } - int ret = execute_command_in_table(handle, g_get_cmd_tables, ARRAY_SIZE(g_get_cmd_tables), argc, argv); + int ret = execute_command_in_table(handle, (bt_command_t *)g_get_cmd_tables, ARRAY_SIZE(g_get_cmd_tables), argc, argv); if (ret != CMD_OK) get_usage(); @@ -871,7 +871,7 @@ static int pair_cmd(void* handle, int argc, char** argv) return CMD_PARAM_NOT_ENOUGH; } - int ret = execute_command_in_table(handle, g_pair_cmd_tables, ARRAY_SIZE(g_pair_cmd_tables), argc, argv); + int ret = execute_command_in_table(handle, (bt_command_t *)g_pair_cmd_tables, ARRAY_SIZE(g_pair_cmd_tables), argc, argv); if (ret != CMD_OK) pair_usage(); From cbd719e4dbdb9f083a566341a75f3beb4b017b33 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 09:51:50 +0800 Subject: [PATCH 24/29] Memory Optimization: Change the bluetooth bt_tool gatt client module to const for reduce the ram size. bug:v/84970 Rootcause: To reduce RAM resource consumption, the `g_gattc_tables`, `gattc_cbs`, in the bt_tools 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 --- tools/gatt_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/gatt_client.c b/tools/gatt_client.c index addd1e999..77efa9274 100644 --- a/tools/gatt_client.c +++ b/tools/gatt_client.c @@ -68,7 +68,7 @@ static volatile uint32_t throughtput_cursor = 0; } \ } -static bt_command_t g_gattc_tables[] = { +static const bt_command_t g_gattc_tables[] = { { "create", create_cmd, 0, "\"create gatt client :\"" }, { "delete", delete_cmd, 0, "\"delete gatt client :\"" }, { "connect", connect_cmd, 0, "\"connect remote device :
[addr type(0:public,1:random,2:public_id,3:random_id)]\"" }, @@ -678,7 +678,7 @@ static void conn_param_updated_callback(void* conn_handle, bt_status_t status, u status, connection_interval, peripheral_latency, supervision_timeout); } -static gattc_callbacks_t gattc_cbs = { +static const gattc_callbacks_t gattc_cbs = { sizeof(gattc_cbs), connect_callback, disconnect_callback, @@ -708,7 +708,7 @@ static int create_cmd(void* handle, int argc, char* argv[]) return CMD_OK; } - if (bt_gattc_create_connect(handle, &g_gattc_devies[conn_id].handle, &gattc_cbs) != BT_STATUS_SUCCESS) + if (bt_gattc_create_connect(handle, &g_gattc_devies[conn_id].handle, (gattc_callbacks_t *)&gattc_cbs) != BT_STATUS_SUCCESS) return CMD_ERROR; PRINT("create connection success, conn_id: %d", conn_id); @@ -752,7 +752,7 @@ int gattc_command_exec(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_gattc_tables, ARRAY_SIZE(g_gattc_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_gattc_tables, ARRAY_SIZE(g_gattc_tables), argc, argv); if (ret < 0) usage(); From 61992117de3517ca19cc97e1efc3d283b339a6f0 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 13:52:58 +0800 Subject: [PATCH 25/29] Memory Optimization: Change the bluetooth bt_tool gatt server module to const for reduce the ram size. bug:v/84971 Rootcause: To reduce RAM resource consumption, the `s_dis_attr_db`, `s_bas_attr_db`, `s_iot_attr_db`, `g_gatts_tables` in the bt_tools gatt server 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 --- tools/gatt_server.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/gatt_server.c b/tools/gatt_server.c index 38f5f22b2..58418da34 100644 --- a/tools/gatt_server.c +++ b/tools/gatt_server.c @@ -205,7 +205,7 @@ const uint8_t pnp_id[7] = { 0x00, 0x01 // pnp_ver }; -static gatt_attr_db_t s_dis_attr_db[] = { +static const gatt_attr_db_t s_dis_attr_db[] = { GATT_H_PRIMARY_SERVICE(BT_UUID_DECLARE_16(0x180A), DIS_SERVICE_ID), GATT_H_CHARACTERISTIC_AUTO_RSP(BT_UUID_DECLARE_16(0x2A24), GATT_PROP_READ, GATT_PERM_READ, (uint8_t*)model_number_str, sizeof(model_number_str), DIS_MODEL_NUMBER_CHR_ID), GATT_H_CHARACTERISTIC_AUTO_RSP(BT_UUID_DECLARE_16(0x2A29), GATT_PROP_READ, GATT_PERM_READ, (uint8_t*)manufacturer_name_str, sizeof(manufacturer_name_str), DIS_MANUFACTURER_NAME_CHR_ID), @@ -213,24 +213,24 @@ static gatt_attr_db_t s_dis_attr_db[] = { }; static gatt_srv_db_t s_dis_service_db = { - .attr_db = s_dis_attr_db, + .attr_db = (gatt_attr_db_t *)s_dis_attr_db, .attr_num = sizeof(s_dis_attr_db) / sizeof(gatt_attr_db_t), }; static uint8_t battery_level = 100U; -static gatt_attr_db_t s_bas_attr_db[] = { +static const gatt_attr_db_t s_bas_attr_db[] = { GATT_H_PRIMARY_SERVICE(BT_UUID_DECLARE_16(0x180F), BAS_SERVICE_ID), GATT_H_CHARACTERISTIC_AUTO_RSP(BT_UUID_DECLARE_16(0x2A19), GATT_PROP_READ | GATT_PROP_NOTIFY, GATT_PERM_READ, &battery_level, sizeof(battery_level), BAS_BATTERY_LEVEL_CHR_ID), GATT_H_CCCD(GATT_PERM_READ | GATT_PERM_WRITE, tx_char_ccc_changed, BAS_BATTERY_LEVEL_CHR_CCC_ID), }; static gatt_srv_db_t s_bas_service_db = { - .attr_db = s_bas_attr_db, + .attr_db = (gatt_attr_db_t *)s_bas_attr_db, .attr_num = sizeof(s_bas_attr_db) / sizeof(gatt_attr_db_t), }; -static gatt_attr_db_t s_iot_attr_db[] = { +static const gatt_attr_db_t s_iot_attr_db[] = { /* Private IOT Service - 0xFF00 */ GATT_H_PRIMARY_SERVICE(BT_UUID_DECLARE_16(0xFF00), IOT_SERVICE_ID), /* Private Characteristic for TX - 0xFF01 */ @@ -250,11 +250,11 @@ static gatt_attr_db_t s_iot_attr_db[] = { }; static gatt_srv_db_t s_iot_service_db = { - .attr_db = s_iot_attr_db, + .attr_db = (gatt_attr_db_t *)s_iot_attr_db, .attr_num = sizeof(s_iot_attr_db) / sizeof(gatt_attr_db_t), }; -static bt_command_t g_gatts_tables[] = { +static const bt_command_t g_gatts_tables[] = { { "register", register_cmd, 0, "\"register gatt service(DIS = 1, BAS = 2, CUSTOM = 3) :\"" }, { "unregister", unregister_cmd, 0, "\"unregister gatt service :\"" }, { "start", start_cmd, 0, "\"start gatt service :\"" }, From 0351f851421c6d95ea5628a63d045892ea56bb57 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 13:58:20 +0800 Subject: [PATCH 26/29] Memory Optimization: Change the bluetooth bt_tool hfp ag module to const for reduce the ram size. bug:v/84972 Rootcause: To reduce RAM resource consumption, the `g_hfp_ag_tables`, in the bt_tools hfp ag 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 --- tools/hfp_ag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/hfp_ag.c b/tools/hfp_ag.c index 8e64cc66a..867278fa5 100644 --- a/tools/hfp_ag.c +++ b/tools/hfp_ag.c @@ -34,7 +34,7 @@ static int stop_voice_recognition_cmd(void* handle, int argc, char* argv[]); static int send_at_cmd_cmd(void* handle, int argc, char* argv[]); static int send_vendor_result_cmd(void* handle, int argc, char* argv[]); -static bt_command_t g_hfp_ag_tables[] = { +static const bt_command_t g_hfp_ag_tables[] = { { "connect", connect_cmd, 0, "\"establish hfp SLC connection , params:
\"" }, { "disconnect", disconnect_cmd, 0, "\"disconnect hfp SLC connection , params:
\"" }, { "connectaudio", connect_audio_cmd, 0, "\"establish hfp SCO connection , params:
\"" }, @@ -326,7 +326,7 @@ int hfp_ag_command_exec(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_hfp_ag_tables, ARRAY_SIZE(g_hfp_ag_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_hfp_ag_tables, ARRAY_SIZE(g_hfp_ag_tables), argc, argv); if (ret < 0) usage(); From cc3f6e4fc05bf7e852fa8390cc4ef06bf203d726 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 14:05:17 +0800 Subject: [PATCH 27/29] Memory Optimization: Change the bluetooth bt_tool hfp hf module to const for reduce the ram size. bug:v/84973 Rootcause: To reduce RAM resource consumption, the `g_hfp_tables`, in the bt_tools hfp hf 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 --- tools/hfp_hf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/hfp_hf.c b/tools/hfp_hf.c index f8f045dcd..a7a85d70b 100644 --- a/tools/hfp_hf.c +++ b/tools/hfp_hf.c @@ -78,7 +78,7 @@ static int get_subscriber_number(void* handle, int argc, char* argv[]); "\t\t\t1: CONNECTION_POLICY_FORBIDDEN \n" \ "\t\t\t2: CONNECTION_POLICY_UNKNOWN \n" -static bt_command_t g_hfp_tables[] = { +static const bt_command_t g_hfp_tables[] = { { "connect", connect_cmd, 0, "Establish hfp SLC connection params:
" }, { "disconnect", disconnect_cmd, 0, "Disconnect hfp SLC connection params:
" }, { "policy", set_policy_cmd, 0, SET_POLICY_USAGE }, @@ -595,7 +595,7 @@ int hfp_hf_command_exec(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_hfp_tables, ARRAY_SIZE(g_hfp_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_hfp_tables, ARRAY_SIZE(g_hfp_tables), argc, argv); if (ret < 0) usage(); From c752bd4be3022325e0dab2b9739ead38aacf3d85 Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 14:14:01 +0800 Subject: [PATCH 28/29] Memory Optimization: Change the bluetooth bt_tool hid device module to const for reduce the ram size. bug:v/84974 Rootcause: To reduce RAM resource consumption, the `g_hidd_tables`, in the bt_tools hid device 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 --- tools/hid_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/hid_device.c b/tools/hid_device.c index 556cb7969..d8e5ff5a1 100644 --- a/tools/hid_device.c +++ b/tools/hid_device.c @@ -31,7 +31,7 @@ static int send_consumer_cmd(void* handle, int argc, char* argv[]); static int unplug_cmd(void* handle, int argc, char* argv[]); static int dump_cmd(void* handle, int argc, char* argv[]); -static bt_command_t g_hidd_tables[] = { +static const bt_command_t g_hidd_tables[] = { { "register", register_cmd, 0, "\"register HID app: (1:KEYBOARD, 2:MOUSE, 3:KBMS_COMBO) (0:BLE, 1:BREDR)\"" }, { "unregister", unregister_cmd, 0, "\"unregister HID app \"" }, { "connect", connect_cmd, 0, "\"connect HID host param:
\"" }, @@ -565,7 +565,7 @@ int hidd_command_exec(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_hidd_tables, ARRAY_SIZE(g_hidd_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_hidd_tables, ARRAY_SIZE(g_hidd_tables), argc, argv); if (ret < 0) usage(); From bd6b9c3e06b7f3f1ba44dfc9a8d01a55e09a291f Mon Sep 17 00:00:00 2001 From: huangyulong3 Date: Wed, 4 Feb 2026 14:42:17 +0800 Subject: [PATCH 29/29] Memory Optimization: Change the bluetooth bt_tool log module to const for reduce the ram size. bug:v/84975 Rootcause: To reduce RAM resource consumption, the `g_log_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 --- tools/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/log.c b/tools/log.c index 21dfe099e..1c842e069 100644 --- a/tools/log.c +++ b/tools/log.c @@ -50,7 +50,7 @@ static int unfilter_cmd(void* handle, int argc, char* argv[]); static int unmask_cmd(void* handle, int argc, char* argv[]); static int level_cmd(void* handle, int argc, char* argv[]); -static bt_command_t g_log_tables[] = { +static const bt_command_t g_log_tables[] = { { "enable", enable_cmd, 0, "\"Enable param: (\"snoop\" or \"stack\")\"" }, { "disable", disable_cmd, 0, "\"Disable param: (\"snoop\" or \"stack\")\"" }, { "mask", mask_cmd, 0, "\"Enable Stack Profile & Protocol Log \"\n" @@ -243,7 +243,7 @@ int log_command(void* handle, int argc, char* argv[]) int ret = CMD_USAGE_FAULT; if (argc > 0) - ret = execute_command_in_table(handle, g_log_tables, ARRAY_SIZE(g_log_tables), argc, argv); + ret = execute_command_in_table(handle, (bt_command_t *)g_log_tables, ARRAY_SIZE(g_log_tables), argc, argv); if (ret < 0) usage();