智能配置

API 参考手册

类型定义

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

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

Parameters
  • status: Status of SmartConfig:
    • SC_STATUS_GETTING_SSID_PSWD : pdata is a pointer of smartconfig_type_t, means config type.
    • SC_STATUS_LINK : pdata is a pointer of struct station_config.
    • SC_STATUS_LINK_OVER : pdata is a pointer of phone’s IP address(4 bytes) if pdata unequal NULL.
    • otherwise : parameter void *pdata is NULL.
  • pdata: According to the different status have different values.

函数

const char *esp_smartconfig_get_version(void)

Get the version of SmartConfig.

Return
  • SmartConfig version const char.

esp_err_t esp_smartconfig_start(sc_callback_t cb, ...)

Start SmartConfig, config ESP device to connect AP. You need to broadcast information by phone APP. Device sniffer special packets from the air that containing SSID and password of target AP.

Attention
1. This API can be called in station or softAP-station mode.
Attention
2. Can not call esp_smartconfig_start twice before it finish, please call esp_smartconfig_stop first.
Return
  • ESP_OK: succeed
  • others: fail
Parameters
  • cb: SmartConfig callback function.
  • ...: log 1: UART output logs; 0: UART only outputs the result.

esp_err_t esp_smartconfig_stop(void)

Stop SmartConfig, free the buffer taken by esp_smartconfig_start.

Attention
Whether connect to AP succeed or not, this API should be called to free memory taken by smartconfig_start.
Return
  • ESP_OK: succeed
  • others: fail

esp_err_t esp_esptouch_set_timeout(uint8_t time_s)

Set timeout of SmartConfig process.

Attention
Timing starts from SC_STATUS_FIND_CHANNEL status. SmartConfig will restart if timeout.
Return
  • ESP_OK: succeed
  • others: fail
Parameters
  • time_s: range 15s~255s, offset:45s.

esp_err_t esp_smartconfig_set_type(smartconfig_type_t type)

Set protocol type of SmartConfig.

Attention
If users need to set the SmartConfig type, please set it before calling esp_smartconfig_start.
Return
  • ESP_OK: succeed
  • others: fail
Parameters
  • type: Choose from the smartconfig_type_t.

esp_err_t esp_smartconfig_fast_mode(bool enable)

Set mode of SmartConfig. default normal mode.

Attention
1. Please call it before API esp_smartconfig_start.
Attention
2. Fast mode have corresponding APP(phone).
Attention
3. Two mode is compatible.
Return
  • ESP_OK: succeed
  • others: fail
Parameters
  • enable: false-disable(default); true-enable;