Auto pts fix#584
Open
expliyh wants to merge 903 commits into
Open
Conversation
… an asynchronous API. bug: v/81682 When priv dynamically allocates memory successfully but fails later due to other reasons before reaching the assignment ins->priv = priv;, the memory allocated to priv cannot be freed in bt_socket_async_client_deinit, leading to a resource leak. Signed-off-by: jialu <jialu@xiaomi.com>
…se functions bug: v/80811 Rootcause: In certain scenarios, users of `euv_pipe` must ensure all UV requests have completed execution before releasing resources. Consequently, it is necessary to notify users that `euv_pipe` has been fully released after its close operation is completed, thereby permitting subsequent operational procedures to proceed. Support for the close callback has therefore been added. Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
…e callback bug: v/80808 Rootcause: In high-throughput reception scenarios, situations may arise where the `write_cb` for SPP data transmission to the application has not yet completed, yet the SPP device is released due to an abrupt disconnection, thereby preventing notification to the protocol stack that data reception has concluded. To circumvent this issue, it is imperative to ensure all write operations are finalised before releasing the SPP device. Consequently, an `euv_pipe` close callback implementation has been introduced to guarantee that all `write_cb` operations execute successfully prior to severing the data pathway. Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
bug: v/74709
only open CONFIG_BLUETOOTH_AVRCP_CONTROL or CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME can build in bt_avrcp_control_notification_cb.
error: 'bt_avrcp_info_find_by_ct' undeclared (first use in this function); did you mean 'bt_avrcp_info_find_by_tg'?
1501 | avrcp_info = bt_list_find(bt_avrcp_conn, bt_avrcp_info_find_by_ct, ct);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| bt_avrcp_info_find_by_tg
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/82095 The spp_connect_handler was attempting to look up the SPP connection by rfcomm_dlc before it was added to the connection list, causing "SPP connection not found for rfcomm_dlc" error. Root Cause: The connection object wasn't in the global connection list at the time of lookup, making spp_find_connection_by_dlc() always fail. Fix: Pass the spp_conn pointer directly as user_data to avoid the lookup, and add it to the connection list after successful initialization. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/81925 Add a generic descriptor allocation path, matching alloc_characteristic() style. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/81958 Some services are marked with GATT_PROP_EXPOSED_OVER_BREDR, but current not implement gatt over bredr. As a temporary workaround, clear this flag when calling add_service() so the service is exposed over BLE. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/82081 `bt_le_scan.h` is a globally exposed header file. Then, Zephyr's `#include <zephyr/bluetooth/bluetooth.h>` is declared as a private inclusion of Zephyr in CMake. However, the problem is that when third-party apps use my global `bt_le_scan.h`, the CMake system doesn't know where `zephyr/bluetooth/bluetooth.h` is and throws an error. One solution is for the third-party app to also declare a private inclusion of Zephyr in CMake, but this doesn't conform to design principles. The app only needs to be concerned with my framework layer. If the app also needs to include Zephyr's header files, then the framework layer is not properly configured. Therefore, `zephyr/bluetooth/bluetooth.h` must not be explicitly included in `bt_le_scan`. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/82104 The number of gatts sal DB attributes was insufficient for miwear's needs, so it was increased to a margin of 60. Future memory optimization projects will no longer maintain static arrays. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/81701 Rootcause: dereference null. Signed-off-by: Yuheng Li <liyuheng@xiaomi.com>
bug: v/81701 Rootcause: unnecessary malloc Signed-off-by: YuhengLi <liyuheng@xiaomi.com>
bug: v/81924 By default, just working (no I/O) should automatically accept user confirmation, but for compatibility with the watch app, app confirmation is required. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/59050 Rootcause:When reconnect to the headset during a call, the headset will obtain the call status through the cind command. Since Vela does not have modem, the status will be error. So, get cind from Android. Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
bug: v/61170 Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
bug: v/81520 In `spp_find_connection_by_sdp_param` and `spp_connect_with_uuid`, the pointer `spp_conn` was dereferenced before the NULL check. This patch ensures the pointer is validated before access to avoid potential crashes. Signed-off-by: v-yichenxi <v-yichenxi@xiaomi.com>
bug: v/82928 Remove the redundant stack variable bd_addr, which already exists in sal_conn. Signed-off-by: YuhengLi <liyuheng@xiaomi.com>
bug: v/82928 Rootcause: bt_sal_get_remote_address may fail Signed-off-by: YuhengLi <liyuheng@xiaomi.com>
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
support. bug: v/65087 Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
…global database hash. bug :v/65095 The logic is implemented in gatts_service.c to trigger hash calculation and return the result via a registered callback, for trusted device sync and DB change tracking. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
…h from adapter to profile. bug: v/65126 Root cause: Adapter had no generic message path to deliver events to profile services. GATTS could not receive a request to fetch the server database hash. Add adapter handler to forward profile_msg_t to service_manager. Add PROFILE_EVT_GATTS_REQUEST_DB_HASH and handle it in gatts_service via process_msg. Wire bt_sal_gatt_server_get_database_hash() call when the event is received. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65129 Root cause: The stack did not compute and store the server GATT database hash on initial bonding. Peers could keep a stale GATT cache because no hash update was triggered. When a bonded LE device is connected, send PROFILE_EVT_GATTS_REQUEST_DB_HASH. Force hash update to start cache sync for the new bond. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65131 There was no persistent storage for the server GATT database hash. The system could not compare hashes after reboot and peers could keep a stale GATT cache. Add remote_device_gatt_properties_t with 16-byte hash field. Add save/load APIs for GATT hash cache using the uv_db backend (BT_KEY_BLEGATTHASH). Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65135 KVDB backend had no key and no save/load path for GATT server database hash. The system could not restore the hash after reboot and cache validation failed. Add BT_KVDB_BLEGATTDBHASH and helpers to save/load remote_device_gatt_properties_t entries. Count and delete old hash properties before saving new data. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65139 The device object had no field to keep the GATT database hash. The stack could not persist and validate GATT cache state per bonded peer. Add a 16-byte gatt_hash field under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Add get/set/delete helpers and export remote_device_gatt_properties_t data. Add DFLAG_GATT_HASH_VALID to mark hash presence. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65142 Adapter did not load or persist the per-device GATT database hash state. After reboot or unpair, the stack lost hash data and cache validation became unreliable. Load GATT hash entries on LE enable and restore them into device objects. Save updated hash list when bond state changes and clear hash on unpair. Use bt_storage_load_gatt_cache_device and bt_storage_save_gatt_cache_device under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
as gatts_service. bug: v/65146 gatts_service could not access the adapter device database to read or update the stored GATT database hash. Hash update and persistence were handled inside adapter_service only, so other modules could not drive cache sync. Add adapter_get_device_gatt_hash() and adapter_set_device_gatt_hash() under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Only allow bonded devices and keep a zero hash when no valid hash is present. Avoid duplicate db hash requests when DFLAG_GATT_HASH_VALID is already set. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65160 The server did not track the peer-synced GATT database hash. Peers could keep a stale GATT cache and the stack could not detect a database change. Request the latest database hash on GATT connection. On hash event, compare with the stored value and decide the next action. Update the stored hash after handling the event. Compile the feature under CONFIG_BLUETOOTH_GATTS_CACHE_SUPPORT. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65182 Add bt_sal_gatt_server_change_indicate(start_hdl, end_hdl) with parameter validation. Use the new SAL API from gatts_service when a hash mismatch is detected. Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
bug: v/65203 Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
❌ CLA Signature Required@expliyh Some contributors need to sign the CLA:
Please:
📋 View detailed check results: Action Run #25536010077 💡 Tip: All contributors must sign the CLA before the PR can be merged. |
Add z_bt_hfp_connect_acl() that establishes BR/EDR ACL connection without initiating RFCOMM/SLC. It initializes HFP callbacks and delegates to z_bt_conn_create() for the ACL connection. This supports PTS test cases where the Lower Tester is the RFCOMM initiator (e.g. HFP/HF/SLC/BV-08-C). Signed-off-by: liyuheng <liyuheng@xiaomi.com>
Add z_bt_hfp_connect_audio() and z_bt_hfp_disconnect_audio() that map to bt_hfp_hf_connect_audio() and bt_hfp_hf_disconnect_audio() Framework APIs. Also add audio_state_cb to the HFP callback registration to forward audio state changes to bttester. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
Revert the bt_device_disconnect() call in conn_disconnect_in_ipc. Calling bt_device_disconnect() for BR/EDR causes a data abort crash in bt_conn_lookup_addr_br_mc when the connection is subsequently re-established. Keep using bt_device_disconnect_le() only for now. The BR/EDR disconnect via gap_unpair needs a different approach. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
Add z_bt_hfp_terminate_call() which calls bt_hfp_hf_terminate_call() in the framework layer. This properly terminates active/dialing/alerting calls, as opposed to reject which is meant for incoming calls. bug: v/0 Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/none Rootcause: In HF_CONTROL_CALL event handler, bt_sal_hfp_hf_call_control() was called with hardcoded index=0 instead of reading data->valueint2. This caused AT+CHLD=1<idx> (release specific call) and AT+CHLD=2<idx> (private consultation mode) to always send index 0, failing ECC PTS test cases that require operating on a specific call by index. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/none Add missing z_api source files for BR/EDR profiles (a2dp, avrcp, hfp, pan, spp, hid) to CMakeLists.txt, and link zblue headers target for Zephyr BT type definitions. Required for bttester to resolve HFP and other BR/EDR profile symbols. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/000000 Rootcause: Pre-SLC calls set global CIND indicators but were never added to SAL's per-connection call list. When the call terminated, SAL could not find the call object, so no +CIEV:call,0 was sent to PTS, causing timeout and FAIL verdict. Fix by adding global indicator tracking for CIND response, passing call/callsetup/callheld indicators through SAL, and adding a fallback path in do_ag_call_op to clear indicators for untracked pre-SLC calls. Also adds z_api_hfp_ag bridge layer for bttester AG commands and increases AG timeout to 30s. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/0 Rootcause: unpair_in_ipc only called bt_device_remove_bond with BT_TRANSPORT_BLE, leaving BR/EDR link keys intact. This caused authentication failures when reconnecting to PTS after a previous test case, as the stale BR/EDR link key no longer matched. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/0 Add BT_LOGI level logging to bt_sal_try_profile_connect and bt_sal_trigger_profile_conn_act to aid debugging HFP connection establishment issues. Previously all logs were BT_LOGD (DEBUG) which was not visible at default log level. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/0 Rootcause: When AG_DISCONNECT event was received in the connecting state, the state machine did nothing (only a comment 'handle ?'). This left the AG in connecting state indefinitely. Fix by calling bt_sal_hfp_ag_disconnect and transitioning to disconnected state. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/0 HF changes: - Refactor zblue callbacks to use do_in_service_loop dispatch for thread safety (connected, disconnected, SCO, call events) - Add pre-SLC security request in do_hf_sdp_discover to avoid ACL disconnect/reconnect during RFCOMM pairing - Add post-SLC AT command init (VGM, VGS, CMEE, COPS, CLIP, CCWA) AG changes: - Add connection manager integration for AG profile connect/disconnect - Add SDP discovery and SLC connect flow for AG outgoing connections - Add SCO connected/disconnected handlers with proper SAL tracking Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/000000 Rootcause: When HF sends AT+BAC mid codec negotiation (e.g. only CVSD after AG has already sent +BCS:2 for mSBC), zblue notifies SAL via codec_negotiate(err=-EAGAIN, codec=0) to indicate the codec connection must be restarted. The previous handler only updated preferred_codec and re-emitted codec_changed, which left the HFP AG state machine stuck in AudioConnecting without ever sending a new +BCS. PTS then disconnects the ACL after 60s, failing tests such as HFP/AG/ACC/BI-14-C. Upon -EAGAIN, invoke bt_hfp_ag_audio_connect again with the new preferred codec (CVSD fallback) so zblue emits +BCS:<new_codec> and the SCO setup completes. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/000000 Rootcause: HCI packet reception was polled from the bluetoothd service_loop (libuv single-threaded event loop). When any handler on that loop called bt_hci_cmd_send_sync() (e.g. HFP AG state machine issuing HCI 0x0406 Disconnect or 0x0428 Setup Synchronous Connection), the thread blocked on the command-complete semaphore while libuv could not re-enter poll() to dispatch the very HCI Command Status/Complete the caller was waiting for. The waiter always hit the full 10s HCI command timeout, surfacing as 'Controller unresponsive' and stalling profiles that issue synchronous HCI commands from the service loop. Spawn a dedicated pthread (bt_hci_rx) that owns the HCI fd. It runs a simple poll loop and calls the same bt_sal_hci_transport_recv() to feed zblue via h4->recv. Priority HCI events (CMD_COMPLETE/CMD_STATUS) are processed synchronously inside bt_recv_unsafe() on this RX thread and post the semaphore, so bt_hci_cmd_send_sync() completes regardless of what bluetoothd is doing. Non-priority events continue to be queued to the bluetooth workqueue as before. The RX thread joins cleanly in h4_close via rx_thread_running flag with a 500ms poll tick so shutdown does not stall. The stale service_poll_t* hci_handle global and the service_loop_poll_fd call are removed. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
…AL_TELEPHONY bug: v/0 Wrap tele_service_*() calls in the AG state machine with #ifdef CONFIG_BLUETOOTH_HFP_AG_LOCAL_TELEPHONY so that builds without a telephony backend (e.g. AutoPTS testing) can compile and run without pulling in phone-service dependencies. Affected paths: answer_call, reject_call, hangup_call, dial_number, call_control, cops_request, get_current_calls, and is_virtual_call_allowed. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
…_at_reply bug: v/0 Implement AT+BLDN (last-number redial) handling for the HFP AG profile with an asynchronous callback design: - HF sends AT+BLDN -> AG sets pending_bldn, notifies application via redial_req_cb asynchronously - Application responds via bt_hfp_ag_redial_response(result, number): OK -> AG emits "OK" + number via dial_at_reply; application then drives call state via phone_state_change(DIALING) ERROR -> AG emits "+CME ERROR:22" - When LOCAL_TELEPHONY is enabled, the AG queries tele_service directly for the last-dialed number (synchronous path unchanged) Separate bt_hfp_ag_dial_response() handles plain ATD async reply path, and the underlying SAL/zblue interface bt_sal_hfp_ag_dial_at_reply() (renamed from bldn_reply) serves both ATD and BLDN paths uniformly. Key changes: - Add AG_STACK_EVENT_REDIAL_REQUEST, AG_REDIAL_RESULT events - Add g_last_dialed_number cache + tele_service_get_last_dialed_number() - Add bt_sal_hfp_ag_dial_at_reply() (renamed from bldn_reply) - Add hfp_ag_redial_req_callback typedef + redial_req_cb field - Add bt_hfp_ag_dial_response() and bt_hfp_ag_redial_response() APIs with IPC path - Implement redial callback in zblue SAL layer; memory_dial stays -ENOTSUP (no persistent phonebook) - Replace z_api dial_response stub with real implementation Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/0 When CONFIG_BLUETOOTH_HFP_AG_LOCAL_TELEPHONY is not set, the AG service cannot handle AT+CHLD, AT+VTS, AT+NREC, and AT+COPS internally. Add new callback types to hfp_ag_callbacks_t so the application (e.g. AutoPTS agent via BTP) can receive and respond to these commands. - Add hfp_ag_call_control_callback, hfp_ag_dtmf_callback, hfp_ag_nrec_req_callback, hfp_ag_cops_req_callback typedefs - Add ag_service_notify_call_control/dtmf/nrec_req/cops_req - Forward events from state machine to service layer - Add socket IPC forwarders and client-side dispatch - Register BTP callbacks in z_port for AutoPTS integration Signed-off-by: liyuheng <liyuheng@xiaomi.com>
bug: v/0 Rootcause: Z_API(bt_hfp_ag_get_conn) already increments the ACL ref count internally, but zblue_on_ag_get_ongoing_call called bt_conn_ref again on the returned conn. The handler only unrefs once, so each ongoing-call callback (triggered on SLC setup for AG cases) leaked one ACL ref. After the first AG test case exits, the leaked ref keeps the ACL bt_conn slot in BT_CONN_DISCONNECTED state, so the next test that needs the IUT to initiate an ACL connection is rejected by bt_conn_create_br_mc (existing conn in wrong state). This matches the observed failure when running AG cases back-to-back without restarting QEMU (e.g. HFP/AG/ACC/BV-18-C followed by HFP/AG/ATA/BV-01-C). Remove the redundant bt_conn_ref; the existing bt_conn_unref in ag_get_ongoing_call_handler now correctly balances the ref returned by bt_hfp_ag_get_conn. Signed-off-by: liyuheng <liyuheng@xiaomi.com>
❌ CLA Signature Required@expliyh Some contributors need to sign the CLA:
Please:
📋 View detailed check results: Action Run #25552220717 💡 Tip: All contributors must sign the CLA before the PR can be merged. |
❌ CLA Signature Required@expliyh Some contributors need to sign the CLA:
|
bug: v/0 Rootcause: bt_sal_hfp_ag_connect called bt_conn_set_security(conn, BT_SECURITY_L2) right after the ACL link was established and before starting SDP discovery. The intent was to complete bonding in parallel with SDP so RFCOMM would find an already-authenticated link. The side effect is that the IUT issues HCI_Authentication_Requested proactively. In a scenario where the IUT local bond was cleared (e.g. AutoPTS unpairs between iterations with HCI Delete_Stored_Link_Key) while the peer still holds the old link key, this leads to: IUT: Authentication_Requested -> peer: Link_Key_Request reply with old key -> IUT controller: Link_Key_Request event to host -> IUT host: no key, sends Link_Key_Negative_Reply -> SSP mismatch, HCI_Simple_Pairing_Complete status != 0 -> zblue bt_hci_ssp_complete calls bt_conn_disconnect(AUTH_FAIL) -> ACL dropped, AG connect times out -> INDCSV. Reproducible on HFP/AG/ECS/BV-01-C (and other cases) when running back-to-back after any prior iteration that bonded once, without restarting QEMU. Remove the explicit set_security call: let RFCOMM drive authentication when it issues the channel connect. In that path, if the peer initiates SSP first (because it still has a key) zblue will respond correctly via the regular SSP flow and pairing completes cleanly. If the peer accepts without auth (no prior bond), RFCOMM just needs L1 and SDP already ran at L0, so there is no functional loss. Verified on HFP/AG/ECS/BV-01-C (previously INDCSV) and no regression on HFP/AG/ACC/BV-18-C (SCO case) or HFP/AG/ACS/BV-04-C (WBS+SCO). Signed-off-by: liyuheng <liyuheng@xiaomi.com>
Change-Id: I78f4e81eeed75b19a976fbc26faceb014303668b Signed-off-by: liyuheng <liyuheng@xiaomi.com>
Rootcause: Multiple AG PTS test failures due to: 1. Security level not set before SDP causing RFCOMM connect race 2. CCWA handler rejecting AT+CCWA when 3-way disabled 3. dial_response not sending proper error for memory dial failure 4. State machine ATD async error path using wrong AT reply function Changes: - Set bt_conn_set_security(L2) before SDP in do_ag_sdp_discover - Add suppress_auto_sco flag for HF-initiated SCO test cases - Remove 3-way call check from CCWA handler (mandatory per HFP spec) - Fix dial_response to send ERROR for failed memory dial - Fix state machine AG_DIALING_RESULT to use dial_response for errors - Fix compile error in bt_sal_hfp_ag_connect debug log Signed-off-by: liyuheng <liyuheng@xiaomi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Please adhere to Contributing Guidelines.
Summary
Update this section with information on why change is necessary,
what it exactly does and how, if new feature shows up, provide
references (dependencies, similar problems and solutions), etc.
Impact
Update this section, where applicable, on how change affects users,
build process, hardware, documentation, security, compatibility, etc.
Testing
Update this section with details on how did you verify the change,
what Host was used for build (OS, CPU, compiler, ..), what Target was
used for verification (arch, board:config, ..), etc. Providing build
and runtime logs from before and after change is highly appreciated.