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>
This commit is contained in:
parent
d4f612b7dd
commit
ec4f5a37b8
1 changed files with 12 additions and 4 deletions
|
@ -17,26 +17,34 @@ import wpactrl
|
||||||
|
|
||||||
wpas_ctrl = '/var/run/wpa_supplicant'
|
wpas_ctrl = '/var/run/wpa_supplicant'
|
||||||
|
|
||||||
def wpas_tag_read(message):
|
def wpas_connect():
|
||||||
ifaces = []
|
ifaces = []
|
||||||
if os.path.isdir(wpas_ctrl):
|
if os.path.isdir(wpas_ctrl):
|
||||||
try:
|
try:
|
||||||
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
|
ifaces = [os.path.join(wpas_ctrl, i) for i in os.listdir(wpas_ctrl)]
|
||||||
except OSError, error:
|
except OSError, error:
|
||||||
print "Could not find wpa_supplicant: ", error
|
print "Could not find wpa_supplicant: ", error
|
||||||
return
|
return None
|
||||||
|
|
||||||
if len(ifaces) < 1:
|
if len(ifaces) < 1:
|
||||||
print "No wpa_supplicant control interface found"
|
print "No wpa_supplicant control interface found"
|
||||||
return
|
return None
|
||||||
|
|
||||||
for ctrl in ifaces:
|
for ctrl in ifaces:
|
||||||
try:
|
try:
|
||||||
wpas = wpactrl.WPACtrl(ctrl)
|
wpas = wpactrl.WPACtrl(ctrl)
|
||||||
print wpas.request("WPS_NFC_TAG_READ " + message.encode("hex"))
|
return wpas
|
||||||
except wpactrl.error, error:
|
except wpactrl.error, error:
|
||||||
print "Error: ", error
|
print "Error: ", error
|
||||||
pass
|
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():
|
def main():
|
||||||
clf = nfc.ContactlessFrontend()
|
clf = nfc.ContactlessFrontend()
|
||||||
|
|
Loading…
Reference in a new issue