1#!/usr/bin/env python3 2# 3# Copyright 2019 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16from datetime import timedelta 17import time 18 19from cert.pts_base_test import PTSBaseTestClass 20from cert.event_stream import EventStream 21from facade import common_pb2 22from facade import rootservice_pb2 as facade_rootservice_pb2 23from l2cap.classic import facade_pb2 as l2cap_facade_pb2 24from google.protobuf import empty_pb2 25from neighbor.facade import facade_pb2 as neighbor_facade 26 27 28class PTSL2capTest(PTSBaseTestClass): 29 30 def setup_test(self): 31 self.device_under_test = self.gd_devices[0] 32 33 self.device_under_test.rootservice.StartStack( 34 facade_rootservice_pb2.StartStackRequest( 35 module_under_test=facade_rootservice_pb2.BluetoothModule.Value('L2CAP'),)) 36 37 self.device_under_test.wait_channel_ready() 38 39 dut_address = self.device_under_test.controller_read_only_property.ReadLocalAddress(empty_pb2.Empty()).address 40 pts_address = self.controller_configs.get('pts_address').lower() 41 self.device_under_test.address = dut_address 42 43 self.dut_address = common_pb2.BluetoothAddress(address=self.device_under_test.address) 44 self.pts_address = common_pb2.BluetoothAddress(address=str.encode(pts_address)) 45 46 self.device_under_test.neighbor.EnablePageScan(neighbor_facade.EnableMsg(enabled=True)) 47 48 def teardown_test(self): 49 self.device_under_test.rootservice.StopStack(facade_rootservice_pb2.StopStackRequest()) 50 51 def _dut_connection_stream(self): 52 return EventStream(self.device_under_test.l2cap.FetchConnectionComplete(empty_pb2.Empty())) 53 54 def _dut_connection_close_stream(self): 55 return EventStream(self.device_under_test.l2cap.FetchConnectionClose(empty_pb2.Empty())) 56 57 def _assert_connection_complete(self, dut_connection_stream, timeout=30): 58 dut_connection_stream.assert_event_occurs( 59 lambda device: device.remote.address == self.pts_address.address, timeout=timedelta(seconds=timeout)) 60 61 def _assert_connection_close(self, dut_connection_close_stream, timeout=30): 62 dut_connection_close_stream.assert_event_occurs( 63 lambda device: device.remote.address == self.pts_address.address, timeout=timedelta(seconds=timeout)) 64 65 def test_L2CAP_IEX_BV_01_C(self): 66 """ 67 L2CAP/COS/IEX/BV-01-C [Query for 1.2 Features] 68 Verify that the IUT transmits an information request command to solicit if the remote device supports 69 Specification 1.2 features. 70 """ 71 psm = 1 72 self.device_under_test.l2cap.OpenChannel(l2cap_facade_pb2.OpenChannelRequest(remote=self.pts_address, psm=psm)) 73 time.sleep(5) 74 75 def test_L2CAP_IEX_BV_02_C(self): 76 """ 77 L2CAP/COS/IEX/BV-02-C [Respond with 1.2 Features] 78 Verify that the IUT responds to an information request command soliciting for Specification 1.2 79 features. 80 """ 81 psm = 1 82 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 83 self.device_under_test.l2cap.SetDynamicChannel( 84 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 85 time.sleep(20) 86 87 def test_L2CAP_EXF_BV_01_C(self): 88 """ 89 L2CAP/EXF/BV-01-C [Extended Features Information Response for Enhanced Retransmission Mode] 90 Verify the IUT can format an Information Response for the information type of Extended Features that 91 correctly identifies that Enhanced Retransmission Mode is locally supported. 92 93 """ 94 psm = 1 95 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 96 self.device_under_test.l2cap.SetDynamicChannel( 97 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 98 time.sleep(5) 99 100 def test_L2CAP_EXF_BV_03_C(self): 101 """ 102 L2CAP/EXF/BV-03-C [Extended Features Information Response for FCS Option] 103 Verify the IUT can format an Information Response for the information type of Extended Features that 104 correctly identifies that the FCS Option is locally supported. 105 """ 106 psm = 1 107 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 108 self.device_under_test.l2cap.SetDynamicChannel( 109 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 110 time.sleep(5) 111 112 def test_L2CAP_CMC_BV_01_C(self): 113 """ 114 L2CAP/CMC/BV-01-C [IUT Initiated Configuration of Enhanced Retransmission Mode] 115 Verify the IUT can send a Configuration Request command containing the F&EC option that specifies 116 Enhanced Retransmission Mode. 117 """ 118 with self._dut_connection_close_stream() as dut_connection_close_stream: 119 psm = 1 120 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 121 self.device_under_test.l2cap.SetDynamicChannel( 122 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 123 self._assert_connection_close(dut_connection_close_stream) 124 125 def test_L2CAP_CMC_BV_02_C(self): 126 """ 127 L2CAP/CMC/BV-02-C [Lower Tester Initiated Configuration of Enhanced Retransmission Mode] 128 Verify the IUT can accept a Configuration Request from the Lower Tester containing an F&EC option 129 that specifies Enhanced Retransmission Mode. 130 """ 131 with self._dut_connection_close_stream() as dut_connection_close_stream: 132 psm = 1 133 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 134 self.device_under_test.l2cap.SetDynamicChannel( 135 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 136 self._assert_connection_close(dut_connection_close_stream) 137 138 def test_L2CAP_ERM_BV_01_C(self): 139 """ 140 L2CAP/ERM/BV-01-C [Transmit I-frames] 141 Verify the IUT can send correctly formatted sequential I-frames with valid values for the enhanced 142 control fields (SAR, F-bit, ReqSeq, TxSeq). 143 """ 144 with self._dut_connection_stream() as dut_connection_stream, \ 145 self._dut_connection_close_stream() as dut_connection_close_stream: 146 psm = 1 147 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 148 self.device_under_test.l2cap.SetDynamicChannel( 149 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 150 self._assert_connection_complete(dut_connection_stream) 151 self.device_under_test.l2cap.SendDynamicChannelPacket( 152 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 153 self.device_under_test.l2cap.SendDynamicChannelPacket( 154 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 155 self.device_under_test.l2cap.SendDynamicChannelPacket( 156 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 157 self._assert_connection_close(dut_connection_close_stream) 158 159 def test_L2CAP_ERM_BV_02_C(self): 160 """ 161 L2CAP/ERM/BV-02-C [Receive I-Frames] 162 Verify the IUT can receive in-sequence valid I-frames and deliver L2CAP SDUs to the Upper Tester 163 """ 164 with self._dut_connection_stream() as dut_connection_stream, \ 165 self._dut_connection_close_stream() as dut_connection_close_stream: 166 psm = 1 167 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 168 self.device_under_test.l2cap.SetDynamicChannel( 169 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 170 self._assert_connection_complete(dut_connection_stream) 171 self._assert_connection_close(dut_connection_close_stream) 172 173 def test_L2CAP_ERM_BV_03_C(self): 174 """ 175 L2CAP/ERM/BV-03-C [Acknowledging Received I-Frames] 176 """ 177 with self._dut_connection_stream() as dut_connection_stream, \ 178 self._dut_connection_close_stream() as dut_connection_close_stream: 179 psm = 1 180 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 181 self.device_under_test.l2cap.SetDynamicChannel( 182 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 183 self._assert_connection_complete(dut_connection_stream) 184 self._assert_connection_close(dut_connection_close_stream) 185 186 def test_L2CAP_ERM_BV_05_C(self): 187 """ 188 L2CAP/ERM/BV-05-C [Resume Transmitting I-Frames when an S-Frame [RR] is Received] 189 Verify the IUT will cease transmission of I-frames when the negotiated TxWindow is full. Verify the 190 IUT will resume transmission of I-frames when an S-frame [RR] is received that acknowledges 191 previously sent I-frames. 192 """ 193 with self._dut_connection_stream() as dut_connection_stream, \ 194 self._dut_connection_close_stream() as dut_connection_close_stream: 195 psm = 1 196 197 self.device_under_test.l2cap.SetDynamicChannel( 198 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 199 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 200 self._assert_connection_complete(dut_connection_stream) 201 self.device_under_test.l2cap.SendDynamicChannelPacket( 202 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 203 self.device_under_test.l2cap.SendDynamicChannelPacket( 204 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 205 self._assert_connection_close(dut_connection_close_stream) 206 207 def test_L2CAP_ERM_BV_06_C(self): 208 """ 209 L2CAP/ERM/BV-06-C [Resume Transmitting I-Frames when an I-Frame is Received] 210 Verify the IUT will cease transmission of I-frames when the negotiated TxWindow is full. Verify the 211 IUT will resume transmission of I-frames when an I-frame is received that acknowledges previously 212 sent I-frames. 213 """ 214 with self._dut_connection_stream() as dut_connection_stream, \ 215 self._dut_connection_close_stream() as dut_connection_close_stream: 216 psm = 1 217 218 self.device_under_test.l2cap.SetDynamicChannel( 219 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 220 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 221 self._assert_connection_complete(dut_connection_stream) 222 self.device_under_test.l2cap.SendDynamicChannelPacket( 223 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 224 self.device_under_test.l2cap.SendDynamicChannelPacket( 225 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 226 self._assert_connection_close(dut_connection_close_stream) 227 228 def test_L2CAP_ERM_BV_08_C(self): 229 """ 230 L2CAP/ERM/BV-08-C [Send S-Frame [RR] with Poll Bit Set] 231 Verify the IUT sends an S-frame [RR] with the Poll bit set when its retransmission timer expires. 232 """ 233 with self._dut_connection_stream() as dut_connection_stream, \ 234 self._dut_connection_close_stream() as dut_connection_close_stream: 235 psm = 1 236 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 237 self.device_under_test.l2cap.SetDynamicChannel( 238 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 239 self._assert_connection_complete(dut_connection_stream) 240 self.device_under_test.l2cap.SendDynamicChannelPacket( 241 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 242 self._assert_connection_close(dut_connection_close_stream) 243 244 def test_L2CAP_ERM_BV_09_C(self): 245 """ 246 L2CAP/ERM/BV-09-C [Send S-frame [RR] with Final Bit Set] 247 Verify the IUT responds with an S-frame [RR] with the Final bit set after receiving an S-frame [RR] 248 with the Poll bit set. 249 """ 250 with self._dut_connection_stream() as dut_connection_stream, \ 251 self._dut_connection_close_stream() as dut_connection_close_stream: 252 psm = 1 253 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 254 self.device_under_test.l2cap.SetDynamicChannel( 255 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 256 self._assert_connection_complete(dut_connection_stream) 257 self._assert_connection_close(dut_connection_close_stream) 258 259 def test_L2CAP_ERM_BV_10_C(self): 260 """ 261 L2CAP/ERM/BV-10-C [Retransmit S-Frame [RR] with Poll Bit Set] 262 Verify the IUT will retransmit the S-frame [RR] with the Poll bit set when the Monitor Timer expires. 263 """ 264 with self._dut_connection_stream() as dut_connection_stream, \ 265 self._dut_connection_close_stream() as dut_connection_close_stream: 266 psm = 1 267 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 268 self.device_under_test.l2cap.SetDynamicChannel( 269 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 270 self._assert_connection_complete(dut_connection_stream) 271 self.device_under_test.l2cap.SendDynamicChannelPacket( 272 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 273 self._assert_connection_close(dut_connection_close_stream) 274 275 def test_L2CAP_ERM_BV_13_C(self): 276 """ 277 L2CAP/ERM/BV-13-C [Respond to S-Frame [REJ]] 278 """ 279 with self._dut_connection_stream() as dut_connection_stream, \ 280 self._dut_connection_close_stream() as dut_connection_close_stream: 281 psm = 1 282 283 self.device_under_test.l2cap.SetDynamicChannel( 284 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 285 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 286 self._assert_connection_complete(dut_connection_stream) 287 self.device_under_test.l2cap.SendDynamicChannelPacket( 288 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 289 self.device_under_test.l2cap.SendDynamicChannelPacket( 290 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 291 self._assert_connection_close(dut_connection_close_stream) 292 293 def test_L2CAP_ERM_BV_16_C(self): 294 """ 295 L2CAP/ERM/BV-16-C [Send S-Frame [REJ]] 296 Verify the IUT can send an S-frame [REJ] after receiving out of sequence I-frames. 297 """ 298 with self._dut_connection_stream() as dut_connection_stream, \ 299 self._dut_connection_close_stream() as dut_connection_close_stream: 300 psm = 1 301 302 self.device_under_test.l2cap.SetDynamicChannel( 303 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 304 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 305 self._assert_connection_complete(dut_connection_stream) 306 self._assert_connection_close(dut_connection_close_stream, timeout=60) 307 308 def test_L2CAP_ERM_BV_18_C(self): 309 """ 310 L2CAP/ERM/BV-18-C [Receive S-Frame [RR] Final Bit = 1] 311 Verify the IUT will retransmit any previously sent I-frames unacknowledged by receipt of an S-Frame 312 [RR] with the Final Bit set. 313 """ 314 with self._dut_connection_stream() as dut_connection_stream, \ 315 self._dut_connection_close_stream() as dut_connection_close_stream: 316 psm = 1 317 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 318 self.device_under_test.l2cap.SetDynamicChannel( 319 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 320 self._assert_connection_complete(dut_connection_stream) 321 self.device_under_test.l2cap.SendDynamicChannelPacket( 322 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 323 self._assert_connection_close(dut_connection_close_stream) 324 325 def test_L2CAP_ERM_BV_19_C(self): 326 """ 327 L2CAP/ERM/BV-19-C [Receive I-Frame Final Bit = 1] 328 Verify the IUT will retransmit any previously sent I-frames unacknowledged by receipt of an I-frame 329 with the final bit set. 330 """ 331 with self._dut_connection_stream() as dut_connection_stream, \ 332 self._dut_connection_close_stream() as dut_connection_close_stream: 333 psm = 1 334 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 335 self.device_under_test.l2cap.SetDynamicChannel( 336 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 337 self._assert_connection_complete(dut_connection_stream) 338 self.device_under_test.l2cap.SendDynamicChannelPacket( 339 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 340 self._assert_connection_close(dut_connection_close_stream) 341 342 def test_L2CAP_ERM_BV_20_C(self): 343 """ 344 L2CAP/ERM/BV-20-C [Enter Remote Busy Condition] 345 Verify the IUT will not retransmit any I-frames when it receives a remote busy indication from the 346 Lower Tester (S-frame [RNR]). 347 """ 348 with self._dut_connection_stream() as dut_connection_stream, \ 349 self._dut_connection_close_stream() as dut_connection_close_stream: 350 psm = 1 351 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 352 self.device_under_test.l2cap.SetDynamicChannel( 353 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 354 self._assert_connection_complete(dut_connection_stream) 355 self.device_under_test.l2cap.SendDynamicChannelPacket( 356 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 357 self._assert_connection_close(dut_connection_close_stream) 358 359 def test_L2CAP_COS_CED_BV_01_C(self): 360 """ 361 L2CAP/COS/CED/BV-01-C [Request Connection] 362 Verify that the IUT is able to request the connection establishment for an L2CAP data channel and 363 initiate the configuration procedure. 364 """ 365 with self._dut_connection_stream() as dut_connection_stream, \ 366 self._dut_connection_close_stream() as dut_connection_close_stream: 367 psm = 1 368 self.device_under_test.l2cap.OpenChannel( 369 l2cap_facade_pb2.OpenChannelRequest(remote=self.pts_address, psm=psm)) 370 self._assert_connection_complete(dut_connection_stream) 371 372 self.device_under_test.l2cap.CloseChannel(l2cap_facade_pb2.CloseChannelRequest(psm=psm)) 373 self._assert_connection_close(dut_connection_close_stream) 374 375 def test_L2CAP_COS_CED_BV_03_C(self): 376 """ 377 L2CAP/COS/CED/BV-03-C [Send Data] 378 Verify that the IUT is able to send DATA. 379 """ 380 with self._dut_connection_stream() as dut_connection_stream, \ 381 self._dut_connection_close_stream() as dut_connection_close_stream: 382 psm = 1 383 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 384 self.device_under_test.l2cap.SetDynamicChannel( 385 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 386 self._assert_connection_complete(dut_connection_stream) 387 388 self.device_under_test.l2cap.SendDynamicChannelPacket( 389 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc' * 34)) 390 self._assert_connection_close(dut_connection_close_stream) 391 392 def test_L2CAP_COS_CED_BV_04_C(self): 393 """ 394 L2CAP/COS/CED/BV-04-C [Disconnect] 395 Verify that the IUT is able to disconnect the data channel. 396 """ 397 with self._dut_connection_stream() as dut_connection_stream, \ 398 self._dut_connection_close_stream() as dut_connection_close_stream: 399 psm = 1 400 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 401 self.device_under_test.l2cap.SetDynamicChannel( 402 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 403 self._assert_connection_complete(dut_connection_stream) 404 time.sleep(2) 405 self.device_under_test.l2cap.CloseChannel(l2cap_facade_pb2.CloseChannelRequest(psm=psm)) 406 self._assert_connection_close(dut_connection_close_stream) 407 408 def test_L2CAP_COS_CED_BV_05_C(self): 409 """ 410 L2CAP/COS/CED/BV-05-C [Accept Connection] 411 Verify that the IUT is able to disconnect the data channel. 412 """ 413 with self._dut_connection_stream() as dut_connection_stream, \ 414 self._dut_connection_close_stream() as dut_connection_close_stream: 415 psm = 1 416 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 417 self.device_under_test.l2cap.SetDynamicChannel( 418 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 419 self._assert_connection_complete(dut_connection_stream) 420 self._assert_connection_close(dut_connection_close_stream) 421 422 def test_L2CAP_COS_CED_BV_07_C(self): 423 """ 424 L2CAP/COS/CED/BV-07-C [Accept Disconnect] 425 Verify that the IUT is able to respond to the request to disconnect the data channel. 426 """ 427 with self._dut_connection_stream() as dut_connection_stream, \ 428 self._dut_connection_close_stream() as dut_connection_close_stream: 429 psm = 1 430 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 431 self.device_under_test.l2cap.SetDynamicChannel( 432 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 433 self._assert_connection_complete(dut_connection_stream) 434 self._assert_connection_close(dut_connection_close_stream) 435 436 def test_L2CAP_COS_CED_BV_08_C(self): 437 """ 438 L2CAP/COS/CED/BV-08-C [Disconnect on Timeout] 439 Verify that the IUT disconnects the data channel and shuts down this channel if no response occurs 440 """ 441 with self._dut_connection_stream() as dut_connection_stream, \ 442 self._dut_connection_close_stream() as dut_connection_close_stream: 443 psm = 1 444 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 445 self.device_under_test.l2cap.SetDynamicChannel( 446 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 447 time.sleep(120) 448 449 def test_L2CAP_COS_CED_BV_09_C(self): 450 """ 451 L2CAP/COS/CED/BV-09-C [Receive Multi-Command Packet] 452 Verify that the IUT is able to receive more than one signaling command in one L2CAP packet. 453 """ 454 with self._dut_connection_stream() as dut_connection_stream, \ 455 self._dut_connection_close_stream() as dut_connection_close_stream: 456 psm = 1 457 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 458 self.device_under_test.l2cap.SetDynamicChannel( 459 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 460 self._assert_connection_complete(dut_connection_stream) 461 self._assert_connection_close(dut_connection_close_stream) 462 463 def test_L2CAP_COS_CED_BV_11_C(self): 464 """ 465 L2CAP/COS/CED/BV-11-C [Configure MTU Size] 466 Verify that the IUT is able to configure the supported MTU size 467 """ 468 with self._dut_connection_stream() as dut_connection_stream, \ 469 self._dut_connection_close_stream() as dut_connection_close_stream: 470 psm = 1 471 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 472 self.device_under_test.l2cap.SetDynamicChannel( 473 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 474 self._assert_connection_complete(dut_connection_stream) 475 self._assert_connection_close(dut_connection_close_stream) 476 477 def test_L2CAP_COS_CED_BI_01_C(self): 478 """ 479 L2CAP/COS/CED/BI-01-C [Reject Unknown Command] 480 Verify that the IUT rejects an unknown signaling command. 481 """ 482 with self._dut_connection_stream() as dut_connection_stream, \ 483 self._dut_connection_close_stream() as dut_connection_close_stream: 484 psm = 1 485 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 486 self.device_under_test.l2cap.SetDynamicChannel( 487 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 488 self._assert_connection_complete(dut_connection_stream) 489 time.sleep(5) 490 491 def test_L2CAP_COS_CFD_BV_03_C(self): 492 """ 493 L2CAP/COS/CFD/BV-03-C [Send Requested Options] 494 Verify that the IUT can receive a configuration request with no options and send the requested 495 options to the Lower Tester 496 """ 497 with self._dut_connection_stream() as dut_connection_stream, \ 498 self._dut_connection_close_stream() as dut_connection_close_stream: 499 psm = 1 500 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.BASIC 501 self.device_under_test.l2cap.SetDynamicChannel( 502 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 503 self._assert_connection_close(dut_connection_close_stream) 504 505 def test_L2CAP_COS_CFD_BV_08_C(self): 506 """ 507 L2CAP/COS/CFD/BV-08-C [Non-blocking Config Response] 508 Verify that the IUT does not block transmitting L2CAP_ConfigRsp while waiting for L2CAP_ConfigRsp 509 from the Lower Tester. 510 """ 511 with self._dut_connection_stream() as dut_connection_stream, \ 512 self._dut_connection_close_stream() as dut_connection_close_stream: 513 psm = 1 514 515 self.device_under_test.l2cap.OpenChannel( 516 l2cap_facade_pb2.OpenChannelRequest(remote=self.pts_address, psm=psm)) 517 self._assert_connection_complete(dut_connection_stream) 518 self.device_under_test.l2cap.CloseChannel(l2cap_facade_pb2.CloseChannelRequest(psm=psm)) 519 self._assert_connection_close(dut_connection_close_stream) 520 521 def test_L2CAP_ERM_BI_01_C(self): 522 """ 523 L2CAP/ERM/BI-01-C [S-Frame [REJ] Lost or Corrupted] 524 Verify the IUT can handle receipt of an S-=frame [RR] Poll = 1 if the S-frame [REJ] sent from the IUT 525 is lost. 526 """ 527 with self._dut_connection_stream() as dut_connection_stream, \ 528 self._dut_connection_close_stream() as dut_connection_close_stream: 529 psm = 1 530 retransmission_mode = l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM 531 self.device_under_test.l2cap.SetDynamicChannel( 532 l2cap_facade_pb2.SetEnableDynamicChannelRequest(psm=psm, retransmission_mode=retransmission_mode)) 533 self._assert_connection_complete(dut_connection_stream) 534 self._assert_connection_close(dut_connection_close_stream) 535 536 def test_L2CAP_ERM_BI_03_C(self): 537 """ 538 L2CAP/ERM/BI-03-C [Handle Duplicate S-Frame [SREJ]] 539 """ 540 with self._dut_connection_stream() as dut_connection_stream, \ 541 self._dut_connection_close_stream() as dut_connection_close_stream: 542 psm = 1 543 544 self.device_under_test.l2cap.SetDynamicChannel( 545 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 546 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 547 self._assert_connection_complete(dut_connection_stream) 548 self.device_under_test.l2cap.SendDynamicChannelPacket( 549 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 550 self.device_under_test.l2cap.SendDynamicChannelPacket( 551 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 552 self._assert_connection_close(dut_connection_close_stream) 553 554 def test_L2CAP_ERM_BI_04_C(self): 555 """ 556 L2CAP/ERM/BI-04-C [Handle Receipt of S-Frame [REJ] and S-Frame [RR, F=1] 557 that Both Require Retransmission of the Same I-Frames] 558 """ 559 with self._dut_connection_stream() as dut_connection_stream, \ 560 self._dut_connection_close_stream() as dut_connection_close_stream: 561 psm = 1 562 563 self.device_under_test.l2cap.SetDynamicChannel( 564 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 565 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 566 self._assert_connection_complete(dut_connection_stream) 567 self.device_under_test.l2cap.SendDynamicChannelPacket( 568 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 569 self.device_under_test.l2cap.SendDynamicChannelPacket( 570 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 571 self._assert_connection_close(dut_connection_close_stream) 572 573 def test_L2CAP_ERM_BI_05_C(self): 574 """ 575 L2CAP/ERM/BI-05-C [Handle receipt of S-Frame [REJ] and I-Frame [F=1] that 576 Both Require Retransmission of the Same I-Frames] 577 """ 578 with self._dut_connection_stream() as dut_connection_stream, \ 579 self._dut_connection_close_stream() as dut_connection_close_stream: 580 psm = 1 581 582 self.device_under_test.l2cap.SetDynamicChannel( 583 l2cap_facade_pb2.SetEnableDynamicChannelRequest( 584 psm=psm, retransmission_mode=l2cap_facade_pb2.RetransmissionFlowControlMode.ERTM)) 585 self._assert_connection_complete(dut_connection_stream) 586 self.device_under_test.l2cap.SendDynamicChannelPacket( 587 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 588 self.device_under_test.l2cap.SendDynamicChannelPacket( 589 l2cap_facade_pb2.DynamicChannelPacket(psm=psm, payload=b'abc')) 590 self._assert_connection_close(dut_connection_close_stream) 591