1# Copyright 2021-2024 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# ----------------------------------------------------------------------------- 16# Imports 17# ----------------------------------------------------------------------------- 18import logging 19import pytest 20 21from bumble.controller import Controller 22from bumble.host import Host 23from bumble.transport import AsyncPipeSink 24 25# ----------------------------------------------------------------------------- 26# Logging 27# ----------------------------------------------------------------------------- 28logger = logging.getLogger(__name__) 29 30 31# ----------------------------------------------------------------------------- 32@pytest.mark.asyncio 33@pytest.mark.parametrize( 34 'supported_commands, lmp_features', 35 [ 36 ( 37 # Default commands 38 '2000800000c000000000e4000000a822000000000000040000f7ffff7f000000' 39 '30f0f9ff01008004000000000000000000000000000000000000000000000000', 40 # Only LE LMP feature 41 '0000000060000000', 42 ), 43 ( 44 # All commands 45 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' 46 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 47 # 3 pages of LMP features 48 '000102030405060708090A0B0C0D0E0F011112131415161718191A1B1C1D1E1F', 49 ), 50 ], 51) 52async def test_reset(supported_commands: str, lmp_features: str): 53 controller = Controller('C') 54 controller.supported_commands = bytes.fromhex(supported_commands) 55 controller.lmp_features = bytes.fromhex(lmp_features) 56 host = Host(controller, AsyncPipeSink(controller)) 57 58 await host.reset() 59 60 assert host.local_lmp_features == int.from_bytes( 61 bytes.fromhex(lmp_features), 'little' 62 ) 63