micropython / micropython/micropython-lib

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

Open
#971 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
1.1k
Avg merge
7d 6h
Merged PRs (30d)
3

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided network.WLAN reproduction on a Pi Pico W 2 running MicroPython 1.25.0-preview, focusing on the connect/disconnect sequence and status values. Confirm that a valid connection followed by disconnecting allows an incorrect password to report success, then identify the WLAN state that must be reset so the bad-password attempt fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.