@@ -51,52 +51,55 @@ def test_examples_provisioning_softap(env, extra_data):
51
51
print ("SoftAP SSID : " + ssid )
52
52
print ("SoftAP Password : " + password )
53
53
54
- ctrl = wifi_tools .wpa_cli (iface , reset_on_exit = True )
55
- print ("Connecting to DUT SoftAP..." )
56
- ip = ctrl .connect (ssid , password )
57
- got_ip = dut1 .expect (re .compile (r"DHCP server assigned IP to a station, IP is: (\d+.\d+.\d+.\d+)" ), timeout = 60 )[0 ]
58
- if ip != got_ip :
59
- raise RuntimeError ("SoftAP connected to another host! " + ip + "!=" + got_ip )
60
- print ("Connected to DUT SoftAP" )
61
-
62
- print ("Starting Provisioning" )
63
- verbose = False
64
- protover = "V0.1"
65
- secver = 1
66
- pop = "abcd1234"
67
- provmode = "softap"
68
- ap_ssid = "myssid"
69
- ap_password = "mypassword"
70
- softap_endpoint = ip .split ('.' )[0 ] + "." + ip .split ('.' )[1 ] + "." + ip .split ('.' )[2 ] + ".1:80"
71
-
72
- print ("Getting security" )
73
- security = esp_prov .get_security (secver , pop , verbose )
74
- if security is None :
75
- raise RuntimeError ("Failed to get security" )
76
-
77
- print ("Getting transport" )
78
- transport = esp_prov .get_transport (provmode , softap_endpoint )
79
- if transport is None :
80
- raise RuntimeError ("Failed to get transport" )
81
-
82
- print ("Verifying protocol version" )
83
- if not esp_prov .version_match (transport , protover ):
84
- raise RuntimeError ("Mismatch in protocol version" )
85
-
86
- print ("Starting Session" )
87
- if not esp_prov .establish_session (transport , security ):
88
- raise RuntimeError ("Failed to start session" )
89
-
90
- print ("Sending Wifi credential to DUT" )
91
- if not esp_prov .send_wifi_config (transport , security , ap_ssid , ap_password ):
92
- raise RuntimeError ("Failed to send Wi-Fi config" )
93
-
94
- print ("Applying config" )
95
- if not esp_prov .apply_wifi_config (transport , security ):
96
- raise RuntimeError ("Failed to send apply config" )
97
-
98
- if not esp_prov .wait_wifi_connected (transport , security ):
99
- raise RuntimeError ("Provisioning failed" )
54
+ try :
55
+ ctrl = wifi_tools .wpa_cli (iface , reset_on_exit = True )
56
+ print ("Connecting to DUT SoftAP..." )
57
+ ip = ctrl .connect (ssid , password )
58
+ got_ip = dut1 .expect (re .compile (r"DHCP server assigned IP to a station, IP is: (\d+.\d+.\d+.\d+)" ), timeout = 60 )[0 ]
59
+ if ip != got_ip :
60
+ raise RuntimeError ("SoftAP connected to another host! " + ip + "!=" + got_ip )
61
+ print ("Connected to DUT SoftAP" )
62
+
63
+ print ("Starting Provisioning" )
64
+ verbose = False
65
+ protover = "V0.1"
66
+ secver = 1
67
+ pop = "abcd1234"
68
+ provmode = "softap"
69
+ ap_ssid = "myssid"
70
+ ap_password = "mypassword"
71
+ softap_endpoint = ip .split ('.' )[0 ] + "." + ip .split ('.' )[1 ] + "." + ip .split ('.' )[2 ] + ".1:80"
72
+
73
+ print ("Getting security" )
74
+ security = esp_prov .get_security (secver , pop , verbose )
75
+ if security is None :
76
+ raise RuntimeError ("Failed to get security" )
77
+
78
+ print ("Getting transport" )
79
+ transport = esp_prov .get_transport (provmode , softap_endpoint )
80
+ if transport is None :
81
+ raise RuntimeError ("Failed to get transport" )
82
+
83
+ print ("Verifying protocol version" )
84
+ if not esp_prov .version_match (transport , protover ):
85
+ raise RuntimeError ("Mismatch in protocol version" )
86
+
87
+ print ("Starting Session" )
88
+ if not esp_prov .establish_session (transport , security ):
89
+ raise RuntimeError ("Failed to start session" )
90
+
91
+ print ("Sending Wifi credential to DUT" )
92
+ if not esp_prov .send_wifi_config (transport , security , ap_ssid , ap_password ):
93
+ raise RuntimeError ("Failed to send Wi-Fi config" )
94
+
95
+ print ("Applying config" )
96
+ if not esp_prov .apply_wifi_config (transport , security ):
97
+ raise RuntimeError ("Failed to send apply config" )
98
+
99
+ if not esp_prov .wait_wifi_connected (transport , security ):
100
+ raise RuntimeError ("Provisioning failed" )
101
+ finally :
102
+ ctrl .reset ()
100
103
101
104
102
105
if __name__ == '__main__' :
0 commit comments