ESP32_RTOS_SDK V1.1.0

- Main Page
- Modules
- Data Structures
- Files

Typedefs | Enumerations | Functions
Smartconfig APIs
WiFi Related APIs

SmartConfig APIs. More...

## Typedefs

typedef void(* | sc_callback_t) (sc_status status, void *pdata)
| The callback of SmartConfig, executed when smart-config status changed. More...

## Enumerations

enum | sc_status { SC_STATUS_WAIT = 0, SC_STATUS_FIND_CHANNEL, SC_STATUS_GETTING_SSID_PSWD, SC_STATUS_LINK, SC_STATUS_LINK_OVER }
enum | sc_type { SC_TYPE_ESPTOUCH = 0, SC_TYPE_AIRKISS, SC_TYPE_ESPTOUCH_AIRKISS }

## Functions

const char * | smartconfig_get_version (void)
| Get the version of SmartConfig. More...
bool | smartconfig_start (sc_callback_t cb,...)
| Start SmartConfig mode. More...
bool | smartconfig_stop (void)
| Stop SmartConfig, free the buffer taken by smartconfig_start. More...
bool | esptouch_set_timeout (uint8 time_s)
| Set timeout of SmartConfig. More...
bool | smartconfig_set_type (sc_type type)
| Set protocol type of SmartConfig. More...

## Detailed Description

SmartConfig APIs.

SmartConfig can only be enabled in station only mode. Please make sure the target AP is enabled before enable SmartConfig.

## Typedef Documentation

typedef void(* sc_callback_t) (sc_status status, void *pdata)

The callback of SmartConfig, executed when smart-config status changed.

Parameters

  sc_status | status : status of SmartConfig:
  - if status == SC_STATUS_GETTING_SSID_PSWD, parameter void *pdata is a pointer of sc_type, means SmartConfig type: AirKiss or ESP-TOUCH.
  - if status == SC_STATUS_LINK, parameter void *pdata is a pointer of struct station_config;
  - if status == SC_STATUS_LINK_OVER, parameter void *pdata is a pointer of mobile phone's IP address, 4 bytes. This is only available in ESPTOUCH, otherwise, it is NULL.
  - otherwise, parameter void *pdata is NULL.
  void | *pdata : data of SmartConfig

Returns
  null

## Enumeration Type Documentation

enum sc_status

Enumerator
SC_STATUS_WAIT | waiting, do not start connection in this phase
SC_STATUS_FIND_CHANNEL | find target channel, start connection by APP in this phase
SC_STATUS_GETTING_SSID_PSWD | getting SSID and password of target AP
SC_STATUS_LINK | connecting to target AP
SC_STATUS_LINK_OVER | got IP, connect to AP successfully

enum sc_type

Enumerator
SC_TYPE_ESPTOUCH | protocol: ESPTouch
SC_TYPE_AIRKISS | protocol: AirKiss
SC_TYPE_ESPTOUCH_AIRKISS | protocol: ESPTouch and AirKiss

## Function Documentation

bool esptouch_set_timeout | ( | uint8 | time_s | ) |

Set timeout of SmartConfig.

Attention
  SmartConfig timeout start at SC_STATUS_FIND_CHANNEL, SmartConfig will restart if timeout.

Parameters

  uint8 | time_s : range 15s~255s, offset:45s.

Returns
  true : succeed
  false : fail

const char* smartconfig_get_version | ( | void |  | ) |

Get the version of SmartConfig.

Parameters

  null |

Returns
  SmartConfig version

bool smartconfig_set_type | ( | sc_type | type | ) |

Set protocol type of SmartConfig.

Attention
  If users need to set the SmartConfig type, please set it before calling smartconfig_start.

Parameters

  sc_type | type : AirKiss, ESP-TOUCH or both.

Returns
  true : succeed
  false : fail

bool smartconfig_start | ( | sc_callback_t | cb,
|  |  | ...
| ) |  |

Start SmartConfig mode.

Start SmartConfig mode, to connect ESP32 station to AP, by sniffing for special packets from the air, containing SSID and password of desired AP. You need to broadcast the SSID and password (e.g. from mobile device or computer) with the SSID and password encoded.

Attention
  1. This api can only be called in station mode.
  2. During SmartConfig, ESP32 station and soft-AP are disabled.
  3. Can not call smartconfig_start twice before it finish, please call smartconfig_stop first.
  4. Don't call any other APIs during SmartConfig, please call smartconfig_stop first.

Parameters

  sc_callback_t | cb : SmartConfig callback; executed when SmartConfig status changed;
  uint8 | log : 1, UART output logs; otherwise, UART only outputs the result.

Returns
  true : succeed
  false : fail

bool smartconfig_stop | ( | void |  | ) |

Stop SmartConfig, free the buffer taken by smartconfig_start.

Attention
  Whether connect to AP succeed or not, this API should be called to free memory taken by smartconfig_start.

Parameters

  null |

Returns
  true : succeed
  false : fail