Commit Graph

417 Commits

Author SHA1 Message Date
Zihao Gao ea27e37547 bt_uuid: define BT_UUID_STR_LENGTH macro and update usages
Bug: v/87379

Define BT_UUID_STR_LENGTH macro (40) in bt_uuid.h to replace hardcoded
magic numbers for UUID string buffer size. Use LENGTH suffix to avoid
conflict with Zephyr's BT_UUID_STR_LEN definition.

Update all usages across the codebase to use the new macro.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2026-04-27 23:14:55 +08:00
Lu Jia 83d3c9933c cs : Add cs_set_config command to set RAS supported configuration and fix compilation warnings.
bug: v/87425

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:55 +08:00
zhongzhijie1 9e3c953bcf bluetooth:Support scan filter policy feature in bluetooth framework/service.
bug: v/55749

API user can pass scan policy refs in ble_scan_filter_type_t.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:55 +08:00
zhangyuan20 a8fa3ba64d CS: add cs socket server and client.
bug: v/80281

Rootcause: Add a socket server and client to enable communication between the user and Bluetooth.

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:55 +08:00
zhangyuan20 1787ea002f CS: add cs service.
bug: v/80281

Rootcause: Add a CS service to manage CS.

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:55 +08:00
huangyulong3 25897a5b40 CS: Add the CS GATTS header file.
bug: v/83698

rootcause: The GATTS module is essential for Channel Sounding during
the ranging process, involving GATT service creation, GATT message
transmission, and GATT management.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
2026-04-27 23:14:55 +08:00
Zihao Gao 4ddf4c0ef8 RSSI: update adapter services to update rssi.
bug: v/86588

Rootcase: the rssi is never changed after BR/EDR inquiry scan, and is never assigned a value for LE.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2026-04-27 23:14:54 +08:00
zhongzhijie1 17f572ca9a fix build waring when CONFIG_BLUETOOTH_BLE_SUPPORT not enable
bug: v/84604

if ble not support, return 0.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:54 +08:00
zhongzhijie1 30f781f87f pm: add bt_cm_enable/disable_enhanced_mode for BR/EDR low-latency sniff
bug: v/67000

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-27 23:14:54 +08:00
zhongzhijie1 9c4b086364 implement get addrtype api
bug: v/84604

original return 0 default, now use adapter_get_le_remote_address_type

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:54 +08:00
zhongzhijie1 e1caf81f4a add ATTR_AUTO_RSP_CCC_READ to keep legacy GATT_H_CCCD behavior
bug: v/86395

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-27 23:14:54 +08:00
zhongzhijie1 10190d8dcb support user response for descriptor read requests
bug: v/86395

Provides a hook for business logic to observe and track read requests
without changing existing ATT/CCCD behavior.

Application sees the request but its response data is ignored; stack
still uses internal values for protocol correctness.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:54 +08:00
zhongzhijie1 d0c5c186c5 gattc: add CCC handle query for Zephyr stack
bug: v/83024

Zephyr stack needs CCC handle to do CCCD.
Old stack only needs value handle.

So gattc_service.c adds a query helper.
It uses the full service DB to map value_handle to ccc_handle.
sal can use this function to find the correct CCC handle.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:54 +08:00
chengkai 1309b694c3 bluetooth: add spp insecure feature
bug: v/13885

Signed-off-by: chengkai <chengkai@xiaomi.com>
2026-04-27 23:14:54 +08:00
v-chenghuijin 5e83175f35 fix: prevent crash by ensuring non-null string for sched_note_printf
bug: v/84212

Rootcase: The lightweight sched_note_printf function in the NuttX backend does not
perform NULL safety checks for the %s format specifier. Passing a NULL pointer from
hsm_get_state_name leads to a NULL pointer dereference, triggering a data abort
exception on systems with memory protection (MMU/MPU) and causing a system crash.

Solution: This commit addresses the issue by modifying the HSM_SAFE_NAME macro to
use the ternary operator. It now explicitly returns the "None" string literal when
hsm_get_state_name returns NULL, guaranteeing that a valid, non-null C-string is always
passed to the logging function.

Signed-off-by: v-chenghuijin <v-chenghuijin@xiaomi.com>
2026-04-27 23:14:54 +08:00
chejinxian1 ffd449d59e Bluetooth: Fixed an issue where resources could not be released after closing uv_pipe in euv_pipe.
bug: v/83955

Rootcause: euv_pipe_close records the address of the euv_pipe in the data field of each uv_pipe instance to be closed, which is used to release the euv_pipe instance after the close operation completes.

A scenario exists where calling euv_pipe_close followed by euv_pipe_read_stop or euv_pipe_read_start causes the client pipe's data field to be reset to NULL or the reader's address. This prevents the euv_pipe instance from being released after close completes.

This occurs because euv_pipe_read_stop does not check the uv_pipe's state before directly freeing cli_pipe.data, while euv_pipe_read_start only verifies whether cli_pipe is active. Both functions lack a check for the closing state.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:54 +08:00
liuxiang18 2244e388f7 aync adv/scan: fix build error
bug: v/83666

The callback macro `CALLBACK_REMOTE` currently used in gatts/gattc employs the member variable `callbacks`. For enhanced versatility, the callback member variables in adv and scan have been modified from `callback` to `callbacks`.

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:54 +08:00
liuxiang18 9f1317ecb0 adv/scan: rename member variables callback as callbacks
bug: v/83666

The callback macro `CALLBACK_REMOTE` currently used in gatts/gattc employs the member variable `callbacks`. For enhanced versatility, the callback member variables in adv and scan have been modified from `callback` to `callbacks`.

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:54 +08:00
liuxiang18 4d524866b1 socket: Move the generic macro to the public header file.
bug: v/83666

