Astwifid

Astwifid is responsible for:

  • Hosting a WiFi Access Point (AP) while the kit is running in development mode.

  • Configuring the WiFi network based on code bundle information.

  • Caching of WiFi configuration to allow the network to come up after a restart without the presence of a Usercode USB.

It is not responsible for handling any networking components such as DHCP. These are to be handled by the operating system.

Hostapd is used to create the WiFi hotspot and uses a configuration that is dynamically generated and stored in /tmp. Hostapd is then launched as a child process of the astwifid process. This is managed via the asyncio.subprocess module.

  • Metadata is received from ref:astmetad

  • If wifi_enabled is True and other data is provided (ssid, psk, region), then the hotspot is started.

  • If the metadata changes, the hotspot will automatically restarted with updated credentials if required.

  • If wifi_enabled changes to False, then the hotspot will be killed.

Astwifid Data Structures and Classes

class astoria.common.config.system.WiFiInfo(**data)[source]

System settings for WiFi.

class Config[source]

Pydantic config.

extra = 'forbid'
bridge: str
enable_wpa3: bool
interface: str
class astoria.common.ipc.WiFiManagerMessage(**data)[source]

Status message for WiFi Manager.

Published to /astoria/astwifid

hotspot_running: bool
class astoria.astwifid.lifecycle.AccessPointInfo(ssid: str, psk: str, region: str)[source]

The information required for an Access Point.

psk: str

Alias for field number 1

region: str

Alias for field number 2

ssid: str

Alias for field number 0

class astoria.astwifid.lifecycle.WiFiLifecycle(access_point_info, wifi_info)[source]

A lifecycle that can be executed by astwifid.

__init__(access_point_info, wifi_info)[source]
property access_point_info: AccessPointInfo

The access point info for the lifecycle.

property interface: str

The physical interface for the WiFi radio.

abstract property name: str

The name of the lifecycle.

abstract async run()[source]

Run the lifecycle.

This coroutine will exist for the lifetime of the lifecycle.

Return type:

None

property ssid: str

The SSID of the network.

abstract async stop()[source]

Stop the lifecycle.

Return type:

None

property wifi_info: WiFiInfo

The WiFi hardware info for the lifecycle.

class astoria.astwifid.hotspot_lifecycle.WiFiHotspotLifeCycle(access_point_info, wifi_info)[source]

Manages the lifecycle of the hostapd process.

HOSTAPD_BINARY: str = 'hostapd'
__init__(access_point_info, wifi_info)[source]
name = 'WiFi Hotspot'
async run()[source]

Starts the hostapd process.

Return type:

None

async stop()[source]

Stops the hostapd process.

Return type:

None