experimental.wifi
Enables managing the wireless connection on the Pico W and Pico 2 W
Wifi credentials are saved in config/ExperimentalConfig.json
See https://docs.micropython.org/en/latest/library/network.WLAN.html for details on wifi implementation
- class experimental.wifi.WifiConnection
Class to manage the wifi connection
This class is initalized automatically by the
europi
module, and should not be needed directly from any user code.To access/inspect the wireless connection, use the
europi.wireless_connection
instance:import europi if europi.wifi_connection is not None: print(europi.wifi_connection.ip_addr)
europi.wifi_connection
will beNone
if: * the Pico model doesn’t support WiFi * the WiFi configuration is invalid and/or raised aWifiError
The constructor will automatically do the following: #. Start the wireless hardware #. Create the access point or connect to the designated SSID (depending on mode) #. Configure WebREPL’s default configuration (if necessary) #. Start WebREPL (if necessary)
- Raises
WifiError – if the model doesn’t support wifi, if we fail to import the necessary libraries, or if the network fails to connect
- connect_ap(cfg)
Connect in access point mode
We can optionally set the IP address and netmask in this mode
- Parameters
cfg – The ExperimentalConfig object
- connect_station(cfg)
Connect to an external wireless router as a client
- Parameters
cfg – The ExperimentalConfig object
- property dns: str
Get our primary DNS
- property gateway: str
Get our current gateway
- property interface
Get the underlying network.WLAN interface
- property ip_addr: str
Get our current IP address
- property is_connected: bool
Is the Pico connected to anything?
In client mode this returns True if we’re connected to an access point
In AP mode this returns True if at least one client is connected to us
- property netmask: str
Get our current netmask
- setup_webrepl()
Create the additional configuration files needed for WebREPL.
Creates the following files (if they do not exist already): * /boot.py (empty) * /webrepl_cfg.py (contains default WebREPL password)
This is done automatically by the constructor; user code should not need to call this method
- property ssid: str
Get the SSID of our wireless network
- start_webrepl()
Start the WebREPL server
This is called automatically by the constructor; user code should not need to call this