Commit Graph

267 Commits

Author SHA1 Message Date
zhangyuan20 7f374b4c90 bluetooth: add android15 config control.
Rootcause: Some configurations are not enabled in Android 15 and require the addition of macro controls in Android 15.

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:53:23 +08:00
zhongzhijie1 977b6dea73 add ATTR_AUTO_RSP_CCC_READ to keep legacy GATT_H_CCCD behavior
rootcause:
Previously, CCC descriptors (defined by `GATT_H_CCCD`) would automatically respond to *read requests* within the stack, while forwarding all *write operations* (including write requests and write commands) to the application. This allowed the app to detect when a characteristic's notify/indicate status changed, without needing to implement `on_read_cb`.

During the Android BTIF porting, CCC read requests started being passed up to the application. This introduced compatibility issues for existing services that used `GATT_H_CCCD` without registering an `on_read_cb`, resulting in unhandled read responses.

To preserve backward compatibility, a new `rsp_type` value — `ATTR_AUTO_RSP_CCC_READ` — is introduced for `GATT_H_CCCD`. It restores the original behavior:

* Automatically respond to CCC descriptor read requests inside the stack
* Still forward write requests and write commands to the application via `on_write_cb`

This allows legacy services to continue functioning without modification.
Apps that require full control over both read and write (e.g. Android BTIF layer) should use `GATT_H_CCCD_USER_RSP`.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:53:22 +08:00
zhongzhijie1 17e21a0c5f support user response for descriptor read requests
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:53:22 +08:00
chejinxian1 fdcb56d71d L2CAP: Resolved the issue where the L2CAP Server was unable to accept new connections
Rootcause: There exists a specific scenario where an application may fail to correctly accept connections. In L2CAP multi-role, multi-connection scenarios, if an instance with ID 0 is released due to disconnection, subsequent connection events will utilise ID 0 for identification. Should the server accept a connection and adopt ID 0 as the new listen channel ID, the application will be unable to distinguish whether a new listen channel ID requires processing. This results in the application being unable to accept further L2CAP connection requests from peer devices.

Therefore, `INVALID_L2CAP_LISTEN_ID` is introduced to distinguish this scenario. When the Client connects, the default `new_listen_id` uses `INVALID_L2CAP_LISTEN_ID`, indicating that the application need not add a new listen channel; otherwise, it must.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +08:00
chejinxian1 65275b274c L2CAP: Update stop listen function to include transport parameter
Rootcause: The PSM employed by L2CAP in LE and BR/EDR contexts are not identical concepts. The LE scenario utilises a simplified PSM, whereas the BR/EDR scenario employs the standard PSM. These differ fundamentally in their allocation methods and are not interoperable.

Consequently, the current implementation of listen and stop listen operations requires distinguishing between connection types. Add a new API `bt_l2cap_stop_listen_with_transport` to support stop listen on BR/EDR PSM. This modification will rectify the error where `bt_l2cap_stop_listen` fails to recognise connection types, whilst filtering operations specific to the BR/EDR type.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:53 +08:00
Lu Jia c827f3e6b4 bluetooth: Fix compilation issues.
./frameworks/connectivity/bluetooth/framework/include/bt_avrcp_control.h:53:3: error: code should be clang-formatted [-Wclang-format-violations]

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:48 +08:00
zhangyuan20 bdc7984fd2 zephyr-pts: add register notification interface for avrcp ct
Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:52:48 +08:00
zhangyuan20 a86c6bb43c zephyr-pts: add get playback state interface for avrcp ct
Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:52:48 +08:00
zhangyuan20 4c52e8b14b zephyr-pts: add get subunit info interface for avrcp ct
Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:52:48 +08:00
zhangyuan20 8fbbd82849 zephyr-pts: add get unit info interface for avrcp ct
Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:52:48 +08:00
zhangyuan20 0a2f1a9344 zephyr-pts: add send passthrough cmd for avrcp ct
Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:52:48 +08:00
chejinxian1 c2f1db305a L2CAP: Enable L2CAP configuration.
Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:47 +08:00
chejinxian1 2ca1ce1c6a L2CAP: Add function to stop listening on a specific PSM.
Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:46 +08:00
chejinxian1 0706a8491f L2CAP: Refactor L2CAP API to support to multiple application and socket pipe.
Refactor L2CAP API to use handles instead of cookies for callback registration and management.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:46 +08:00
Kai Cheng ef7747f1c2 bluetooth: add gatt client and server config
add gatt client and server config.openvela:
35ed1ce372

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-20 14:52:43 +08:00
liuxiang18 bb834bba1e PTS: add pts property for dynamic control disconnect or not when pair failed.
Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:52:42 +08:00
zhongzhijie1 09c3c75c61 Support the signed write function, which requires BT_SIGNING micro to open.
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:42 +08:00
zhongzhijie1 3fa65f3169 Add API for limited Discovery.
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:42 +08:00
liuxiang18 4baa13a8d1 bluetooth: implement bt_device_set_bondable_le API to change bond mode.
Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:52:41 +08:00
liuxiang18 55147e63ba bluetooth: implement bt_device_set_security_level API to change bond security level.
Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:52:40 +08:00
liyuheng 45b7e64e16 Add new interface: hfp_hf_query_current_calls_with_callback.
Rootcause: Currently, when the bt_hfp_hf_query_current_calls interface receives a request, it retrieves the result from the state machine cache and returns it immediately. However, since the cache may not be updated in a timely manner, the returned data may not be the latest.

