|
| 1 | +.. _ug_wifi_direct: |
| 2 | + |
| 3 | +Wi-Fi Direct (P2P mode) |
| 4 | +####################### |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +Wi-Fi Direct® (also known as Wi-Fi P2P or peer-to-peer mode) enables direct device-to-device connections without requiring a traditional access point. |
| 11 | +The nRF70 Series devices support Wi-Fi Direct, allowing you to establish peer-to-peer connections with other Wi-Fi Direct-capable devices. |
| 12 | + |
| 13 | +Building with Wi-Fi Direct support |
| 14 | +********************************** |
| 15 | + |
| 16 | +To build an application with Wi-Fi Direct support, use the :ref:`wifi_shell_sample` sample with the ``wifi-p2p`` snippet and external flash for firmware patches. |
| 17 | + |
| 18 | +Build command |
| 19 | +============= |
| 20 | + |
| 21 | +To build the Wi-Fi shell sample with Wi-Fi Direct (P2P) support, run the following command: |
| 22 | + |
| 23 | +.. code-block:: console |
| 24 | +
|
| 25 | + west build --pristine --board nrf7002dk/nrf5340/cpuapp -S wifi-p2p -S nrf70-fw-patch-ext-flash |
| 26 | + west flash |
| 27 | +
|
| 28 | +Wi-Fi Direct commands |
| 29 | +********************* |
| 30 | + |
| 31 | +The following commands are available for Wi-Fi Direct operations. |
| 32 | +Both Wi-Fi shell commands and ``wpa_cli`` commands are provided for each operation. |
| 33 | + |
| 34 | +Finding peers |
| 35 | +============= |
| 36 | + |
| 37 | +To start discovering Wi-Fi Direct peers, use the following commands: |
| 38 | + |
| 39 | +.. tabs:: |
| 40 | + |
| 41 | + .. group-tab:: Wi-Fi shell command |
| 42 | + |
| 43 | + .. code-block:: console |
| 44 | +
|
| 45 | + wifi p2p find |
| 46 | +
|
| 47 | + .. group-tab:: wpa_cli command |
| 48 | + |
| 49 | + .. code-block:: console |
| 50 | +
|
| 51 | + wpa_cli p2p_find |
| 52 | +
|
| 53 | +This command initiates the P2P discovery process. |
| 54 | +The device scans for other Wi-Fi Direct-capable devices in range. |
| 55 | + |
| 56 | +Listing discovered peers |
| 57 | +======================== |
| 58 | + |
| 59 | +To view the list of discovered peers, use the following commands: |
| 60 | + |
| 61 | +.. tabs:: |
| 62 | + |
| 63 | + .. group-tab:: Wi-Fi shell command |
| 64 | + |
| 65 | + .. code-block:: console |
| 66 | +
|
| 67 | + wifi p2p peers |
| 68 | +
|
| 69 | + .. group-tab:: wpa_cli command |
| 70 | + |
| 71 | + .. code-block:: console |
| 72 | +
|
| 73 | + wpa_cli p2p_peers |
| 74 | +
|
| 75 | +This command displays a table of discovered peers with the following information: |
| 76 | + |
| 77 | +.. code-block:: console |
| 78 | +
|
| 79 | + Num | Device Name | MAC Address | RSSI | Device Type | Config Methods |
| 80 | + 1 | Galaxy S22 | D2:39:FA:43:23:C1 | -58 | 10-0050F204-5 | 0x188 |
| 81 | +
|
| 82 | +The columns in the table represent the following attributes: |
| 83 | + |
| 84 | +* ``Num`` - Sequential number of the peer in the list |
| 85 | +* ``Device Name`` - Friendly name of the peer device |
| 86 | +* ``MAC Address`` - MAC address of the peer device |
| 87 | +* ``RSSI`` - Signal strength in dBm |
| 88 | +* ``Device Type`` - WPS device type identifier |
| 89 | +* ``Config Methods`` - Supported WPS configuration methods |
| 90 | + |
| 91 | +Getting peer details |
| 92 | +==================== |
| 93 | + |
| 94 | +To get detailed information about a specific peer, use the following commands: |
| 95 | + |
| 96 | +.. tabs:: |
| 97 | + |
| 98 | + .. group-tab:: Wi-Fi shell command |
| 99 | + |
| 100 | + .. code-block:: console |
| 101 | +
|
| 102 | + wifi p2p peer <mac_address> |
| 103 | +
|
| 104 | + .. group-tab:: wpa_cli command |
| 105 | + |
| 106 | + .. code-block:: console |
| 107 | +
|
| 108 | + wpa_cli p2p_peer <mac_address> |
| 109 | +
|
| 110 | +For example: |
| 111 | + |
| 112 | +.. code-block:: console |
| 113 | +
|
| 114 | + wpa_cli p2p_peer D2:39:FA:43:23:C1 |
| 115 | +
|
| 116 | +This command displays detailed information about the specified peer device. |
| 117 | + |
| 118 | +Connecting to a peer |
| 119 | +==================== |
| 120 | + |
| 121 | +To establish a Wi-Fi Direct connection with a discovered peer: |
| 122 | + |
| 123 | +.. tabs:: |
| 124 | + |
| 125 | + .. group-tab:: Wi-Fi shell command |
| 126 | + |
| 127 | + .. code-block:: console |
| 128 | +
|
| 129 | + wifi p2p connect <mac_address> <pin|pbc> -g <go_intent> |
| 130 | +
|
| 131 | + .. group-tab:: wpa_cli command |
| 132 | + |
| 133 | + .. code-block:: console |
| 134 | +
|
| 135 | + wpa_cli p2p_connect <mac_address> <pin|pbc> go_intent=<go_intent> |
| 136 | +
|
| 137 | +Parameters: |
| 138 | + |
| 139 | +* `<mac_address>` - MAC address of the peer device to connect to |
| 140 | +* ``<pbc|pin>`` - WPS provisioning method: |
| 141 | + |
| 142 | + * ``pin`` - Use PIN-based WPS authentication. |
| 143 | + The command will return a PIN (for example, ``88282282``) that must be entered on the peer device. |
| 144 | + * ``pbc`` - Use Push Button Configuration (PBC) for WPS authentication. |
| 145 | + |
| 146 | +* ``go_intent`` - Group Owner (GO) intent value ``0-15``: |
| 147 | + |
| 148 | + * Higher values indicate a stronger desire to become the Group Owner. |
| 149 | + * Value of ``15`` forces the device to become the GO. |
| 150 | + * Value of ``0`` indicates the device prefers to be a client. |
| 151 | + |
| 152 | +Example connection with PIN method: |
| 153 | + |
| 154 | +**Wi-Fi shell command:** |
| 155 | + |
| 156 | +.. code-block:: console |
| 157 | +
|
| 158 | + wifi p2p connect D2:39:FA:43:23:C1 pin -g 0 |
| 159 | +
|
| 160 | +**wpa_cli command:** |
| 161 | + |
| 162 | +.. code-block:: console |
| 163 | +
|
| 164 | + wpa_cli p2p_connect D2:39:FA:43:23:C1 pin go_intent=0 |
| 165 | +
|
| 166 | +The command will output a PIN (for example, ``88282282``) that should be entered on the peer device to complete the connection. |
| 167 | + |
| 168 | +To disconnect from a Wi-Fi Direct connection: |
| 169 | + |
| 170 | +.. tabs:: |
| 171 | + |
| 172 | + .. group-tab:: Wi-Fi shell command |
| 173 | + |
| 174 | + .. code-block:: console |
| 175 | +
|
| 176 | + wifi disconnect |
| 177 | +
|
| 178 | + .. group-tab:: wpa_cli command |
| 179 | + |
| 180 | + .. code-block:: console |
| 181 | +
|
| 182 | + wpa_cli disconnect |
0 commit comments