SDK4.0 This document shows Ameba SDK 4.0 APIs

- Main Page
- Modules
- Data Structures
- Files

Functions
WPS/P2P
Ameba SDK » WLAN

WPS/P2P functions. More...

## Functions
int | wifi_p2p_init (u8 *dev_addr, int go_intent, u8 listen_ch, u8 op_ch)
| Initialize P2P data. More...
void | wifi_p2p_deinit ()
| Deinitialize P2P data. More...
void | cmd_wifi_p2p_start (int argc, char **argv)
| Command to start WiFi Direct mode for commonly use. Can refer to ATWG in atcmd_wifi.c. After executing this command, P2P resource will be allocated and the driver enter P2P mode. More...
void | cmd_wifi_p2p_stop (int argc, char **argv)
| Command to stop WiFi Direct mode for commonly use. Can refer to ATWH in atcmd_wifi.c. After execute this command, WLAN driver will release P2P resources and turn off Wi-Fi. More...
void | cmd_p2p_info (int argc, char **argv)
| Command to show P2P role, P2P group information, and memory usage. Can refer to ATWN in atcmd_wifi.c. More...
void | wifi_p2p_set_dev_name (const char *dev_name)
| Set the device name in WPS ie and P2P ie. More...
void | wifi_p2p_set_manufacturer (const char *manufacturer)
| Set the manufacturer in WPS ie. More...
void | wifi_p2p_set_model_name (const char *model_name)
| Set the model name in WPS ie. More...
void | wifi_p2p_set_model_number (const char *model_number)
| Set the model number in WPS ie. More...
void | wifi_p2p_set_serial_number (const char *serial_number)
| Set the serial number in WPS ie. More...
void | wifi_p2p_set_pri_dev_type (const u8 *pri_dev_type)
| Set the primary device type in WPS ie and P2P ie. More...
void | wifi_p2p_set_ssid (const char *ssid_in)
| Set the GO SSID. More...
void | wifi_p2p_init_auto_go_params (void *res, u8 *passphrase, u8 channel)
| Initialize the Wi-Fi Direct GO parameters. More...
int | wifi_p2p_start_auto_go (void *res)
| Start Wi-Fi Direct GO. More...
int | cmd_wifi_p2p_auto_go_start (int argc, char **argv)
| Command to start WiFi Direct GO mode for commonly use. Can refer to ATWg in atcmd_wifi.c. More...
int | wps_start (u16 wps_config, char *pin, u8 channel, char *ssid)
| Start WPS enrollee process. More...
void | cmd_wps (int argc, char **argv)
| Command to start WPS enrollee process for commonly use. Can refer to ATWW in atcmd_wifi.c. More...
void | wifi_start_ap_wps_thread (u16 config_methods, char *pin)
| Start a WPS registrar thread. More...
void | cmd_ap_wps (int argc, char **argv)
| Command to start WPS registrar process for commonly use. Can refer to ATWw in atcmd_wifi.c. More...

## Detailed Description

WPS/P2P functions.

## Function Documentation

void cmd_ap_wps | ( | int | argc,
|  | char ** | argv
| ) |  |

Command to start WPS registrar process for commonly use. Can refer to ATWw in atcmd_wifi.c.

Warning
  Before invoking this function, the Wi-Fi should be in SoftAP mode.

Parameters

  [in] | argc | Command line argument. Argument count.
  [in] | argv | Command line argument. Argument vector.

Returns
  0 on success

Note
  Command style for example:
  - cmd_ap_wps pbc
  - cmd_ap_wps pin
  - cmd_ap_wps pin 12345678
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_WPS_AP are enabled in platform_opts.h.

void cmd_p2p_info | ( | int | argc,
|  | char ** | argv
| ) |  |

Command to show P2P role, P2P group information, and memory usage. Can refer to ATWN in atcmd_wifi.c.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | argc | Command line argument. Argument count. Just let it be NULL.
  [in] | argv | Command line argument. Argument vector. Just let it be NULL.

Returns
  None

Note
  Command style:
  - cmd_p2p_info
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

int cmd_wifi_p2p_auto_go_start | ( | int | argc,
|  | char ** | argv
| ) |  |

Command to start WiFi Direct GO mode for commonly use. Can refer to ATWg in atcmd_wifi.c.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | argc | Command line argument. Argument count. Just let it be NULL.
  [in] | argv | Command line argument. Argument vector. Just let it be NULL.

Returns
  0 if success, otherwise return -1.

Note
  Command style:
  - cmd_wifi_p2p_auto_go_start
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void cmd_wifi_p2p_start | ( | int | argc,
|  | char ** | argv
| ) |  |

Command to start WiFi Direct mode for commonly use. Can refer to ATWG in atcmd_wifi.c.
After executing this command, P2P resource will be allocated and the driver enter P2P mode.

Warning
  If the started Wi-Fi Direct mode is no longer needed, please make sure to invoke cmd_wifi_p2p_stop() before doing other procedures.

Parameters

  [in] | argc | Command line argument. Argument count. Just let it be NULL.
  [in] | argv | Command line argument. Argument vector. Just let it be NULL.

Returns
  None

Note
  Command style:
  - cmd_wifi_p2p_start
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void cmd_wifi_p2p_stop | ( | int | argc,
|  | char ** | argv
| ) |  |

Command to stop WiFi Direct mode for commonly use. Can refer to ATWH in atcmd_wifi.c.
After execute this command, WLAN driver will release P2P resources and turn off Wi-Fi.

