# Copyright 2021-2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import asyncio import pytest import struct from unittest import mock from bumble import device as bumble_device from bumble.profiles import asha from .test_utils import TwoDevices # ----------------------------------------------------------------------------- HI_SYNC_ID = b'\x00\x01\x02\x03\x04\x05\x06\x07' TIMEOUT = 0.1 # ----------------------------------------------------------------------------- @pytest.mark.asyncio async def test_get_only_properties(): devices = TwoDevices() await devices.setup_connection() asha_service = asha.AshaService( hisyncid=HI_SYNC_ID, device=devices[0], protocol_version=0x01, capability=0x02, feature_map=0x03, render_delay_milliseconds=0x04, supported_codecs=0x05, ) devices[0].add_service(asha_service) async with bumble_device.Peer(devices.connections[1]) as peer: asha_client = peer.create_service_proxy(asha.AshaServiceProxy) assert asha_client read_only_properties = ( await asha_client.read_only_properties_characteristic.read_value() ) ( protocol_version, capabilities, hi_sync_id, feature_map, render_delay_milliseconds, _, supported_codecs, ) = struct.unpack("