aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2013-02-15 09:45:29 (GMT)
committerJouni Malinen <j@w1.fi>2013-02-15 09:47:52 (GMT)
commitbbf41865c90c2e16510712fa32290729c194422d (patch)
tree499cebbd8000a7ac666d27382ee3bf0be45a23e4 /wpa_supplicant/examples
parent23ffcaf172f2b601abd423ff2e9cd9d78773ce92 (diff)
downloadhostap-bbf41865c90c2e16510712fa32290729c194422d.zip
hostap-bbf41865c90c2e16510712fa32290729c194422d.tar.gz
hostap-bbf41865c90c2e16510712fa32290729c194422d.tar.bz2
WPS: Add support for config token generation with wpa_supplicant
When wpa_supplicant is controlling an AP mode interface, it can generate the NFC configuration token similarly to the way this is done in hostapd. 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 4d00a3a..14acc5b 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_config_token():
+ wpas = wpas_connect()
+ if (wpas == None):
+ return None
+ return wpas.request("WPS_NFC_CONFIG_TOKEN NDEF").rstrip().decode("hex")
+
+
def wpas_get_password_token():
wpas = wpas_connect()
if (wpas == None):
@@ -169,6 +176,28 @@ def wps_tag_read(tag):
time.sleep(0.1)
+def wps_write_config_tag(clf):
+ print "Write WPS config token"
+ data = wpas_get_config_token()
+ if (data == None):
+ print "Could not get WPS config 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 wps_write_password_tag(clf):
print "Write WPS password token"
data = wpas_get_password_token()
@@ -223,6 +252,10 @@ def main():
clf = nfc.ContactlessFrontend()
try:
+ if len(sys.argv) > 1 and sys.argv[1] == "write-config":
+ wps_write_config_tag(clf)
+ raise SystemExit
+
if len(sys.argv) > 1 and sys.argv[1] == "write-password":
wps_write_password_tag(clf)
raise SystemExit