# Copyright 2023 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 hci_packets as hci import link_layer_packets as ll import unittest from hci_packets import ErrorCode from py.bluetooth import Address from py.controller import ControllerTest
# 3. Lower Tester expects the IUT to send ADV_DIRECT_IND packets: A packet starting an event on # an applicable advertising channel with the lowest advertising channel index, then optionally # following packets on applicable advertising channels with increasing advertising channel indexes. # Expect the intervals between starts of packet on any single channel to be equal to or below # 3.75 ms. # 4. Repeat until the IUT stops advertising and verify that it stops after 1.28s. For each advertising # channel, verify that at least 30 of the intervals between starts of packets on that channel are # equal to or below 3.75 ms. try:
end_time = asyncio.get_running_loop().time() + 5 while asyncio.get_running_loop().time() < end_time:
await self.expect_ll(
ll.LeLegacyAdvertisingPdu(
source_address=controller.address,
destination_address=peer_address,
advertising_address_type=ll.AddressType.PUBLIC,
target_address_type=ll.AddressType.PUBLIC,
advertising_type=ll.LegacyAdvertisingType.ADV_DIRECT_IND,
advertising_data=[])) # Note: The test should timeout waiting for a directed advertising event # past the direct advertising timeout.
self.assertTrue(False) except asyncio.exceptions.TimeoutError:
print('stopped advertising OK')
# 5. Upper Tester receives an HCI_LE_Connection_Complete event from the IUT with status # parameter set to ‘directed advertising timeout’. # Note: The correct event to receive is LE Enhanced Connection Complete, # but the PTS tool expects LE Connection Complete for the test GAP/DISC/GENP/BV-05-C.
await self.expect_evt(hci.LeConnectionComplete(status=ErrorCode.ADVERTISING_TIMEOUT))
# 6. Configure Lower Tester to initiate a connection. # 7. Upper Tester enables directed advertising in the IUT using all supported advertising channels.
controller.send_cmd(hci.LeSetAdvertisingEnable(advertising_enable=True))
# 8. Lower Tester receives an ADV_DIRECT_IND packet from the IUT on the selected advertising # channel (defined as an IXIT), then responds with a CONNECT_IND packet T_IFS after the end of # the advertising packet and does not send any data packets to the IUT. # 9. Lower Tester receives no ADV_DIRECT_IND packets from the IUT after the advertising interval. # 10. Repeat steps 8–9 until the IUT stops advertising.
await self.expect_ll(
ll.LeLegacyAdvertisingPdu(source_address=controller.address,
destination_address=peer_address,
advertising_address_type=ll.AddressType.PUBLIC,
target_address_type=ll.AddressType.PUBLIC,
advertising_type=ll.LegacyAdvertisingType.ADV_DIRECT_IND,
advertising_data=[]))
# 11. Upper Tester receives an HCI_LE_Connection_Complete event from the IUT including the # parameters sent to the IUT in step 8.
evt = await self.expect_evt(
hci.LeEnhancedConnectionCompleteV1(
status=ErrorCode.SUCCESS,
connection_handle=self.Any,
role=hci.Role.PERIPHERAL,
peer_address_type=hci.AddressType.PUBLIC_DEVICE_ADDRESS,
peer_address=peer_address,
connection_interval=self.LL_initiator_connInterval,
peripheral_latency=self.LL_initiator_connPeripheralLatency,
supervision_timeout=self.LL_initiator_connSupervisionTimeout,
central_clock_accuracy=hci.ClockAccuracy.PPM_500))
connection_handle = evt.connection_handle
# 12. Upper Tester receives an HCI_LE_Disconnection_Complete event from the IUT with the reason # parameter indicating ‘connection failed to be established’, with the connection handle parameter # matching to step 8.
controller.send_ll(
ll.Disconnect(source_address=peer_address,
destination_address=controller.address,
reason=int(hci.ErrorCode.CONNECTION_FAILED_ESTABLISHMENT)))
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.