Signed-off-by: liyuheng <liyuheng@xiaomi.com>
2026-04-20 14:52:40 +08:00
chejinxian1 e1aa224828 bluetooth: Restrict the scope of use for `bt_oob_data_t`
Rootcause: The current definition of `bt_oob_data_t` conflicts with the Android Bluetooth. In practice, this type definition is restricted to internal service usage and is not currently exposed externally.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:52:40 +08:00
zhangyuan20 2ecaa0d81e Android-Vela:add cind interface for android
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>
2026-04-20 14:52:39 +08:00
zhangyuan20 2a46cb1ffa Android-Vela:add cnum interface for android
Rootcause: Adapt the cnum interface to obtain the virtual call mobile phone number.

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:52:39 +08:00
Lu Jia 0647f85b0f bluetooth: Fix the issue of failed GATTC deletion.
When deleting a GATTC instance, the Advanced API identifies clients based on their device address. If an application creates two GATTC instances with the same device address, and attempts to delete the second instance before the server has returned the asynchronous callback for the first deletion, both deletion operations will effectively target the same underlying GATTC instance due to the identical device address.

Signed-off-by: jialu <jialu@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:52:34 +08:00
zhongzhijie1 d8c0ed8abb Extend feature get-service callback to report service array
The original bt_gattc_feature_get_service_cb_t callback only returned a
single gatt_service_t pointer. This is insufficient for feature-layer
use cases that require receiving all discovered services at once.

This patch updates the callback signature by adding:

- const gatt_service_t *services[] : array of discovered service pointers
- size_t count                     : number of services in the array

This allows the feature layer to receive a batch of services in a single
notification and avoids repeated per-service callbacks.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:34 +08:00
Lu Jia 08b110ac5c bluetooth: Using macros to reduce boilerplate code in asynchronous callbacks.
Some processing logic in asynchronous callbacks is identical; extract this common code into a macro.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:34 +08:00
chejinxian1 060df83c75 Bluetooth: Enhance euv_pipe status management and add new status flags.
Rootcause: `uv_close` does not guarantee the order in which close callbacks run.
There is a case where `euv_pipe_close2` and `euv_pipe_close` are called in sequence: if the `uv_close` initiated by `euv_pipe_close` completes first and frees the `euv_pipe_t` instance, `euv_pipe_close2` must access the invaliad address during its execution.
Therefore, add a status flag to ensure the `euv_pipe_t` instance is freed safely.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:52:32 +08:00
liuxiang18 904d80778e bluetooth: fixed a use-after-free issue caused by ins->client_loop & ins have been released during worker execution.
When the client clears resources, if tasks are still executing in the worker thread at that time, it will lead to a use-after-free issue.

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:52:15 +08:00
chengkai 70c6e72aff bluetooth: add spp insecure feature
Signed-off-by: chengkai <chengkai@xiaomi.com>
2026-04-20 14:52:12 +08:00
zhongzhijie1 f64747b316 pm: add bt_cm_enable/disable_enhanced_mode for BR/EDR low-latency sniff
Add bt_cm_enable_enhanced_mode() and bt_cm_disable_enhanced_mode().
Support EM_BR_SNIFF_LOW_LATENCY and EM_BR_SNIFF_ULTRA_LOW_LATENCY.
They switch to lower sniff intervals for short-term low latency needs.
Disable API restores the default sniff parameters.

