Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to the same WiFi access point with an incorrect password succeeds, after successfully connecting and disconnecting with a valid password. #971

Open
adrianblakey opened this issue Feb 7, 2025 · 0 comments

Comments

@adrianblakey
Copy link

adrianblakey commented Feb 7, 2025

Pi Pico W 2 running: 1.25.0-preview

Do something like this:

class WC():

    def __init__(self):
        self._wlan: network.WLAN = network.WLAN(network.STA_IF) # WiFi client

   def connect(self, ssid: str, pwd: str) -> bool:
        i: int = 10
        self._wlan.connect(ssid, pwd)
        while i > 0 and self._wlan.status() == network.STAT_CONNECTING:
            i -= 1
            time.sleep(1)
        if self._wlan.status() == network.STAT_GOT_IP or self._wlan.status() == 2:
            self._ssid = ssid
            self._pwd = pwd
            return True
        elif self._wlan.status() == network.STAT_CONNECTING:
            log.info('Still connecting, try later’)
        elif self._wlan.status() == network.STAT_IDLE:
            log.info('Network idle’)
        elif self._wlan.status() == network.STAT_WRONG_PASSWORD:
            log.info('Connection failed. Check password’)
        elif self._wlan.status() == network.STAT_NO_AP_FOUND:  
            log.info('Connection failed. Check ssid’)
        elif self._wlan.status() == network.STAT_CONNECT_FAIL:
            log.info('Connection failed %s.', self._wlan.status())
        else:
            log.info('Unknown Status: %s', self._wlan.status())
        return False    

  def disconnect(self) -> boot:
        self._wlan.disconnect()
        time.sleep(2)


wc = WC()
wc.connect(‘ssid’, ‘goodpwd’) # Succeeds
wc.disconnect()
wc.connect(‘ssid’, ‘badpwd’) # Succeeds - NO!

Do I need to reinitialize the WLAN in the disconnect and drop the ip address - somehow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant