.. _nRF70_soft_ap_mode:

SoftAP mode
###########

.. contents::
   :local:
   :depth: 2

The nRF70 Series device supports :term:`Software-enabled Access Point (SoftAP or SAP)` mode.
This mode allows a device to operate as a virtual router or temporary access point (AP) and accept connections from other Wi-Fi® station devices.
SoftAP mode is typically used in scenarios where a Wi-Fi device wishes to share its internet connection with nearby station devices.
For instance, smartphone Wi-Fi hotspots utilize SoftAP mode.
The smartphone acts as a virtual router, allowing other station devices to connect to the internet through it.
Alternatively, SoftAP mode can be used to securely provision Wi-Fi devices into an access point network.

nRF70 Series devices support Wi-Fi provisioning using the SoftAP mode as one of the provisioning methods.

Supported functionality and limitations
***************************************

The SAP mode in the nRF70 Series devices provides SoftAP support with the following limitations:

  * A network interface can operate in either SAP mode or Station mode, but not in both modes simultaneously.
  * SAP mode only supports the Wi-Fi 4 (IEEE 802.11n) mode of operation.
  * The SAP mode currently supports a single station device connection.
    However, the implementation provides an :ref:`experimental <software_maturity>` support for up to eight station connections.
  * Only Wi-Fi personal security (WPA2-PSK) is supported.

Enabling the SAP mode
*********************

You can enable the SAP mode by setting the :kconfig:option:`CONFIG_NRF700X_AP_MODE` and :kconfig:option:`CONFIG_WPA_SUPP_AP` Kconfig options in the application project configuration file.


SAP mode configuration
**********************

The SAP mode is configured using the standard Wi-Fi configuration APIs in the Zephyr networking stack.
See `Zephyr Wi-Fi management API`_ for more information.

Shell commands
--------------

The SAP mode can be configured using the following shell commands:

.. list-table::
     :header-rows: 1

     * - Command
       - Description
     * - ``wifi ap enable``
       - Starts the SAP mode.
     * - ``wifi ap disable``
       - Stops the SAP mode.
     * - ``wifi status``
       - Displays the status of the SAP mode interface.
     * - ``wifi ap stations``
       - Displays the list of stations connected to the SAP mode interface.
     * - ``net dhcpv4 server start``
       - Starts the DHCPv4 server.

Wi-Fi configuration APIs
------------------------

The SAP mode can be configured using the following Wi-Fi configuration APIs:

.. list-table::
     :header-rows: 1

     * - API
       - Description
       - Parameters
     * - ``NET_REQUEST_WIFI_AP_ENABLE``
       - Starts the SAP mode.
       - | Interface
         | SSID
         | Channel
         | Security information
     * - ``NET_REQUEST_WIFI_AP_DISABLE``
       - Stops the SAP mode.
       - Interface
     * - ``NET_REQUEST_WIFI_STATUS``
       - Displays the status of the SAP mode interface.
       - Interface

The SAP mode generates the following events:

.. list-table::
     :header-rows: 1

     * - Event
       - Description
     * - ``NET_EVENT_WIFI_AP_ENABLE_RESULT``
       - Generated when the SAP mode is enabled.
     * - ``NET_EVENT_WIFI_AP_DISABLE_RESULT``
       - Generated when the SAP mode is disabled.
     * - ``NET_EVENT_WIFI_AP_STA_CONNECTED``
       - Generated when a station connects to the SAP mode interface.
     * - ``NET_EVENT_WIFI_AP_STA_DISCONNECTED``
       - Generated when a station disconnects from the SAP mode interface.

.. note::
   There is no API to display the list of stations connected to the SAP mode interface.
   However, using the events generated by Zephyr Wi-Fi stack, you can get the list of stations connected to the SAP mode interface.

.. note::
    The SAP mode operation is dictated by regulatory requirements.
    For more information on regulatory support, see :ref:`ug_nrf70_developing_regulatory_support`.

Stations handling
*****************

For a typical SAP mode operation, the nRF70 Series device acts as a virtual router, allowing other station devices to connect to it.
The SAP interface needs to be configured with a valid IP address and a subnet mask.
Without this configuration, the Wi-Fi station device might disconnect from the SAP interface.
But the station devices use :abbr:`DHCP (Dynamic Host Configuration Protocol)` to get an IP address from the virtual router.
See `Zephyr net DHCPv4 server`_ for more information.
