Repository navigation
wifi: CircuitPython's wifi.radio API on network.WLAN - #127
Merged
Merged
Conversation
connect() raises ConnectionError with CircuitPython's reasons (Authentication failure, No network with that ssid, a timeout) and returns at once when already on that network; timeout=0 starts a join without waiting. Adds scanning, ap_info with live rssi, static addresses, power management, tx power, hostname and an access point. connect_from_secrets() keeps its contract and now falls back to the networks wifi_manager remembered when secrets.py is missing or its network isn't in range; it skips NTP when already connected. Tested on an ESP32-S3 (LCD-7) hopping between two P4 access points started with start_ap(): five hops, the wrong-password, missing-network and timeout=0 cases, and the wifi_manager fallback with and without secrets.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces
lib/wifi.pywith a version that gives MicroPython CircuitPython'swifi.radioAPI, so board code written for CircuitPython runs unchanged.What's new:
radio.connect()raisesConnectionError(anOSError) with CircuitPython's reasons, andtimeout=0joins without waiting.ap_infowith live RSSI, static addresses, power management, TX power, hostname, and an access point.connect_from_secrets()keeps its contract. Whensecrets.pyis missing or its network isn't in range, it now falls back to the networkswifi_managerremembered.Two behaviours change for existing callers:
radio.connect()used to returnNonequietly when it failed. It now raises. No caller in our repos relies on the old behaviour.connect_from_secrets()no longer re-syncs NTP when the board is already connected.tests/test_wifi.pynow asserts that, and its fake radio gains thedisconnect()andconfig()the new code calls.Tested on hardware. An ESP32-S3 (LCD-7) hopped between two ESP32-P4 access points started with the new
start_ap(), a→b→a→b→a, joining each in 1.1–1.4 s. Wrong password, missing network andtimeout=0behaved as documented. Thewifi_managerfallback worked both withoutsecrets.pyand with asecrets.pynetwork out of range.Boards that freeze PyDevices (
--modules pydevices) carry the old copy until their firmware is rebuilt, because frozen modules come before/lib.