WPS: Move NFC tag processing into a separate function
This makes it cleaner to add processing of other NFC operations to the python script. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
ec4f5a37b8
commit
dab710c4d0
1 changed files with 29 additions and 22 deletions
|
@ -46,22 +46,8 @@ def wpas_tag_read(message):
|
|||
return
|
||||
print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex"))
|
||||
|
||||
def main():
|
||||
clf = nfc.ContactlessFrontend()
|
||||
|
||||
try:
|
||||
while True:
|
||||
print "Waiting for a tag to be touched"
|
||||
|
||||
while True:
|
||||
tag = clf.poll()
|
||||
if tag and tag.ndef:
|
||||
break
|
||||
if tag:
|
||||
print "Not an NDEF tag"
|
||||
while tag.is_present:
|
||||
time.sleep(0.2)
|
||||
|
||||
def wps_tag_read(tag):
|
||||
if len(tag.ndef.message):
|
||||
message = nfc.ndef.Message(tag.ndef.message)
|
||||
print "message type " + message.type
|
||||
|
@ -77,9 +63,30 @@ def main():
|
|||
|
||||
print "Remove tag"
|
||||
while tag.is_present:
|
||||
time.sleep(0.2)
|
||||
time.sleep(0.1)
|
||||
|
||||
print "Ok"
|
||||
|
||||
def main():
|
||||
clf = nfc.ContactlessFrontend()
|
||||
|
||||
try:
|
||||
while True:
|
||||
print "Waiting for a tag to be touched"
|
||||
|
||||
while True:
|
||||
tag = clf.poll()
|
||||
if tag == None:
|
||||
continue
|
||||
|
||||
if tag.ndef:
|
||||
wps_tag_read(tag)
|
||||
break
|
||||
|
||||
if tag:
|
||||
print "Not an NDEF tag - remove tag"
|
||||
while tag.is_present:
|
||||
time.sleep(0.1)
|
||||
break
|
||||
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit
|
||||
|
|
Loading…
Reference in a new issue