Merge branch 'google:main' into main

This commit is contained in:
khsiao-google
2025-07-15 11:42:58 +08:00
6 changed files with 28 additions and 8 deletions

View File

@@ -618,8 +618,8 @@ class Controller:
cis_sync_delay=0, cis_sync_delay=0,
transport_latency_c_to_p=0, transport_latency_c_to_p=0,
transport_latency_p_to_c=0, transport_latency_p_to_c=0,
phy_c_to_p=0, phy_c_to_p=1,
phy_p_to_c=0, phy_p_to_c=1,
nse=0, nse=0,
bn_c_to_p=0, bn_c_to_p=0,
bn_p_to_c=0, bn_p_to_c=0,

View File

@@ -1710,6 +1710,8 @@ class Connection(utils.CompositeEventEmitter):
pairing_peer_authentication_requirements: Optional[int] pairing_peer_authentication_requirements: Optional[int]
cs_configs: dict[int, ChannelSoundingConfig] # Config ID to Configuration cs_configs: dict[int, ChannelSoundingConfig] # Config ID to Configuration
cs_procedures: dict[int, ChannelSoundingProcedure] # Config ID to Procedures cs_procedures: dict[int, ChannelSoundingProcedure] # Config ID to Procedures
classic_mode: int = hci.HCI_Mode_Change_Event.Mode.ACTIVE
classic_interval: int = 0
EVENT_CONNECTION_ATT_MTU_UPDATE = "connection_att_mtu_update" EVENT_CONNECTION_ATT_MTU_UPDATE = "connection_att_mtu_update"
EVENT_DISCONNECTION = "disconnection" EVENT_DISCONNECTION = "disconnection"
@@ -1736,6 +1738,8 @@ class Connection(utils.CompositeEventEmitter):
EVENT_CHANNEL_SOUNDING_CONFIG_REMOVED = "channel_sounding_config_removed" EVENT_CHANNEL_SOUNDING_CONFIG_REMOVED = "channel_sounding_config_removed"
EVENT_CHANNEL_SOUNDING_PROCEDURE_FAILURE = "channel_sounding_procedure_failure" EVENT_CHANNEL_SOUNDING_PROCEDURE_FAILURE = "channel_sounding_procedure_failure"
EVENT_CHANNEL_SOUNDING_PROCEDURE = "channel_sounding_procedure" EVENT_CHANNEL_SOUNDING_PROCEDURE = "channel_sounding_procedure"
EVENT_MODE_CHANGE = "mode_change"
EVENT_MODE_CHANGE_FAILURE = "mode_change_failure"
EVENT_ROLE_CHANGE = "role_change" EVENT_ROLE_CHANGE = "role_change"
EVENT_ROLE_CHANGE_FAILURE = "role_change_failure" EVENT_ROLE_CHANGE_FAILURE = "role_change_failure"
EVENT_CLASSIC_PAIRING = "classic_pairing" EVENT_CLASSIC_PAIRING = "classic_pairing"
@@ -5888,7 +5892,7 @@ class Device(utils.CompositeEventEmitter):
connection.classic_interval = interval connection.classic_interval = interval
connection.emit(connection.EVENT_MODE_CHANGE) connection.emit(connection.EVENT_MODE_CHANGE)
else: else:
connection.emit(connection.EVENT_MODE_CHANGE_FAILURE) connection.emit(connection.EVENT_MODE_CHANGE_FAILURE, status)
# [Classic only] # [Classic only]
@host_event_handler @host_event_handler

View File

@@ -4990,7 +4990,9 @@ class HCI_LE_Set_Privacy_Mode_Command(HCI_Command):
NETWORK_PRIVACY_MODE = 0x00 NETWORK_PRIVACY_MODE = 0x00
DEVICE_PRIVACY_MODE = 0x01 DEVICE_PRIVACY_MODE = 0x01
peer_identity_address_type: int = field(metadata=Address.ADDRESS_TYPE_SPEC) peer_identity_address_type: int = field(
metadata=metadata(Address.ADDRESS_TYPE_SPEC)
)
peer_identity_address: Address = field( peer_identity_address: Address = field(
metadata=metadata(Address.parse_address_preceded_by_type) metadata=metadata(Address.parse_address_preceded_by_type)
) )

View File

@@ -1392,6 +1392,15 @@ class Host(utils.EventEmitter):
def on_hci_synchronous_connection_changed_event(self, event): def on_hci_synchronous_connection_changed_event(self, event):
pass pass
def on_hci_mode_change_event(self, event: hci.HCI_Mode_Change_Event):
self.emit(
'mode_change',
event.connection_handle,
event.status,
event.current_mode,
event.interval,
)
def on_hci_role_change_event(self, event): def on_hci_role_change_event(self, event):
if event.status == hci.HCI_SUCCESS: if event.status == hci.HCI_SUCCESS:
logger.debug( logger.debug(

View File

@@ -8,7 +8,7 @@ dynamic = ["version"]
description = "Bluetooth Stack for Apps, Emulation, Test and Experimentation" description = "Bluetooth Stack for Apps, Emulation, Test and Experimentation"
readme = "README.md" readme = "README.md"
authors = [{ name = "Google", email = "bumble-dev@google.com" }] authors = [{ name = "Google", email = "bumble-dev@google.com" }]
requires-python = ">=3.8" requires-python = ">=3.9"
dependencies = [ dependencies = [
"aiohttp ~= 3.8; platform_system!='Emscripten'", "aiohttp ~= 3.8; platform_system!='Emscripten'",
"appdirs >= 1.4; platform_system!='Emscripten'", "appdirs >= 1.4; platform_system!='Emscripten'",

View File

@@ -581,8 +581,12 @@ async def test_enter_and_exit_sniff_mode():
devices = TwoDevices() devices = TwoDevices()
await devices.setup_connection() await devices.setup_connection()
m = mock.Mock() q = asyncio.Queue()
devices.connections[0].on(Connection.EVENT_MODE_CHANGE, m)
def on_mode_change():
q.put_nowait(lambda: None)
devices.connections[0].on(Connection.EVENT_MODE_CHANGE, on_mode_change)
await devices[0].send_command( await devices[0].send_command(
hci.HCI_Sniff_Mode_Command( hci.HCI_Sniff_Mode_Command(
@@ -594,7 +598,7 @@ async def test_enter_and_exit_sniff_mode():
), ),
) )
m.assert_called_once() await asyncio.wait_for(q.get(), _TIMEOUT)
assert devices.connections[0].classic_mode == hci.HCI_Mode_Change_Event.Mode.SNIFF assert devices.connections[0].classic_mode == hci.HCI_Mode_Change_Event.Mode.SNIFF
assert devices.connections[0].classic_interval == 2 assert devices.connections[0].classic_interval == 2
@@ -602,6 +606,7 @@ async def test_enter_and_exit_sniff_mode():
hci.HCI_Exit_Sniff_Mode_Command(connection_handle=devices.connections[0].handle) hci.HCI_Exit_Sniff_Mode_Command(connection_handle=devices.connections[0].handle)
) )
await asyncio.wait_for(q.get(), _TIMEOUT)
assert devices.connections[0].classic_mode == hci.HCI_Mode_Change_Event.Mode.ACTIVE assert devices.connections[0].classic_mode == hci.HCI_Mode_Change_Event.Mode.ACTIVE
assert devices.connections[0].classic_interval == 2 assert devices.connections[0].classic_interval == 2