Note: idle timeout is not changed in current design. It may be extended in the future.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:12 +08:00
zhongzhijie1 e019ba426c scanners initiated by multiple apps, select the optimal scan parameters and filter policy.
rootcause: Originally, multiple scanners were not supported, and the new scanner could only passively monitor the scanning results of the old scanner. Now, the global optimal scanner will be selected, and when a scan fails, all scanners will be notified that the current scan has stopped. And free scanner resources.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:11 +08:00
zhongzhijie1 cfdd3e95f6 scan manager: Modify low power scan paremter from 160ms/ 2560ms to
15ms/ 600ms, set balanced paramter to 20 ms / 80 ms.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:11 +08:00
zhongzhijie1 5d146c323a Add api brief annotate info for 'bt_adapter_le_add_whitelist_with_type'.
Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:11 +08:00
zhongzhijie1 05a15ee027 bluetooth: add whitelist with type API to support specific BLE address type.
Whitelist with type API allows adding a BLE address with a specified address type to the whitelist. Note that each address can only have one address type, and the stack will auto handle merging of address type operations.

New API:
    bt_status_t BTSYMBOLS(bt_adapter_le_add_whitelist_with_type)(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t type);

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:11 +08:00
zhongzhijie1 d316c89c78 bluetooth:Support scan filter policy feature in bluetooth framework/service.
API user can pass scan policy refs in ble_scan_filter_type_t.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:10 +08:00
Lu Jia 0cca14cced ipc: trace async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:09 +08:00
zhongzhijie1 747b14d440 gattc/feature: add high-level GATT client, local DB, and async ops
Add feature-layer GATT client (gatt_client_t) wrapping low-level GATTC callbacks.
Build a local services DB from discovery (service/characteristic/descriptor).
Provide stable UUID handle lookups and helpers (service/char/desc finders).
Implement async read/write for characteristics and descriptors, notify subscribe/unsubscribe, and MTU exchange.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia cf1f9b4220 ipc: gattc async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia 69334cb53e ipc: le scan async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:08 +08:00
Lu Jia 295db704ae bluetooth: Fix compilation errors when calling Bluetooth in C++ files.
Root Cause: When a C++ file references a Bluetooth file, compilation errors occur due to the Bluetooth file using C++ keywords.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:07 +08:00
chejinxian1 d095fdbe87 SPP: Add SPP Proxy connection states to handle different events.
Rootcause: Since the SPP Proxy's state is closely tied to the SPP connection status, but socket-related operations make it impossible for the two to maintain full synchronization. When an SPP disconnection occurs, the server-side Proxy will be closed directly. If bt_client subsequently attempts to connect to the Proxy via Socket, there may be a thread blocking risk. Therefore, adding two states - SPP_PROXY_STATE_CONNECTING and SPP_PROXY_STATE_CLOSING - better describes the Proxy's status under different scenarios, enabling differentiated operations for handling disconnection events. In such risk scenarios, the SPP Proxy will enter the SPP_PROXY_STATE_CLOSING state to delay the closure of the Proxy, ensuring synchronization between the Proxy connection and SPP connection.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:06 +08:00
jialu d8076dc8f6 HFP: Adding vendor specific AT command process for AG
In order to implement the PTT function of headphone control, it is necessary to add the process of AG send and receive vendor specific AT commands.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:06 +08:00
zhongzhijie1 2ed8f967d8 [bug fix] When bt off is executed, disconnect all acl connections.
Originally, only the "adapter_disable" function was executed. An additional step was added before that, which disconnects all ACL connections. A timer was also started to wait for the "disconnect" event for 2 seconds, followed by cleaning up profile resources (by following the normal disable procedure).

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:04 +08:00
Lu Jia 1d7a5117e9 bluetooth: Add bluetooth_get_async_instance()
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:01 +08:00
Lu Jia 0e070754c0 ipc: le advertiser async api
Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:00 +08:00
chejinxian1 69c2dfb74f bttool: Remove the dependency of SPP on CONFIG_BLUETOOTH_SPP_RPMSG_NET in bttool.
Rootcause: The new euv_pipe_connect interface will automatically help the application select the socket connection method, without requiring the application to determine whether it is in a cross-core scenario.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:00 +08:00
Zihao Gao 4fa0b20284 bttool: add test tool for vendor at response.
Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2026-04-20 14:52:00 +08:00
zhangyuan20 0cc3641f6d Android-Vela: add clip callback for hf
Rootcause: The application wants to get the name of the hf call by clip. The order is clip first, then clcc, but clip can only be called back after clcc, resulting in the application not being able to get the name. A separate callback needs to be added to clip.

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-20 14:51:58 +08:00
chengkai 3613536ff3 bluetooth: add bt trace tool
Signed-off-by: chengkai <chengkai@xiaomi.com>
2026-04-20 14:51:53 +08:00