aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-11-04 13:53:33 (GMT)
committerJouni Malinen <j@w1.fi>2012-11-04 13:53:33 (GMT)
commitec4f5a37b8fc3612be2353133be97af92c8a4667 (patch)
tree2a4a6e971214bd564b7d09ff022432ca60a961b4 /wpa_supplicant/examples
parentd4f612b7ddae6863d09bdb70b188a3d75a7cddb4 (diff)
downloadhostap-ec4f5a37b8fc3612be2353133be97af92c8a4667.zip
hostap-ec4f5a37b8fc3612be2353133be97af92c8a4667.tar.gz
hostap-ec4f5a37b8fc3612be2353133be97af92c8a4667.tar.bz2
WPS: Move wpactrl setup into a separate function
This makes it easier to share this functionality for new NFC use cases. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-xwpa_supplicant/examples/wps-nfc.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/wpa_supplicant/examples/wps-nfc.py b/wpa_supplicant/examples/wps-nfc.py
index 753e9d1..39c206f 100755
--- a/wpa_supplicant/examples/wps-nfc.py
+++ b/wpa_supplicant/examples/wps-nfc.py
@@ -17,26 +17,34 @@ import wpactrl
wpas_ctrl = '/var/run/wpa_supplicant'
-def wpas_tag_read(message):
+def wpas_connect():
ifaces = []
if os.path.isdir(wpas_ctrl):
try:
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
except OSError, error:
print "Could not find wpa_supplicant: ", error
- return
+ return None
if len(ifaces) < 1:
print "No wpa_supplicant control interface found"
- return
+ return None
for ctrl in ifaces:
try:
wpas = wpactrl.WPACtrl(ctrl)
- print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex"))
+ return wpas
except wpactrl.error, error:
print "Error: ", error
pass
+ return None
+
+
+def wpas_tag_read(message):
+ wpas = wpas_connect()
+ if (wpas == None):
+ return
+ print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex"))
def main():
clf = nfc.ContactlessFrontend()