From 6fd08b709ad03c7acb352f1fe7369fd833f9a191 Mon Sep 17 00:00:00 2001 From: dcaayushd Date: Mon, 6 Jul 2026 19:17:34 +0545 Subject: [PATCH] Fix CS default channel map --- bumble/device.py | 2 +- tests/device_test.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bumble/device.py b/bumble/device.py index f3b431c5e..b39299cb6 100644 --- a/bumble/device.py +++ b/bumble/device.py @@ -5442,7 +5442,7 @@ async def create_cs_config( role: int = hci.CsRole.INITIATOR, rtt_type: int = hci.RttType.AA_ONLY, cs_sync_phy: int = hci.CsSyncPhy.LE_1M, - channel_map: bytes = b'\x54\x55\x55\x54\x55\x55\x55\x55\x55\x15', + channel_map: bytes = b'\x54\x55\x55\x54\x55\x55\x55\x55\x55\x05', channel_map_repetition: int = 0x01, channel_selection_type: int = hci.HCI_LE_CS_Create_Config_Command.ChannelSelectionType.ALGO_3B, ch3c_shape: int = hci.HCI_LE_CS_Create_Config_Command.Ch3cShape.HAT, diff --git a/tests/device_test.py b/tests/device_test.py index 3efe4db1e..7df82802c 100644 --- a/tests/device_test.py +++ b/tests/device_test.py @@ -17,6 +17,7 @@ # ----------------------------------------------------------------------------- import asyncio import functools +import inspect import logging import os from unittest import mock @@ -693,6 +694,25 @@ async def test_power_on_default_static_address_should_not_be_any(): assert devices[0].static_address != Address.ANY_RANDOM +# ----------------------------------------------------------------------------- +def test_cs_channel_map_excludes_forbidden_channels(): + forbidden = {0, 1, 23, 24, 25, 76, 77, 78, 79} + default_map = ( + inspect.signature(Device.create_cs_config).parameters['channel_map'].default + ) + + enabled = { + byte_idx * 8 + bit + for byte_idx, byte in enumerate(default_map) + for bit in range(8) + if byte & (1 << bit) + } + + assert enabled.isdisjoint( + forbidden + ), f"Default channel_map enables forbidden CS channels: {enabled & forbidden}" + + # ----------------------------------------------------------------------------- def test_gatt_services_with_gas_and_gatt(): device = Device(host=Host(None, None))