Warning
  This command must be invoked if the enabled Wi-Fi Direct mode is no longer used.

Parameters

  [in] | argc | Command line argument. Argument count. Just let it be NULL.
  [in] | argv | Command line argument. Argument vector. Just let it be NULL.

Returns
  None

Note
  Command style:
  - cmd_wifi_p2p_stop
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void cmd_wps | ( | int | argc,
|  | char ** | argv
| ) |  |

Command to start WPS enrollee process for commonly use. Can refer to ATWW in atcmd_wifi.c.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on().

Parameters

  [in] | argc | Command line argument. Argument count.
  [in] | argv | Command line argument. Argument vector.

Returns
  0 on success.

Note
  Command style for example:
  - cmd_wps pbc
  - cmd_wps pin
  - cmd_wps pin 12345678
  Please make sure CONFIG_ENABLE_WPS is enabled in platform_opts.h.

void wifi_p2p_deinit | ( |  | ) |

Deinitialize P2P data.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P).

Parameters

  None |

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

int wifi_p2p_init | ( | u8 * | dev_addr,
|  | int | go_intent,
|  | u8 | listen_ch,
|  | u8 | op_ch
| ) |  |

Initialize P2P data.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P).

Parameters

  [in] | dev_addr | The device address.
  [in] | go_intent | The GO intent.
  [in] | listen_ch | The listen channel.
  [in] | op_ch | The operation channel.

Returns
  0 on success, otherwise return -1.

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
  You can reference cmd_wifi_p2p_start() to understand the process of starting P2P mode.

void wifi_p2p_init_auto_go_params | ( | void * | res,
|  | u8 * | passphrase,
|  | u8 | channel
| ) |  |

Initialize the Wi-Fi Direct GO parameters.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [out] | res | The location where the set parameters will be stored. (p2p_go_neg_results)
  [in] | passphrase | The GO passphrase.
  [in] | channel | The operation channel.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_dev_name | ( | const char * | dev_name | ) |

Set the device name in WPS ie and P2P ie.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | dev_name | Device name to be set. The max string length is 32 bytes.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_manufacturer | ( | const char * | manufacturer | ) |

Set the manufacturer in WPS ie.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | manufacturer | Manufacturer to be set. The max string length is 64 bytes.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_model_name | ( | const char * | model_name | ) |

Set the model name in WPS ie.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | model_name | Model name to be set. The max string length is 32 bytes.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_model_number | ( | const char * | model_number | ) |

Set the model number in WPS ie.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | model_number | Model number to be set. The max string length is 32 bytes.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_pri_dev_type | ( | const u8 * | pri_dev_type | ) |

Set the primary device type in WPS ie and P2P ie.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | pri_dev_type | Primary device type to be set. The string length is 8 bytes. The first two bytes are category ID, and the last two bytes are subcategory ID. The middle four bytes are 0x 00-50-F2-04.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_serial_number | ( | const char * | serial_number | ) |

Set the serial number in WPS ie.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | serial_number | Serial number to be set. The max string length is 32 bytes.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

void wifi_p2p_set_ssid | ( | const char * | ssid_in | ) |

Set the GO SSID.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | ssid_in | Ssid_in will be set as GO SSID. The string length is between 1 byte and 32 bytes.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.

int wifi_p2p_start_auto_go | ( | void * | res | ) |

Start Wi-Fi Direct GO.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on(RTW_MODE_P2P) and P2P be initialized by using wifi_p2p_init().
  You can reference cmd_wifi_p2p_start() to initialize them.

Parameters

  [in] | res | The parameters for GO negotiation. (p2p_go_neg_results)

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_P2P are enabled in platform_opts.h.
  You can reference cmd_wifi_p2p_auto_go_start() to understand the process of opening the P2P automatic GO.

void wifi_start_ap_wps_thread | ( | u16 | config_methods,
|  | char * | pin
| ) |  |

Start a WPS registrar thread.

Warning
  Before invoking this function, the Wi-Fi should be in SoftAP mode.

Parameters

  [in] | config_methods | WPS configure method. Options are: WPS_CONFIG_DISPLAY, WPS_CONFIG_KEYPAD, and WPS_CONFIG_PUSHBUTTON.
  [in] | pin | PIN number. Can be set to NULL.

Returns
  None

Note
  Please make sure CONFIG_ENABLE_WPS and CONFIG_ENABLE_WPS_AP are enabled in platform_opts.h.
  You can reference cmd_ap_wps() to know how to choose input parameters.

int wps_start | ( | u16 | wps_config,
|  | char * | pin,
|  | u8 | channel,
|  | char * | ssid
| ) |  |

Start WPS enrollee process.

Warning
  Before invoking this function, the Wi-Fi should be enabled by using wifi_on().

Parameters

  [in] | wps_config | WPS configure method. Options are: WPS_CONFIG_DISPLAY, WPS_CONFIG_KEYPAD, and WPS_CONFIG_PUSHBUTTON.
  [in] | pin | PIN number. Can be set to NULL if using WPS_CONFIG_PUSHBUTTON.
  [in] | channel | Channel. Currently un-used, can be set to 0.
  [in] | ssid | Target network SSID. Can be set to NULL if no target network specified.

Returns
  0 on success.

Note
  Please make sure CONFIG_ENABLE_WPS is enabled in platform_opts.h.
  You can reference cmd_wps() to know how to choose input parameters.