Test three; memory usage. After each successful connection it appears that memory use is reduced -Though this will eventually be recovered by internal garbage collection it makes sense to call 'gc.collect()' after a 'connect'.
Code:
145152 ('192.168.0.205', '255.255.255.0', '192.168.0.1', '192.168.0.1')144992 ('192.168.0.205', '255.255.255.0', '192.168.0.1', '192.168.0.1')144832 ('192.168.0.205', '255.255.255.0', '192.168.0.1', '192.168.0.1')144672 ('192.168.0.205', '255.255.255.0', '192.168.0.1', '192.168.0.1')etc
Code:
import gcimport networkimport secretsimport timewhile True: wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.disconnect() while wlan.status() > 0: time.sleep(1) wlan.connect(secrets.SSID, secrets.PASSWORD) while wlan.status() != 3: time.sleep(1) gc.collect() print(gc.mem_free(), wlan.ifconfig())
Code:
147024 ('192.168.0.209', '255.255.255.0', '192.168.0.1', '192.168.0.1')147024 ('192.168.0.209', '255.255.255.0', '192.168.0.1', '192.168.0.1')147024 ('192.168.0.209', '255.255.255.0', '192.168.0.1', '192.168.0.1')147024 ('192.168.0.209', '255.255.255.0', '192.168.0.1', '192.168.0.1')
Statistics: Posted by hippy — Sat Jan 27, 2024 3:28 pm