jacdac.wifi

Submodules

Package Contents

Classes

WifiClient

Discovery and connection to WiFi networks. Separate TCP service can be used for data transfer.

class jacdac.wifi.WifiClient(bus: jacdac.bus.Bus, role: str, *, missing_rssi_value: int | None = None)

Bases: jacdac.bus.SensorClient

Discovery and connection to WiFi networks. Separate TCP service can be used for data transfer. Implements a client for the WIFI service.

property rssi: int | None

Current signal strength. Returns -128 when not connected., _: dB

property enabled: bool | None

Determines whether the WiFi radio is enabled. It starts enabled upon reset.,

property ip_address: bytes | None

0, 4 or 16 byte buffer with the IPv4 or IPv6 address assigned to device if any.,

property eui_48: bytes | None

The 6-byte MAC address of the device. If a device does MAC address randomization it will have to “restart”.,

property ssid: str | None

SSID of the access-point to which device is currently connected. Empty string if not connected.,

on_got_ip(handler: jacdac.bus.EventHandlerFn) jacdac.bus.UnsubscribeFn

Emitted upon successful join and IP address assignment.

on_lost_ip(handler: jacdac.bus.EventHandlerFn) jacdac.bus.UnsubscribeFn

Emitted when disconnected from network.

on_scan_complete(handler: jacdac.bus.EventHandlerFn) jacdac.bus.UnsubscribeFn

A WiFi network scan has completed. Results can be read with the last_scan_results command. The event indicates how many networks where found, and how many are considered as candidates for connection.

on_networks_changed(handler: jacdac.bus.EventHandlerFn) jacdac.bus.UnsubscribeFn

Emitted whenever the list of known networks is updated.

on_connection_failed(handler: jacdac.bus.EventHandlerFn) jacdac.bus.UnsubscribeFn

Emitted when when a network was detected in scan, the device tried to connect to it and failed. This may be because of wrong password or other random failure.

add_network(ssid: str, password: str) None

Automatically connect to named network if available. Also set password if network is not open.

reconnect() None

Enable the WiFi (if disabled), initiate a scan, wait for results, disconnect from current WiFi network if any, and then reconnect (using regular algorithm, see set_network_priority).

forget_network(ssid: str) None

Prevent from automatically connecting to named network in future. Forgetting a network resets its priority to 0.

forget_all_networks() None

Clear the list of known networks.

set_network_priority(priority: int, ssid: str) None

Set connection priority for a network. By default, all known networks have priority of 0.

scan() None

Initiate search for WiFi networks. Generates scan_complete event.