Quantcast
Viewing all articles
Browse latest Browse all 5359

MicroPython • Re: Security Concern with Raspberry Pi Pico W: Reconnecting to WiFi with Incorrect Password

Test three; memory usage. After each successful connection it appears that memory use is reduced -

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
Though this will eventually be recovered by internal garbage collection it makes sense to call 'gc.collect()' after a 'connect'.

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



Viewing all articles
Browse latest Browse all 5359

Trending Articles