Wi-Fi & Cellular Modems
Relevant source files
The following files were used as context for generating this wiki page:
The Wi-Fi and Cellular Modem subsystem provides a standardized set of interfaces and drivers for wireless connectivity. This system integrates high-level networking protocols with low-level hardware drivers, ensuring modularity and support for various wireless technologies including IEEE 802.11 (Wi-Fi), IEEE 802.15.4, and cellular technologies.
The architecture focuses on abstraction via Layer 2 (L2) interfaces, allowing the IP stack to interact with diverse network technologies such as Bluetooth IPSP, Wi-Fi, and 802.15.4 simultaneously. This modularity is supported by specialized glue code and external libraries, such as the hostap module for Wi-Fi management.
Sources: doc/releases/release-notes-1.7.rst:54-63, modules/hostap/CMakeLists.txt:1-15
Architecture and Components
The modem and wireless architecture is structured to separate protocol management from physical hardware interaction. This is achieved through a layered model where hardware-specific drivers report to a generic L2 interface.
Wi-Fi Management (hostap)
Wi-Fi functionality is largely managed through the hostap module, which includes a WPA Supplicant and Hostapd implementation. This module handles complex tasks like scanning, authentication, and station management (SME).
The diagram shows the data flow from the application through the IP stack and L2 abstraction to specific wireless management modules and hardware drivers.
Sources: doc/releases/release-notes-1.7.rst:64-70, modules/hostap/CMakeLists.txt:104-125
Key Wi-Fi Features
The Wi-Fi implementation supports various advanced IEEE 802.11 features through the hostap port:
- WPA Supplicant & SME: Handles the State Machine for association and authentication.
- Security Protocols: Support for WPA3 (SAE), WEP, and Enterprise-grade security (EAP-TLS, EAP-PEAP).
- Advanced Standards: Support for 802.11ac (VHT), 802.11ax (HE), and 802.11r (Fast Transition).
- Background Scanning: Configurable bgscan simple and learn modules for roaming.
Sources: modules/hostap/CMakeLists.txt:50-90, modules/hostap/CMakeLists.txt:200-220
Configuration and API
Connectivity features are highly configurable through Kconfig options, allowing developers to include only necessary protocols to save memory—a critical requirement for resource-constrained devices.
Wi-Fi Configuration Table
| Option | Description | Source File |
|---|---|---|
CONFIG_WPA_SUPPLICANT | Enables the WPA Supplicant for Wi-Fi station mode. | modules/hostap/CMakeLists.txt:7 |
CONFIG_WIFI_NM_WPA_SUPPLICANT_WPA3 | Enables WPA3 SAE and Dragonfly handshake support. | modules/hostap/CMakeLists.txt:251 |
CONFIG_WIFI_NM_WPA_SUPPLICANT_P2P | Enables Wi-Fi Direct (Peer-to-Peer) functionality. | modules/hostap/CMakeLists.txt:265 |
CONFIG_WIFI_NM_WPA_SUPPLICANT_AP | Enables Access Point (AP) mode functionality. | modules/hostap/CMakeLists.txt:135 |
CONFIG_EAP_TLS | Enables Enterprise authentication via TLS. | modules/hostap/CMakeLists.txt:320 |
External Driver Integration
The project uses specific "glue" code to bridge external libraries like hostap with the internal RTOS kernel. Key files include:
src/supp_api.c: Porting layer for supplicant APIs.src/os_zephyr.c: OS abstraction layer for memory, threads, and synchronization.src/l2_packet_zephyr.c: Bridge between hostap and the L2 network stack.
Sources: modules/hostap/CMakeLists.txt:115-125
Modem Context and Data Flow
Modem communication typically involves serialized data streams (AT commands or PPP) handled via the Modem Context.
The sequence diagram illustrates a typical transmission flow where an application uses the Modem Pipe API to send data through the modem context to the underlying hardware driver.
Sources: doc/contribute/style/doxygen.rst:200-210
Modem API Example
The following snippet represents the documented interface for modem transmission:
/**
* @brief Transmit data through a pipe
*
* @param[in] pipe Pipe to transmit through
* @param buf Data to transmit
* @param size Number of bytes to transmit
*
* @return Number of bytes placed in @p pipe
* @retval -EPERM Pipe is closed
* @retval -errno Negative error code on error
*/
int modem_pipe_transmit(struct modem_pipe *pipe, const uint8_t *buf, size_t size);
Sources: doc/contribute/style/doxygen.rst:203-215
Security Implementation
Wireless security is integrated into the system using specialized cryptographic libraries. For Wi-Fi, the system leverages mbedTLS for underlying cryptographic operations.
- Crypto Abstraction: Wi-Fi modules use
crypto_mbedtls_alt.cto link hostap requirements to the internal security stack. - Execution Protection: Modems often handle external data; the system uses stack protection and thread separation to mitigate risks from malformed network packets.
- PSA Crypto: Applications leverage PSA Crypto APIs for standardized secure operations, including key storage.
Sources: modules/hostap/CMakeLists.txt:480-495, doc/security/security-overview.rst:65-75
Conclusion
The Wi-Fi and Cellular Modem subsystem provides a robust, modular framework for wireless communication. By utilizing L2 abstraction and porting established libraries like hostap, the system supports a wide array of standards from basic 802.15.4 to advanced 802.11ax. The extensive use of Kconfig allows for highly optimized builds that maintain security and functional requirements across diverse hardware architectures.