ci provisioning: Use strings instead of "magic numbers" for connection state

This commit is contained in:
Angus Gratton 2020-06-25 15:43:42 +10:00 committed by bot
parent 5e0e4a5f01
commit ae586deeeb
5 changed files with 16 additions and 10 deletions

View File

@ -87,9 +87,9 @@ def test_examples_provisioning_ble(env, extra_data):
time.sleep(5) time.sleep(5)
print("Wi-Fi connection state") print("Wi-Fi connection state")
ret = esp_prov.get_wifi_config(transport, security) ret = esp_prov.get_wifi_config(transport, security)
if (ret == 1): if (ret == "connecting"):
continue continue
elif (ret == 0): elif (ret == "connected"):
print("Provisioning was successful") print("Provisioning was successful")
success = True success = True
break break

View File

@ -101,9 +101,9 @@ def test_examples_provisioning_softap(env, extra_data):
time.sleep(5) time.sleep(5)
print("Wi-Fi connection state") print("Wi-Fi connection state")
ret = esp_prov.get_wifi_config(transport, security) ret = esp_prov.get_wifi_config(transport, security)
if (ret == 1): if (ret == "connecting"):
continue continue
elif (ret == 0): elif (ret == "connected"):
print("Provisioning was successful") print("Provisioning was successful")
success = True success = True
break break

View File

@ -96,12 +96,12 @@ def test_examples_wifi_prov_mgr(env, extra_data):
time.sleep(5) time.sleep(5)
print("Wi-Fi connection state") print("Wi-Fi connection state")
ret = esp_prov.get_wifi_config(transport, security) ret = esp_prov.get_wifi_config(transport, security)
if (ret == 1): if (ret == "connecting"):
continue continue
elif (ret == 0): elif (ret == "connected"):
print("Provisioning was successful") print("Provisioning was successful")
success = True success = True
elif (ret == 3 and retry < 3): elif (ret == "failed" and retry < 3):
retry = retry + 1 retry = retry + 1
print("Connection failed.. retry again...: ", ret) print("Connection failed.. retry again...: ", ret)
continue continue

View File

@ -475,9 +475,9 @@ if __name__ == '__main__':
time.sleep(5) time.sleep(5)
print("\n==== Wi-Fi connection state ====") print("\n==== Wi-Fi connection state ====")
ret = get_wifi_config(obj_transport, obj_security) ret = get_wifi_config(obj_transport, obj_security)
if (ret == 1): if (ret == "connecting"):
continue continue
elif (ret == 0): elif (ret == "connected"):
print("==== Provisioning was successful ====") print("==== Provisioning was successful ====")
else: else:
print("---- Provisioning failed ----") print("---- Provisioning failed ----")

View File

@ -45,19 +45,25 @@ def config_get_status_response(security_ctx, response_data):
cmd_resp1.ParseFromString(decrypted_message) cmd_resp1.ParseFromString(decrypted_message)
print_verbose(security_ctx, "Response type " + str(cmd_resp1.msg)) print_verbose(security_ctx, "Response type " + str(cmd_resp1.msg))
print_verbose(security_ctx, "Response status " + str(cmd_resp1.resp_get_status.status)) print_verbose(security_ctx, "Response status " + str(cmd_resp1.resp_get_status.status))
if cmd_resp1.resp_get_status.sta_state == 0: if cmd_resp1.resp_get_status.sta_state == 0:
print("++++ WiFi state: " + "connected ++++") print("++++ WiFi state: " + "connected ++++")
return "connected"
elif cmd_resp1.resp_get_status.sta_state == 1: elif cmd_resp1.resp_get_status.sta_state == 1:
print("++++ WiFi state: " + "connecting... ++++") print("++++ WiFi state: " + "connecting... ++++")
return "connecting"
elif cmd_resp1.resp_get_status.sta_state == 2: elif cmd_resp1.resp_get_status.sta_state == 2:
print("++++ WiFi state: " + "disconnected ++++") print("++++ WiFi state: " + "disconnected ++++")
return "disconnected"
elif cmd_resp1.resp_get_status.sta_state == 3: elif cmd_resp1.resp_get_status.sta_state == 3:
print("++++ WiFi state: " + "connection failed ++++") print("++++ WiFi state: " + "connection failed ++++")
if cmd_resp1.resp_get_status.fail_reason == 0: if cmd_resp1.resp_get_status.fail_reason == 0:
print("++++ Failure reason: " + "Incorrect Password ++++") print("++++ Failure reason: " + "Incorrect Password ++++")
elif cmd_resp1.resp_get_status.fail_reason == 1: elif cmd_resp1.resp_get_status.fail_reason == 1:
print("++++ Failure reason: " + "Incorrect SSID ++++") 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): def config_set_config_request(security_ctx, ssid, passphrase):