Commit Graph

479 Commits

Author SHA1 Message Date
chejinxian1 6c4dc95334 bluetooth/tools: fix bttool cleanup failure on BT disable
bug: v/85832

Fix defects causing bttool resource leak during BT enable/disable
stress test:

1. Store bttool_t pointer in g_bttool_loop->data so TURNING_OFF callback
   can access the async queue (previously always 0, cleanup was skipped)
2. Replace do_in_thread_loop with bttool_uninit() in TURNING_OFF callback
   to send _uninit command via uv_async_queue_send, ensuring bt_tool_uninit
   runs on g_bttool_loop thread (mirrors bttool_quit pattern). Guard with
   CONFIG_LIBUV_EXTENSION only.
3. Add re-entry guard in bt_tool_uninit to prevent double cleanup on
   repeated BT disable cycles

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:55 +08:00
Lu Jia 5845d97591 cs: Fix the issue where RAS data is transmitted incompletely (only half sent).
bug: v/87852

This commit performs an architecture-level refactoring of cs_ras.c and cs_ras.h. The core change replaces the shared global buffer and static arrays used for Real-time and On-demand mode data storage with independent dynamically-allocated linked list queues, resolving memory safety issues and concurrent processing defects in the original architecture.

Signed-off-by: jialu <jialu@xiaomi.com>
2026-04-27 23:14:55 +08:00
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
chejinxian1 ebefa1d6d4 bluetooth/tools: fix Coverity defects in l2cap tool
bug: v/87430

- Replace strncpy with memcpy for non-string delimiter field
  to avoid non-null terminated buffer warning
- Remove dead comparison msg->id < 0 on unsigned type and
  change msg->len <= 0 to msg->len == 0 to fix
  unsigned compared against 0 warning

Signed-off-by: chejinxian1 <chejinxian1@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 90020e899a CS: add bttool to test cs.
bug: v/80281

Rootcause: Add bttool to test CS functionality

Signed-off-by: zhangyuan20 <zhangyuan20@xiaomi.com>
2026-04-27 23:14:55 +08:00
zhongzhijie1 f43a1bf044 Implement CTKD support for cross-transport key derivation
bug: v/85866

Implemented Cross-Transport Key Derivation (CTKD) functionality to enable
secure key derivation between BR/EDR and BLE transports.

Changes:
- service/stacks/zephyr/sal_adapter_le_interface.c:
  * Added ctkd_mode field to sal_adapter_args_t union
  * Implemented enable_key_derivation() function
  * Completed bt_sal_le_enable_key_derivation() implementation with support
    for bidirectional key derivation (BR->LE and LE->BR)
  * Added proper CONFIG_BT_CLASSIC conditional compilation

- tools/bt_tools.c:
  * Added set_ctkd_mode_cmd() function for CLI control
  * Registered 'setctkd' and 'set ctkd' commands in command tables
  * Provides user-friendly interface to enable/disable CTKD modes

This feature allows devices to derive encryption keys across different
Bluetooth transports, improving security and user experience during
dual-mode connections.

Signed-off-by: zhongzhijie1 <zhongzhijie1@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 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
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
chejinxian1 cdd6946ebe bttool: L2CAP: add configurable mtu/mps/credits parameters
bug: v/84420

Add support for configurable MTU, MPS, and credits parameters in L2CAP connect and listen commands with proper validation.

Changes:
- Add optional [mtu] [mps] [credits] parameters to connect/listen commands
- Use default values when parameters are not specified
- Add validate_l2cap_params() function for parameter validation
- Validate MTU >= 23, MPS range 23-65533, credits >= 1, and MPS <= MTU
- Provide clear error messages with specific validation failures
- Update command help text to reflect new optional parameters

Usage:
  connect <address> <psm> [mtu] [mps] [credits]
  listen <psm> [mtu] [mps] [credits]

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:54 +08:00
chejinxian1 5a3c6dfbfe bttool: L2CAP: add flow control commands for testing
bug: v/84215

Add stoprecv/startrecv commands to manually control data reception on L2CAP channels for flow control testing purposes.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-27 23:14:54 +08:00
v-chenghuijin 498bbed959 SPP: Fix race condition crash by unifying thread context for resource cleanup
bug: v/80850

Rootcause: uv_loop_close() marks internal data structures as invalid, but
pending callbacks in the queue still reference these invalidated
structures. When uv_run() is called later, it processes the queue using
corrupted pointers, leading to segmentation faults and crashes.

Solution:To address the issues described above, the solution removes
uv_loop_t from the bttool_t struct and changes it to dynamic allocation,
introducing a global pointer g_bttool_loop to centrally manage its
lifecycle. Specific modifications include: dynamically allocating and
initializing the uv_loop_t instance within the bttool_thread function and
assigning it to the global pointer; modifying the bttool_command_uvloop_run
function to operate using the global g_bttool_loop pointer; and adjusting
the asynchronous API initialization logic in async/gap.c to ensure it
uses the global pointer instead of a local pointer. Furthermore, the
solution enhances error handling, ensuring proper resource cleanup if
memory allocation fails, and optimizes the bt_tool_uninit_cb function to
prevent premature clearing of the global pointer, which could lead to
access exceptions.

Signed-off-by: v-chenghuijin <v-chenghuijin@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
liuxiang18 842e267a37 storage_update: fix build error.
bug: v/73508

