diff options
author | Jouni Malinen <jouni@qca.qualcomm.com> | 2014-02-11 17:33:43 (GMT) |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2014-02-11 17:33:43 (GMT) |
commit | 7bea07645899fbb6fd27e1e9b5fca426835e4fe2 (patch) | |
tree | 6fe9c670f24850d36f6186b0c57201a5b6418323 /wpa_supplicant/examples | |
parent | b0d18bc2a1bd20cb81a2fbb51126a3a7f2ab417a (diff) | |
download | hostap-7bea07645899fbb6fd27e1e9b5fca426835e4fe2.zip hostap-7bea07645899fbb6fd27e1e9b5fca426835e4fe2.tar.gz hostap-7bea07645899fbb6fd27e1e9b5fca426835e4fe2.tar.bz2 |
P2P NFC: Clean up p2p-nfc.py error handling
If wpa_supplicant reports a failure when trying to generate a handover
request, detect that before trying to decode the response as a hex
string.
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-x | wpa_supplicant/examples/p2p-nfc.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/wpa_supplicant/examples/p2p-nfc.py b/wpa_supplicant/examples/p2p-nfc.py index 848f79f..03d1a27 100755 --- a/wpa_supplicant/examples/p2p-nfc.py +++ b/wpa_supplicant/examples/p2p-nfc.py @@ -77,16 +77,19 @@ def wpas_get_handover_req(): wpas = wpas_connect() if (wpas == None): return None - res = wpas.request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip().decode("hex") + res = wpas.request("NFC_GET_HANDOVER_REQ NDEF P2P-CR").rstrip() if "FAIL" in res: return None - return res + return res.decode("hex") def wpas_get_handover_req_wps(): wpas = wpas_connect() if (wpas == None): return None - return wpas.request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip().decode("hex") + res = wpas.request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip() + if "FAIL" in res: + return None + return res.decode("hex") def wpas_get_handover_sel(tag=False): @@ -94,8 +97,12 @@ def wpas_get_handover_sel(tag=False): if (wpas == None): return None if tag: - return wpas.request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip().decode("hex") - return wpas.request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip().decode("hex") + res = wpas.request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip() + else: + res = wpas.request("NFC_GET_HANDOVER_SEL NDEF P2P-CR").rstrip() + if "FAIL" in res: + return None + return res.decode("hex") def wpas_get_handover_sel_wps(): |