def test_dispatch_connect_by_name(self, llc, dlc): llc.dispatch(nfc.llcp.pdu.Connect(1, 32, sn=b'urn:nfc:sn:service')) assert llc.collect() == nfc.llcp.pdu.DisconnectedMode(32, 1, 2) llc.bind(dlc, b'urn:nfc:sn:service') llc.listen(dlc, 1) llc.dispatch(nfc.llcp.pdu.Connect(1, 32, sn=b'urn:nfc:sn:service')) llc.accept(dlc) assert llc.collect() == nfc.llcp.pdu.ConnectionComplete(32, 16)
def test_accept_send_cc(self, llc, dlc): llc.bind(dlc, b'urn:nfc:sn:snep') llc.listen(dlc, 0) threading.Timer(0, llc.accept, (dlc,)).start() time.sleep(0.01) llc.dispatch(nfc.llcp.pdu.Connect(4, 32)) pdu = llc.collect(0.01) assert isinstance(pdu, nfc.llcp.pdu.ConnectionComplete) assert pdu.dsap == 32 and pdu.ssap == 4
def collect_and_dispatch(llc): tid = llc.collect().sdreq[0][0] pdu = nfc.llcp.pdu.ServiceNameLookup(1, 1, sdres=[(tid, sap)]) llc.dispatch(pdu)
def test_dispatch_to_inactive_sap(self, llc): llc.dispatch(nfc.llcp.pdu.UnnumberedInformation(63, 63))
def test_dispatch_aggregated_frame(self, llc): aggregate = 3 * [nfc.llcp.pdu.Symmetry()] llc.dispatch(nfc.llcp.pdu.AggregatedFrame(0, 0, aggregate)) llc.dispatch(nfc.llcp.pdu.AggregatedFrame(1, 0, aggregate))
def collect_and_dispatch(llc): llc.collect() llc.dispatch(nfc.llcp.pdu.ConnectionComplete(32, 16, peer_miu))