def onNfcData(self, srcname, srcpeer, otherpeer, data, bytes): def relay(): otherpeer.sendNfcData(srcname, bytes) relay() if srcname == NFCData.READER: print "lastRequestAPDU -> " + strhex(bytes) self.lastRequestAPDU = bytes else: cmd = self.lastRequestAPDU[0] reply = bytes[0] cmdOk = reply == desfire.RESPONSE_OK if cmd == desfire.CMD_SELECT and cmdOk: print "cmd: CMD_SELECT" self.selectedAID = self.lastRequestAPDU[1:] self.onAidSelected(self.lastRequestAPDU[1:]) elif cmd == desfire.CMD_AUTH and reply == desfire.CMD_AUTHPHASE: print "cmd: CMD_AUTH" self.inAuthPhase = True self.onAuthStart() elif cmd == desfire.CMD_AUTHPHASE and reply == desfire.RESPONSE_OK: print "cmd: CMD_AUTHPHASE" self.inAuthPhase = False self.onAuthenticated() return
def printFile(self, fid): reply = self.readFile(fid) print "File " + strhex(fid) + ": " + strhex(reply)