Commit Graph

229 Commits

Author SHA1 Message Date
huangyulong3 0cf1898d83 bluetooth: fix compilation errors
Fix various compilation errors across bluetooth framework, service,
and stack layers including:
- Add missing function declarations and header includes
- Fix type mismatches and implicit function declarations
- Add missing macro definitions in dfx headers
- Add stub implementation for hid device interface
- Fix list utility inline function issues

Signed-off-by: openvela <openvela@xiaomi.com>
2026-05-08 09:52:38 +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
Lu Jia 5ee890cc21 cs: Fix compilation errors.
bug: v/87350

Signed-off-by: jialu <jialu@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
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
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
liuxiang18 ca68358f90 scan: fix coding error
bug: v/84177

The on_scan_start_status callback was incorrectly used in BT_LE_ON_SCAN_STOPPED. It has now been reverted to on_scan_stopped.

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:54 +08:00
liuxiang18 257b1d3593 socket: fix nullptr access when callback->member is NULL.
bug: v/84177

When a member variable is NULL within the scan_callback or adv_callback of the client call interface, the bt_socket_scan/adv fails to check for nullptr, resulting in a null address access.

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
Kai Cheng 43b6f0e791 bluetooth: fix bt_socket_server build break
bug: v/76636

rootcasue: fix ci break
./frameworks/connectivity/bluetooth/service/ipc/socket/src/bt_socket_server.c:171:96: error: code should be clang-formatted [-Wclang-format-violations]
      if (BT_IPC_CODE_CHECK_RANGE(packet->code, BT_MANAGER_MESSAGE_START, BT_MANAGER_MESSAGE_END)
./frameworks/connectivity/bluetooth/service/ipc/socket/src/bt_socket_server.c:174:103: error: code should be clang-formatted [-Wclang-format-violations]
      } else if (BT_IPC_CODE_CHECK_RANGE(packet->code, BT_ADAPTER_MESSAGE_START, BT_ADAPTER_MESSAGE_END)
./frameworks/connectivity/bluetooth/service/ipc/socket/src/bt_socket_server.c:177:78: error: code should be clang-formatted [-Wclang-format-violations]
      } else if (BT_IPC_CODE_CHECK_RANGE(packet->code, BT_DEVICE_MESSAGE_START,BT_DEVICE_MESSAGE_END)

Signed-off-by: Kai Cheng <chengkai@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
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
Kai Cheng cb99b4546c blueototh: add ipc and service config
bug: v/51584

add ipc and service profile config

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-27 23:14:52 +08:00
Kai Cheng adc08df0a4 blueotooth: add log config
bug: v/51584

add CONFIG_BLUETOOTH_LOG config

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-27 23:14:52 +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
zhongzhijie1 12124f78a0 Redefine new ipc callback code BT_LE_ON_BATCH_SCAN_RESULT.
bug: v/52485

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-27 23:14:51 +08:00
zhongzhijie1 7bfcb74aa8 Support batch scan result report.
bug: v/58186

Detail:
- Implemented batch reporting for BLE scan results via 1024-byte pipe buffer.
  Supports up to 15 scan packets per batch.
- Added 150ms flush timeout to ensure timely reporting in low-traffic environments.

Signed-off-by: zhongzhijie1 <zhongzhijie1@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
Haishen Zhang beebf57a97 Redefine IPC message/callback code
bug: v/52485

1. Add extended IPC message/callback code
2. Update bt_socket_client_callback_process()
3. Update bt_socket_server_receive()

Signed-off-by: Haishen Zhang <zhanghaishen@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
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
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 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 8e80c727a1 BTsnoop: Fixed cherry-pick conflicts.
bug: v/42717

Signed-off-by: duqunbo <duqunbo@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
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
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
zhangyuan20 60072ab342 framework/avrcp: add metadata support for avrcp control in BT Service
bug: v/42362

Rootcause: Avrcp control lacks metadata interface, add get metadata interface and callback for avrcp control

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:50 +08:00
shenyangsi 805e59c285 ipc: fix the truncation issue of socket receiving or sending.
bug: v/45789

Rootcause: Missing return value handling for send() & recv() of socket

Signed-off-by: shenyangsi <shenyangsi@xiaomi.com>
2026-04-27 23:14:50 +08:00
openvela-robot 9d0c825cbb Merge commit
Change-Id: If26995eebd18a82ac4cd827e6801458e57a6ead3
2026-04-27 23:14:50 +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
Lu Jia 5ee7a9d275 bluetooth: Fix resource leak issues when initializing the client with an asynchronous API.
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>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:53:22 +08:00
Lu Jia c814e04423 bluetooth: Fix resource leak issue.
When the family is not AF_LOCAL or AF_RPMSG, the function returns immediately without freeing the memory allocated for 'priv', leading to a memory leak.

Signed-off-by: jialu <jialu@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:53:21 +08:00
Zihao Gao e87739c4da IPC: Add nullptr protection.
Rootcause: missing NULL check before uv_read_stop.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
Signed-off-by: miot-robot <miot-robot@xiaomi.com>
2026-04-20 14:53:06 +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 532f06a40c bluetooth: Fix the issue where AVRCP fails to retrieve song information.
When the length of a song's attribute is 0, both types and chr_sets of that attribute are set to the default value 0. During message processing on the client side, the attribute's text is not assigned a NULL value due to types = 0. This leads to an error during string length calculation (strlen) when the feature processes the callback.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-20 14:52:51 +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
liuxiang18 b7651f4cc5 IPC: adapt l2cap new message code
Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:52:47 +08:00