diff --git a/examples/provisioning/ble_prov/ble_prov_test.py b/examples/provisioning/ble_prov/ble_prov_test.py index 1e3e8508b..91c5bb4bf 100644 --- a/examples/provisioning/ble_prov/ble_prov_test.py +++ b/examples/provisioning/ble_prov/ble_prov_test.py @@ -87,9 +87,9 @@ def test_examples_provisioning_ble(env, extra_data): time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) - if (ret == 1): + if (ret == "connecting"): continue - elif (ret == 0): + elif (ret == "connected"): print("Provisioning was successful") success = True break diff --git a/examples/provisioning/manager/wifi_prov_mgr_test.py b/examples/provisioning/manager/wifi_prov_mgr_test.py index 7afa584fe..0433659b2 100644 --- a/examples/provisioning/manager/wifi_prov_mgr_test.py +++ b/examples/provisioning/manager/wifi_prov_mgr_test.py @@ -92,12 +92,12 @@ def test_examples_wifi_prov_mgr(env, extra_data): time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) - if (ret == 1): + if (ret == "connecting"): continue - elif (ret == 0): + elif (ret == "connected"): print("Provisioning was successful") success = True - elif (ret == 3 and retry < 3): + elif (ret == "failed" and retry < 3): retry = retry + 1 print("Connection failed.. retry again...: ", ret) continue diff --git a/examples/provisioning/softap_prov/softap_prov_test.py b/examples/provisioning/softap_prov/softap_prov_test.py index 86376a384..8c5641fa1 100644 --- a/examples/provisioning/softap_prov/softap_prov_test.py +++ b/examples/provisioning/softap_prov/softap_prov_test.py @@ -101,9 +101,9 @@ def test_examples_provisioning_softap(env, extra_data): time.sleep(5) print("Wi-Fi connection state") ret = esp_prov.get_wifi_config(transport, security) - if (ret == 1): + if (ret == "connecting"): continue - elif (ret == 0): + elif (ret == "connected"): print("Provisioning was successful") success = True break diff --git a/tools/esp_prov/esp_prov.py b/tools/esp_prov/esp_prov.py index 3ce67d700..9a16252e5 100644 --- a/tools/esp_prov/esp_prov.py +++ b/tools/esp_prov/esp_prov.py @@ -453,9 +453,9 @@ if __name__ == '__main__': time.sleep(5) print("\n==== Wi-Fi connection state ====") ret = get_wifi_config(obj_transport, obj_security) - if (ret == 1): + if (ret == "connecting"): continue - elif (ret == 0): + elif (ret == "connected"): print("==== Provisioning was successful ====") else: print("---- Provisioning failed ----") diff --git a/tools/esp_prov/prov/wifi_prov.py b/tools/esp_prov/prov/wifi_prov.py index 9140291f9..11e4c0bde 100644 --- a/tools/esp_prov/prov/wifi_prov.py +++ b/tools/esp_prov/prov/wifi_prov.py @@ -45,19 +45,25 @@ def config_get_status_response(security_ctx, response_data): cmd_resp1.ParseFromString(decrypted_message) print_verbose(security_ctx, "Response type " + str(cmd_resp1.msg)) print_verbose(security_ctx, "Response status " + str(cmd_resp1.resp_get_status.status)) + if cmd_resp1.resp_get_status.sta_state == 0: print("++++ WiFi state: " + "connected ++++") + return "connected" elif cmd_resp1.resp_get_status.sta_state == 1: print("++++ WiFi state: " + "connecting... ++++") + return "connecting" elif cmd_resp1.resp_get_status.sta_state == 2: print("++++ WiFi state: " + "disconnected ++++") + return "disconnected" elif cmd_resp1.resp_get_status.sta_state == 3: print("++++ WiFi state: " + "connection failed ++++") if cmd_resp1.resp_get_status.fail_reason == 0: print("++++ Failure reason: " + "Incorrect Password ++++") elif cmd_resp1.resp_get_status.fail_reason == 1: print("++++ Failure reason: " + "Incorrect SSID ++++") - return cmd_resp1.resp_get_status.sta_state + return "failed" + return "unknown" + def config_set_config_request(security_ctx, ssid, passphrase):