Skip to content

Commit 002a13a

Browse files
projectgusespressif-bot
authored andcommitted
ci provisioning: Add some experiments to check the runner's STA state
Not clear why sometimes it associates without negotiating a new DHCP lease.
1 parent ab55bea commit 002a13a

File tree

2 files changed

+54
-48
lines changed

2 files changed

+54
-48
lines changed

examples/provisioning/legacy/softap_prov/softap_prov_test.py

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -51,52 +51,55 @@ def test_examples_provisioning_softap(env, extra_data):
5151
print("SoftAP SSID : " + ssid)
5252
print("SoftAP Password : " + password)
5353

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()
100103

101104

102105
if __name__ == '__main__':

tools/ci/python_packages/wifi_tools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ def __init__(self, iface, reset_on_exit=False):
5555
if self.iface_ifc is None:
5656
raise RuntimeError('supplicant : Failed to fetch interface')
5757

58-
self.old_network = self.iface_obj.Get("fi.w1.wpa_supplicant1.Interface", "CurrentNetwork",
59-
dbus_interface='org.freedesktop.DBus.Properties')
58+
self.old_network = self._get_iface_property("CurrentNetwork")
59+
print("Old network is %s" % self.old_network)
60+
6061
if self.old_network == '/':
6162
self.old_network = None
6263
else:
@@ -78,6 +79,8 @@ def connect(self, ssid, password):
7879
if self.new_network is not None:
7980
self.iface_ifc.RemoveNetwork(self.new_network)
8081

82+
print("Pre-connect state is %s, IP is %s" % (self._get_iface_property("State"), get_wiface_IPv4(self.iface_name)))
83+
8184
self.new_network = self.iface_ifc.AddNetwork({"ssid": ssid, "psk": password})
8285
self.iface_ifc.SelectNetwork(self.new_network)
8386
time.sleep(10)

0 commit comments

Comments
 (0)