P2P AT Commands

Note

  • P2P AT commands are disabled by default.

  • Refer to Configuring Project (menuconfig) to enter CONFIG SHELL configuration, and check Enable P2P to enable the P2P AT commands.

AT+WLP2PSTART

Function Description

Initialize and start the P2P device

Command Format

AT+WLP2PSTART=[<type>,<value>,<type>,<value>……]

Response Format

Success Response:

OK

Error Response: definitions of error_no are in Wi-Fi AT Error Codes.

ERROR: <error_no>

Parameters

<type>:

Parameter type, followed by corresponding <value>

  • listen_ch:followed by Listen Channel

  • op_ch:followed by Operating Channel

<value>:

Specific parameter corresponding to <type>

<listen_ch>:

Listen Channel

  • It can be channel 1,6,11 in the 2.4GHz band.

<op_ch>:

Operating Channel

  • It can be channel 1,6,11 in the 2.4GHz band.

Note

You can omit the parameters. In this case, the Listen Channel and Operating Channel will be randomly selected from ch 1, 6, and 11.

AT+WLP2PSTOP

Function Description

Stop P2P mode.

Command Format

AT+WLP2PSTOP

Response Format

Success Response:

OK

Error Response: definitions of error_no are in Wi-Fi AT Error Codes.

ERROR: <error_no>

AT+WLP2PCONN

Function Description

P2P device connection, including GO Nego, Group Formation and Connection.

Command Format

AT+WLCONN=[<type>,<value>,<type>,<value>……]

Response Format

Success Response:

OK

Error Response: definitions of error_no are in Wi-Fi AT Error Codes.

ERROR: <error_no>

Parameters

<type>:

Parameter type, followed by corresponding <value>

  • peer:followed by the MAC address of the peer device

  • pbc:the <value> field can be omitted

  • pin_display:the <value> field can be omitted

  • pin_keypad:followed by 8-digit PIN code

  • go_intent:followed by the value of GO intent

<value>:

Specific parameter corresponding to <type>

<peer>:

the MAC address of the peer device

  • Format: Colon-separated hexadecimal (e.g., 1a:2b:3c:4d:5e:6f)

<pin_keypad>:

PIN code

  • 8-digit PIN code(e.g., 12345678)

<go_intent>:

the intent to become GO

  • Valid range: [0, 15]. If the go_intent parameter is not specified, a random value will be generated. If go_intent=15, the device will become GO.

AT Messages

  • The following P2P notification message will be displayed during the connection process:

    P2P-NOTIFY: P2P-GO-NEG-SUCCESS
    P2P-NOTIFY: P2P-GROUP-FORMATION-SUCCESS
    P2P-NOTIFY: P2P-GROUP-STARTED
    
  • Once the connection is successful, GO will display:

    [$]client connected:<client_mac_addr>
    [$]assign client ip:<ip_addr>
    
  • Once the connection is successful, GC will display:

    [$]wifi connected
    [$]wifi got ip:<ip_addr>
    

AT+WLP2PDISCONN

Function Description

Disconnect and delete group.

Command Format

AT+WLP2PDISCONN

Response Format

Success Response:

OK

Error Response: definitions of error_no are in Wi-Fi AT Error Codes.

ERROR: <error_no>

AT+WLP2PSTATE

Function Description

Query P2P status information.

Command Format

AT+WLP2PSTATE

AT+WLP2PFIND

Function Description

Start P2P Device Discovery.

Command Format

AT+WLP2PFIND=[<timeout_sec>]

Response Format

Success Response:

OK

Error Response: definitions of error_no are in Wi-Fi AT Error Codes.

ERROR: <error_no>

Parameters

<timeout_sec>:

The timeout value for device discovery, in seconds. The default is 30 seconds if not specified.

AT Messages

  • When a P2P device is scanned, its basic information will be displayed, including the P2P Device Address, P2P role (GC, GO, or DEVICE), name, and listen channel. For example:

    P2P-NOTIFY: P2P-DEVICE-SCANNED 00:e0:4c:00:14:2d role=DEVICE name=DIRECT- listen_ch=6
    
  • When the device discovery phase ends, the following message will be displayed:

    P2P-NOTIFY: P2P-FIND-STOPPED
    

AT+WLP2PPEERS

Function Description

Query the scanned P2P devices.

Command Format

AT+WLP2PPEERS

Response Format

Success Response:

OK

AT Messages

  • Displays information of all discovered devices, including P2P Device Address, P2P role (GC, GO, or DEVICE) and listen channel, as shown in the example below:

    Found p2p peers:
    [0]:00:e0:4c:00:14:2d, P2P_DEV, listen_ch 6
    [1]:00:e0:4c:00:14:2f, P2P_DEV, listen_ch 11