ci provisioning: Use strings instead of "magic numbers" for connection state
This commit is contained in:
parent
faaf08c441
commit
9d38b0ab9b
5 changed files with 16 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ----")
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue