WPS: Allow password token to be written with nfcpy
This adds write-password option for the nfcpy example script for wpa_supplicant to match hostapd wps-ap-nfc.py functionality. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
042ec551d4
commit
23ffcaf172
1 changed files with 33 additions and 0 deletions
|
@ -54,6 +54,13 @@ def wpas_tag_read(message):
|
||||||
print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex"))
|
print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex"))
|
||||||
|
|
||||||
|
|
||||||
|
def wpas_get_password_token():
|
||||||
|
wpas = wpas_connect()
|
||||||
|
if (wpas == None):
|
||||||
|
return None
|
||||||
|
return wpas.request("WPS_NFC_TOKEN NDEF").rstrip().decode("hex")
|
||||||
|
|
||||||
|
|
||||||
def wpas_get_handover_req():
|
def wpas_get_handover_req():
|
||||||
wpas = wpas_connect()
|
wpas = wpas_connect()
|
||||||
if (wpas == None):
|
if (wpas == None):
|
||||||
|
@ -162,6 +169,28 @@ def wps_tag_read(tag):
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
|
def wps_write_password_tag(clf):
|
||||||
|
print "Write WPS password token"
|
||||||
|
data = wpas_get_password_token()
|
||||||
|
if (data == None):
|
||||||
|
print "Could not get WPS password token from wpa_supplicant"
|
||||||
|
return
|
||||||
|
|
||||||
|
print "Touch an NFC tag"
|
||||||
|
while True:
|
||||||
|
tag = clf.poll()
|
||||||
|
if tag == None:
|
||||||
|
time.sleep(0.1)
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
|
||||||
|
print "Tag found - writing"
|
||||||
|
tag.ndef.message = data
|
||||||
|
print "Done - remove tag"
|
||||||
|
while tag.is_present:
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
def find_peer(clf):
|
def find_peer(clf):
|
||||||
while True:
|
while True:
|
||||||
if nfc.llcp.connected():
|
if nfc.llcp.connected():
|
||||||
|
@ -194,6 +223,10 @@ def main():
|
||||||
clf = nfc.ContactlessFrontend()
|
clf = nfc.ContactlessFrontend()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] == "write-password":
|
||||||
|
wps_write_password_tag(clf)
|
||||||
|
raise SystemExit
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print "Waiting for a tag or peer to be touched"
|
print "Waiting for a tag or peer to be touched"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue