wifi

The wifi module provides necessary low-level functionality for managing wifi wifi connections. Use socketpool for communicating over the network.

wifi.radio :Radio

Wifi radio used to manage both station and AP modes. This object is the sole instance of wifi.Radio.

class wifi.Network

A wifi network provided by a nearby access point.

You cannot create an instance of wifi.Network. They are returned by wifi.Radio.start_scanning_networks.

ssid :str

String id of the network

rssi :int

Signal strength of the network

channel :int

Channel number the network is operating on

class wifi.Radio

Native wifi radio.

This class manages the station and access point functionality of the native Wifi radio.

You cannot create an instance of wifi.Radio. Use wifi.radio to access the sole instance available.

enabled :bool

True when the wifi radio is enabled.

mac_address :bytes

MAC address of the wifi radio. (read-only)

ipv4_address :Optional[ipaddress.IPv4Address]

IP v4 Address of the radio when connected to an access point. None otherwise.

start_scanning_networks(self, *, start_channel=1, stop_channel=11)

Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country.

stop_scanning_networks(self)

Stop scanning for Wifi networks and free any resources used to do it.

connect(self, ssid: ReadableBuffer, password: ReadableBuffer = b'', *, channel: Optional[int] = 0, timeout: Optional[float] = None)

Connects to the given ssid and waits for an ip address. Reconnections are handled automatically once one connection succeeds.

ping(self, ip, *, timeout: float = 0.5)

Ping an IP to test connectivity. Returns echo time in seconds. Returns None when it times out.

class wifi.ScannedNetworks

Iterates over all wifi.Network objects found while scanning. This object is always created by a wifi.Radio: it has no user-visible constructor.

Cannot be instantiated directly. Use wifi.Radio.start_scanning_networks.

__iter__(self)

Returns itself since it is the iterator.

__next__(self)

Returns the next wifi.Network. Raises StopIteration if scanning is finished and no other results are available.