In the current bt_socket_profile file, all client-side callbacks use the generic macro interface
BREDR & common: CALLBACK_FOREACH
BLE: CALLBACK_REMOTE

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:54 +08:00
chengkai d7a276c5a7 bluetooth: add gatts_connect_bear api [1/2]
bug: v/51103

Signed-off-by: chengkai <chengkai@xiaomi.com>
2026-04-27 23:14:53 +08:00
YuhengLi 2e7c5c3fda Android-Vela:add cind interface for android
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>
2026-04-27 23:14:53 +08:00
zhongzhijie1 303c98578c Remove the zephyr header file from the Bluetooth global header directory
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>
2026-04-27 23:14:53 +08:00
chejinxian1 ffe9428e8f Bluetooth: Add close callback support to `euv_pipe` structure and close 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>
2026-04-27 23:14:53 +08:00
Lu Jia e0699b4797 bluetooth: Before releasing the IPC pending_queue, invoke the asynchronous callbacks for all messages contained within it.
bug: v/77564

When deleting the Bluetooth asynchronous instance, the IPC cached messages are directly released, and their asynchronous callbacks will not be invoked. This could lead to memory leaks if resources are released within the callbacks.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:52 +08:00
wuxiaodong6 616c09ec15 Move the internal header files out to include common
bug: v/73268

Signed-off-by: wuxiaodong6 <wuxiaodong6@xiaomi.com>
2026-04-27 23:14:52 +08:00
Lu Jia 1aa0a59c97 ipc: trace async api
bug: v/62087

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:52 +08:00
zhongzhijie1 e52b434172 gattc/feature: add high-level GATT client, local DB, and async ops
bug: v/62106

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-27 23:14:52 +08:00
Lu Jia 6ab8107575 ipc: gattc async api
bug: v/62106

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:52 +08:00
liuxiang18 54f9f99502 PTS: add pts property for dynamic control disconnect or not when pair failed.
bug: v/71321

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:52 +08:00
liuxiang18 35619721a7 bluetooth: implement bt_device_set_bondable_le API to change bond mode.
bug: v/67335

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:52 +08:00
liuxiang18 9d7ddc49be bluetooth: implement bt_device_set_security_level API to change bond security level.
bug: v/67009

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:52 +08:00
Kai Cheng 89d1a7df7a bluetooth: add gatt client and server config
bug: v/51584

add gatt client and server config

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-27 23:14:52 +08:00
zhongzhijie1 d79629bfa4 Rename helper func get_os_timestamp_xx to bt_get_os_timestamp_xx avoid
naming confict.

bug: v/59638

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:51 +08:00
Zihao Gao 9d6193def5 Bluetooth: defer LE scan results if IPC blocked.
bug: v/57341

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2026-04-27 23:14:51 +08:00
zhangyuan20 914526bf60 zephyr-pts: add send passthrough cmd for avrcp ct
bug: v/58789

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:51 +08:00
liuxiang18 7fcbecc5cd IPC: fix build error conversion from 'int' to 'bt_message_type_t'.
bug: v/52485

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:51 +08:00
zhangyuan20 92594c2d26 Android-Vela: add clcc interface and callback
bug: v/60610

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:51 +08:00
Zihao Gao d91362fd92 Adapter: allow to check local support profiles via uuid.
bug: v/59759

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2026-04-27 23:14:51 +08:00
chejinxian1 981570db50 API: Add a new callback interface to obtain bond states.
bug: v/54141

Rootcause: The new interface will inform the upper-layer application of the previous bond state, thus distinguishing the different scenarios that may occur during the bonding process.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:51 +08:00
jialu 11c269d7d0 Bluetooth: Introducing the AVRCP function.
bug: v/46573

Rootcause: Add comments to the AVRCP .h file and improve function documentation.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:51 +08:00
fangzhenwei d61b5cf1be ipc: socket ipc support async call
bug: v/46316

1.add api bt_socket_client_send_with_reply

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2026-04-27 23:14:51 +08:00
liuxiang18 f376350309 Android-Vela: Adapter SPP in Android 14
bug: v/53727

open flag CONFIG_RPMSG_UART if defined(Android14)

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:51 +08:00
liuxiang18 3401f08950 Android-vela: bt_client-add bt_socket disconnect handling
bug: v/53721

Fix lost BT connection between android and vela as vela/Android reboot.

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:51 +08:00
duqunbo d3b95f21f1 BTsnoop: add btsnoop API
bug: v/42717

Signed-off-by: duqunbo <duqunbo@xiaomi.com>
2026-04-27 23:14:51 +08:00
chejinxian1 0d5604befa API Comments: Add comments to the API related to SPP.
bug: v/49544

Rootcause:To better assist the use of Bluetooth services for Bluetooth applications, this submission will add commentary descriptions for certain APIs in order to provide instructions for application reference

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:51 +08:00
chengkai 0f09cd64e9 bluetooth: adapt spp socket api
bug: v/47179

Signed-off-by: chengkai <chengkai@xiaomi.com>
2026-04-27 23:14:51 +08:00
chejinxian1 8fbb699c66 API Comments: Add comments to the API related to HFP.
bug: v/46611

Rootcause:To better assist the use of Bluetooth services for Bluetooth applications, this submission will add commentary descriptions for certain APIs in order to provide instructions for application reference.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:51 +08:00
zhangyuan20 eb4d0a3ce3 Vela-Android: save bredr remote uuids
bug: v/45250

Rootcause: vela does not save remote uuids, causing android UI to display errors

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:51 +08:00
jialu 1838bc72e8 HFP: Adding vendor specific AT command process for AG
bug: v/17775

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-27 23:14:51 +08:00
fangzhenwei 44a24c0a70 addr: fix bt_addr_str multiple define
bug: v/49964

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2026-04-27 23:14:50 +08:00