Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import nfc
  2. import time
  3. import socket
  4.  
  5.  
  6. clf = nfc.ContactlessFrontend('tty')
  7.  
  8. UDP_IP = "192.168.100.110"
  9. UDP_PORT = 5005
  10.  
  11. from nfc.clf import RemoteTarget
  12.  
  13. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  14.  
  15. def checkTag(records):
  16. message = records[0].text
  17. print message
  18. sock.sendto(message, (UDP_IP, UDP_PORT))
  19.  
  20.  
  21. time.sleep(5)
  22. main()
  23.  
  24. def main():
  25. tag = clf.connect(rdwr={'on-connect': lambda tag: False})
  26. try:
  27. #assert tag.ndef is not None
  28. if tag.ndef.records != None:
  29. checkTag(tag.ndef.records)
  30. except:
  31. print("error")
  32. time.sleep(2)
  33. main()
  34.  
  35. if __name__ == '__main__':
  36. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement