aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2013-02-15 09:29:37 (GMT)
committerJouni Malinen <j@w1.fi>2013-02-15 09:34:13 (GMT)
commit23ffcaf172f2b601abd423ff2e9cd9d78773ce92 (patch)
tree5d233394eb12bc9952fcdcbbd49b6f54bae61519 /wpa_supplicant/examples
parent042ec551d4ff2ffb8e0eec4708e4bbefcaea804c (diff)
downloadhostap-23ffcaf172f2b601abd423ff2e9cd9d78773ce92.zip
hostap-23ffcaf172f2b601abd423ff2e9cd9d78773ce92.tar.gz
hostap-23ffcaf172f2b601abd423ff2e9cd9d78773ce92.tar.bz2
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>
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-xwpa_supplicant/examples/wps-nfc.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/wpa_supplicant/examples/wps-nfc.py b/wpa_supplicant/examples/wps-nfc.py
index f1b29ac..4d00a3a 100755
--- a/wpa_supplicant/examples/wps-nfc.py
+++ b/wpa_supplicant/examples/wps-nfc.py
@@ -54,6 +54,13 @@ def wpas_tag_read(message):
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():
wpas = wpas_connect()
if (wpas == None):
@@ -162,6 +169,28 @@ def wps_tag_read(tag):
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):
while True:
if nfc.llcp.connected():
@@ -194,6 +223,10 @@ def main():
clf = nfc.ContactlessFrontend()
try:
+ if len(sys.argv) > 1 and sys.argv[1] == "write-password":
+ wps_write_password_tag(clf)
+ raise SystemExit
+
while True:
print "Waiting for a tag or peer to be touched"