Skip to content

NetworkModule

Top-level network identity module. Holds the device name and MAC address, and puts the ESP32 radio into simultaneous AP+STA mode. Introduced in Sprint 8.


What it does

NetworkModule is the parent of all network child modules (WifiStaModule, WifiApModule). On setup() it:

  • Reads the hardware MAC address and derives a default device name MM-XXXX (last 4 hex digits).
  • Calls WiFi.mode(WIFI_AP_STA) so AP and STA can run simultaneously.
  • Exposes device_name as an editable text control and mac_address as a read-only display.

Child modules call deviceName() to inherit the device name as their AP SSID, so changing device_name once propagates to all children.

On PC, the MAC address is 00:00:00:00:00:00 and device_name defaults to MM-0000.


Controls

Key Type Default Description
device_name text MM-XXXX (auto from MAC) Human-readable device name; editable, persisted
mac_address display hardware MAC Read-only; set once in setup()

Parent-child lifecycle

NetworkModule is a parent module. Its children (WifiStaModule, WifiApModule) are added under it in state/modulemanager.json via "parent_id". The ModuleManager sets up children after the parent, ensuring WiFi.mode(WIFI_AP_STA) runs first.

WifiApModule reads deviceName() via setInput("network", networkModule).


Platform notes

ESP32: reads the eFuse MAC via esp_efuse_mac_get_default(). WiFi mode is set via WiFi.mode(WIFI_AP_STA).

PC: no-op; MAC is zeroed and device name defaults to MM-0000.


Test coverage

Network and WiFi — default device_name format, setProps override, loadState/saveState round-trip, schema includes both controls, category is "network", healthReport contains device= and mac=.


Source