NetworkModule
Source:
NetworkModule.h
NetworkModule¶
src/core/system/NetworkModule.h:50Inherits:
MoonModule
All device connectivity, cascading from Ethernet through WiFi to an access point.
One module and one card: the user sees a network, not three technologies. A desktop uses the operating system's own networking and loads none of this.

Public Methods¶
inline void setScheduler(Scheduler * s)
: Adopt the scheduler, which the tree rebuild after a mode change goes through.
inline void setSystemModule(SystemModule * s)
: Adopt the system module, which owns the device name this one reads.
inline void setTxPowerSetting(uint8_t dBm)
: Persist and apply the power cap, before credentials arriving with it are used.
inline void setWifiCredentials(const char * ssid, const char * password)
: Set the credentials and drive a clean transition into connecting.
virtual inline bool respectsEnabled() const override
: Keep the cascade ticking whatever the toggle says, or the device drops off the network.
virtual inline bool appliesConfigLive() const override
: Bring-up runs once and is not re-entrant, so a restored config applies at the next boot.
virtual inline void setup() override
: Set the hostname, push the interface config, then start the cascade.
virtual inline uint8_t fixedPins(FixedPin * out, uint8_t max) const override
: The controller's data pads while Ethernet runs, which the chip fixed and nobody sets.
virtual inline void defineControls() override
: Declare the mode, the credentials, the addressing and the interface pins.
virtual inline void tick1s() override
: Advance the cascade, then apply anything a control changed live.
virtual inline void release() override
: Release the children first, then shut down whichever interface is up.
inline void currentIp(uint8_t out) const
: The current address as octets, all zero meaning not connected.
More info¶
The cascade¶
Ethernet is preferred, then WiFi, then our own access point as a last resort. A higher-priority link tears the lower ones down to reclaim memory. Each is tried unconditionally, the platform failing fast where hardware is absent. A state machine drives this from the slow tick, and a late interface is promoted live.
Why one preset defaults to itself¶
The preset list is filtered per chip, and the default is Custom rather than row 0. A real preset writes a pin map, which on the wrong board overwrites the chip's own defaults. Where the filter leaves exactly ONE real preset that reasoning inverts, because the single survivor IS this chip's board. A P4 offers P4-NANO and an S31 offers S31 CoreBoard, so Custom there ships an unconfigured interface on a board whose wiring is known. A classic keeps Custom, where several survive and only the catalog knows the board: an Olimex takes Classic RMII, a QuinLED Dig-Octa the no-reset variant.
The applied-tracker starts on a sentinel rather than row 0 for the same reason. Zero would claim row 0 is already applied, and on a single-preset chip that row is now the board's own preset. Its map then never reached the pin fields, so a virgin P4 selected P4-NANO and still booted with the interface at ethNone.
Configuration¶
Which driver is compiled in is per chip; which interface a board uses is runtime config. An SPI change applies live, while the built-in controller applies at the next boot. The addressing selector pins a static address or runs the client, live either way.
The device name belongs to the system module, and is the one identity behind every name. It registers before the light pipeline, which then sees the real remaining heap.