1# Copyright 2021-2023 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 asyncio 19import os 20import pytest 21import logging 22 23from bumble import device 24from bumble import gatt 25from bumble.profiles import cap 26from bumble.profiles import csip 27from .test_utils import TwoDevices 28 29# ----------------------------------------------------------------------------- 30# Logging 31# ----------------------------------------------------------------------------- 32logger = logging.getLogger(__name__) 33 34 35# ----------------------------------------------------------------------------- 36@pytest.mark.asyncio 37async def test_cas(): 38 SIRK = bytes.fromhex('2f62c8ae41867d1bb619e788a2605faa') 39 40 devices = TwoDevices() 41 devices[0].add_service( 42 cap.CommonAudioServiceService( 43 csip.CoordinatedSetIdentificationService( 44 set_identity_resolving_key=SIRK, 45 set_identity_resolving_key_type=csip.SirkType.PLAINTEXT, 46 ) 47 ) 48 ) 49 50 await devices.setup_connection() 51 peer = device.Peer(devices.connections[1]) 52 cas_client = await peer.discover_service_and_create_proxy( 53 cap.CommonAudioServiceServiceProxy 54 ) 55 56 included_services = await peer.discover_included_services(cas_client.service_proxy) 57 assert any( 58 service.uuid == gatt.GATT_COORDINATED_SET_IDENTIFICATION_SERVICE 59 for service in included_services 60 ) 61 62 63# ----------------------------------------------------------------------------- 64async def run(): 65 await test_cas() 66 67 68# ----------------------------------------------------------------------------- 69if __name__ == '__main__': 70 logging.basicConfig(level=os.environ.get('BUMBLE_LOGLEVEL', 'INFO').upper()) 71 asyncio.run(run()) 72