ARRAY_SIZE() is defined at "bt_utils.h"

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:53 +08:00
liuxiang18 c7d042e371 bluetooth: add bttool-storage
bug: v/70895

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-27 23:14:53 +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
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
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
zhongzhijie1 748ea54904 bttool: Update gattc gatts command, the last parameter is the address type.
bug: v/60490

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
Haishen Zhang b6d9041078 BTS: Add Bond Tool
bug: v/57723

1. Add Bond Tool
2026-04-27 23:14:51 +08:00
Haishen Zhang 9dd20370bb BTS: Add Bluetooth Socket test tool
bug: v/57368

1. Add test tool of SPP
2. Add test tool of L2CAP over BREDR
3. Add test tool of L2CAP over BLE
4. Add Watch UI
2026-04-27 23:14:51 +08:00
Haishen Zhang 4aa506e324 BTS: Add layout for watch devices
bug: v/57133

1. Add layout for watch devices: ScrollView + ConstraintLayout
2026-04-27 23:14:51 +08:00
Haishen Zhang ae12a3458a BTS: Adjust the layout of MainActivity
bug: v/57133

1. Change LinearLayout to ConstraintLayout + ScrollView to make it more responsive
2. Add OnOffActivity.java and activity_on_off.xml to do Bluetooth On/Off operations
3. Add permissions in AndroidManifest.xml and request them during runtime
4. Add more debug logs
5. Remove Bluetooth On/Off operations from MainActivity.java
2026-04-27 23:14:51 +08:00
Haishen Zhang d78e6be873 BTS: remove "android:screenOrientation"
bug: v/57133

The <activity> element should not be locked to any orientation so that users can take advantage of the multi-window environments and larger screens available on Android.
2026-04-27 23:14:51 +08:00
Haishen Zhang 860e6357d9 Update Gradle and AGP
bug: v/57133

Upgrade AGP dependency from 8.7.2 to 8.9.0
Upgrade Gradle version to 8.11.1
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
shenyangsi 75f0368648 test_suite: add BluetoothTest APP based on AndroidStudio
bug: v/52280

Signed-off-by: shenyangsi <shenyangsi@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
chejinxian1 5c99058bde OS-Upgrade: Add a BT storage transformation tool.
bug: v/47945

Rootcause: Due to the differences in the storage format of Bluetooth information in different system versions, in order to ensure that saved information can continue to be used after system upgrades, the storage transformation tool has been added.

Signed-off-by: chejinxian1 <chejinxian1@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
liuxiang18 d5b401b78b storage update: add items-GATT HASH for storage update.
Since the current version_5_0_3 has no business logic and does not impact the existing storage structure, the GATT hash is reused in version_5_0_3.

New GATT hash items added in version_5_0_3 include:
1. Added enumeration value: BT_STORAGE_UPDATE_GATT_HASH_INFO
2. Added GATT hash removal logic within the bt_storage_properties_destroy function
3. Modified the bt_storage_update_item_size table
4. Added GATT hash items to the callback_cnt_list
5. Added GATT_cache save logic to the bt_storage_update_save_info function

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:53:20 +08:00
chejinxian1 23bead1c3d bttool: Implement cleanup function for L2CAP channels on uninitialization
Rootcause: In scenarios where the test server listens, channel instances exist for awaiting accept operations. When the `bttool` exits directly, although the service can be notified to release corresponding resources via `bt_l2cap_unregister_callbacks`, the channel instances on the `bttool` side still require manual release to prevent memory leaks.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +08:00
chejinxian1 b37c2f4279 bttool: Implementation of L2CAP throughput testing commands
Rootcause: An assessment of the throughput performance of the L2CAP service is required; consequently, the command `speed` has been added to measure the throughput of L2CAP connections.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +08:00
chejinxian1 9f0e8bba1c bttool: Refactor connection parameters to use defined constants and improve command parameters input
Replace hard-coded connection parameters with macro definitions.

Introduce `strtoul` to optimise command parameter reading.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +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 c0702aacac bttool: Implement the stoplisten command in L2CAP
Rootcause: The command stoplisten is provided to simulate scenarios where an application no longer accepts new L2CAP connections.

To implement this functionality, the is_listening flag has been introduced to assist in releasing channels used for listening.

Additionally, this modification optimises the input for the listen command, supporting both decimal and hexadecimal PSM input.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +08:00
chejinxian1 fb40ee41ff bttool: Rename `l2cap_channel_t` to `l2cap_chnl_t` for consistency
Rootcause: The `l2cap_channel_t` structure type definition in `bttool` is identical to the Service type definition, resulting in GDB being unable to correctly parse variable contents when analysing coredump.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +08:00
chejinxian1 779fce73fb bttool: Add usage function to display l2cap command information
Add L2CAP command usage prompts to guide testing operations.

Signed-off-by: chejinxian1 <chejinxian1@xiaomi.com>
2026-04-20 14:52:54 +08:00
liuxiang18 695d201a05 storage_update: update from v5_0_2 to v5_0_3.
1. adaptInfo add 'irk', and remote_device_le_properties_t add 'local_csrk'.
2. change storage version number to v5_0_3
3. add v5_0_2->v5_0_3 storage update function

Signed-off-by: liuxiang18 <liuxiang18@xiaomi.com>
2026-04-20 14:52:52 +08:00
zhongzhijie1 3fc754b785 Manager GATT server test: Normalize read-only/read-write/pts char access.
move PTS test char to tools/manager (replace SAL workaround); place Manager char value at tool (app) level.

Signed-off-by: zhongzhijie1 <zhongzhijie1@xiaomi.com>
2026-04-20 14:52:49 +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