API Reference¶
chumicro_wifi¶
chumicro_wifi
¶
Unified wifi supervisor across CircuitPython, MicroPython, and CPython.
Exports :class:WifiService, :class:WifiConfig, and :class:WifiState.
WifiConfig
¶
Connection configuration for WifiService.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ssid
|
str
|
AP SSID to associate with. |
required |
password
|
str
|
WPA passphrase. |
required |
hostname
|
str | None
|
Hostname advertised on the AP, or |
None
|
connect_timeout_ms
|
int
|
Max wait for a single connect attempt, in ms (default 15 s). |
15000
|
first_connect_timeout_ms
|
int | None
|
Longer allowance for the first connect attempt
after construction, in ms, or |
None
|
reconnect_backoff_start_ms
|
int
|
Initial delay between reconnect attempts (default 1 s). |
1000
|
reconnect_backoff_max_ms
|
int
|
Cap on the exponential reconnect backoff (default 60 s). |
60000
|
reconnect_max
|
int | None
|
Failed attempts before terminal |
None
|
power_save
|
bool
|
Whether to leave the radio's power-save mode enabled (default |
False
|
tx_power_dbm
|
int | None
|
Radio transmit power in dBm, or |
None
|
from_config(config)
classmethod
¶
Build a WifiConfig from the flat runtime config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object
|
A :class: |
required |
Raises:
| Type | Description |
|---|---|
MissingConfigKey
|
|
InvalidConfigType
|
config is |
try_from_config(config)
classmethod
¶
Soft-load a WifiConfig, returning None when not configured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object
|
A :class: |
required |
Returns:
| Type | Description |
|---|---|
WifiConfig | None
|
A |
WifiService
¶
Drives a wifi adapter through connect, monitor, and reconnect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
WifiConfig
|
A :class: |
required |
adapter
|
object | None
|
Optional :class: |
None
|
ticks
|
object | None
|
Optional |
None
|
connected
property
¶
True when the substrate is currently linked.
ip
property
¶
Assigned IPv4 string, or None when not connected.
from_config(config, *, radio=None, ticks=None, **constructor_kwargs)
classmethod
¶
Build a :class:WifiService from runtime config.
The wifi.* config keys carry the deployment-varying values
(credentials, timeouts, backoff, power tuning) and load through
:meth:WifiConfig.from_config; any other constructor knob
passes through verbatim as a keyword, and an explicit keyword
wins over its config-derived value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
object
|
A :class: |
required |
radio
|
object | None
|
CircuitPython radio handle for the runtime adapter;
ignored on MicroPython and CPython, and unused when an
explicit |
None
|
ticks
|
object | None
|
Optional tick source, forwarded to the constructor. |
None
|
**constructor_kwargs
|
object
|
Any other constructor knob (e.g.
|
{}
|
Raises:
| Type | Description |
|---|---|
MissingConfigKey
|
|
InvalidConfigType
|
config is |
on_state_change(callback)
¶
Register a callback invoked on every state transition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
object
|
Called as |
required |
check(now_ms)
¶
Return True when the service has work to do this tick.
handle(now_ms)
¶
Drive the state machine forward.
WifiState
¶
State-name constants for :class:WifiService.