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

  • ssid_postfix:followed by SSID postfix

<value>:

Specific parameter corresponding to <type>

<listen_ch>:

Listen Channel

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

<op_ch>:

Operating Channel

  • Any permitted Wi-Fi channel (2.4/5GHz) supported by the device and subject to regulatory constraints.

<ssid_postfix>:

SSID postfix string,default value is “-REALTEKDEV”.

Note

If the listen_ch or op_ch parameter is omitted, 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 Negotiation, 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

  • 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+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-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-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
    

AT+WLP2PGO

Function Description

Start auto GO

Command Format

AT+WLP2PGO=[<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>

  • ssid: followed by SSID name

  • pw: followed by connection password

  • ch: followed by operating channel number

<value>:

Specific parameter corresponding to <type>

<ssid>:

SSID name

  • Maximum length: 32 characters. Each SSID shall begin with the ASCII characters “DIRECT-“. Following “DIRECT-“ the SSID shall contain two ASCII characters “xy”, which can be the upper case letters, lower case letters or numbers.

<pw>:

connection password

<ch>:

operating channel number

Note

This command enables the device to act as the GO and initiate a P2P Group without GO negotiation. When a P2P device wants to connect to this GO, it should send a Provision Discovery Request frame first. The GO will reply with a Provision Discovery Response frame and start WPS authentication.