Esempio n. 1
0
def dta_pol_p2p(clf, args):
    sot = "004000011002010E".decode("hex")  # start of test command
    gbi = ''  # 'Ffm' + "010111".decode("hex") # general bytes from initiator
    ato = 1.0  # activation timeout
    lto = 1.0  # link timeout

    dep = nfc.dep.Initiator(clf)
    if dep.activate(timeout=ato, brs=1, gbi=gbi) is not None:
        log.info("enter nfc-dep initiator loop")
        log.info("link timeout set to {0} seconds".format(lto))
        try:
            data = dep.exchange(send_data=sot, timeout=lto)
            while data is not None:
                # log.info("rcvd data %s", hexlify(data).decode())
                if data == b"\xFF\xFF\xFF\x01\x01":
                    dep.deactivate(release=False)
                    break
                if data == b"\xFF\xFF\xFF\x01\x02":
                    dep.deactivate(release=True)
                    break
                # log.info("send back %s", hexlify(data).decode())
                data = dep.exchange(send_data=data, timeout=lto)
        except nfc.clf.DigitalProtocolError as error:
            log.error(repr(error))
        finally:
            log.info("exit nfc-dep target loop")
Esempio n. 2
0
def dta_pol_p2p(clf, args):
    sot = "004000011002010E".decode("hex")  # start of test command
    gbi = ''  # 'Ffm' + "010111".decode("hex") # general bytes from initiator
    ato = 1.0  # activation timeout
    lto = 1.0  # link timeout

    dep = nfc.dep.Initiator(clf)
    if dep.activate(timeout=ato, brs=1, gbi=gbi) is not None:
        log.info("enter nfc-dep initiator loop")
        log.info("link timeout set to {0} seconds".format(lto))
        try:
            data = dep.exchange(send_data=sot, timeout=lto)
            while data is not None:
                # log.info("rcvd data {0}".format(data.encode("hex")))
                if data == "FFFFFF0101".decode("hex"):
                    dep.deactivate(release=False)
                    break
                if data == "FFFFFF0102".decode("hex"):
                    dep.deactivate(release=True)
                    break
                # log.info("send back {0}".format(data.encode("hex")))
                data = dep.exchange(send_data=data, timeout=lto)
        except nfc.clf.DigitalProtocolError as error:
            log.error(repr(error))
        finally:
            log.info("exit nfc-dep target loop")
Esempio n. 3
0
def dta_lis_p2p(clf, args):
    dep = nfc.dep.Target(clf)
    gbt = '' #'Ffm' + "010111".decode("hex")
    if dep.activate(timeout=1.0, wt=8, gbt=gbt) is not None:
        log.info("enter nfc-dep target loop")
        rwt = 4096/13.56E6 * 2**8
        data = dep.exchange(None, timeout=1.0)
        while data is not None:
            #log.info("rcvd data {0}".format(data.encode("hex")))
            if data == "FFFFFF0103".decode("hex"):
                if dep.send_timeout_extension(2) == 2:
                    sleep(1.5 * rwt)
                else: break
            if len(data) == 6 and data.startswith("\xFF\x00\x00\x00"):
                log.info("pattern number: " + data[4:6].encode("hex"))
                pattern_number = data[4:6]
            #log.info("send back {0}".format(data.encode("hex")))
            data = dep.exchange(data, timeout=1.0)
        dep.deactivate()
        log.info("exit nfc-dep target loop")
Esempio n. 4
0
def dta_lis_p2p(clf, args):
    dep = nfc.dep.Target(clf)
    gbt = ''  # 'Ffm' + "010111".decode("hex")
    if dep.activate(timeout=1.0, wt=8, gbt=gbt) is not None:
        log.info("enter nfc-dep target loop")
        rwt = 4096/13.56E6 * 2**8
        data = dep.exchange(None, timeout=1.0)
        while data is not None:
            # log.info("rcvd data %s", hexlify(data).decode())
            if data == b"\xFF\xFF\xFF\x01\x03":
                if dep.send_timeout_extension(2) == 2:
                    sleep(1.5 * rwt)
                else:
                    break
            if len(data) == 6 and data.startswith(b"\xFF\x00\x00\x00"):
                log.info("pattern number: %s", hexlify(data[4:6]).decode())
                # pattern_number = data[4:6]
            # log.info("send back %s", hexlify(data).decode())
            data = dep.exchange(data, timeout=1.0)
        dep.deactivate()
        log.info("exit nfc-dep target loop")