esp8266 smartconfig V2.5.4 Unable to connect to the distribution network with esptouch app

Open
#9,317 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
cpp

Research direction

Start by reproducing the report with the supplied setup, ESP8266WiFi.h, smartconfig.h, and the ESP-Touch app. Trace the smartconfig_start callback through SC_STATUS_FIND_CHANNEL, SC_STATUS_LINK, and SC_STATUS_LINK_OVER, checking where connection progress stops. Done means the device receives the credentials and successfully connects to the router.

Written by the indexing model from the issue text.

Description

`
#include <ESP8266WiFi.h>
#include <smartconfig.h>

// 回调函数
void smartConfigCallback(uint32_t st, void* result)
{
sc_status status = (sc_status) st;
Serial.printf("[SmartConfig] status:%d\n", status);

if (status == SC_STATUS_FIND_CHANNEL) {
Serial.println("正在扫描信道... 请打开 ESP-Touch App 开始配网");
}
else if (status == SC_STATUS_GETTING_SSID_PSWD) {
Serial.println("正在接收 SSID 和密码...");
if (result != NULL) {
sc_type type = (sc_type)result;
if (*type == SC_TYPE_ESPTOUCH) {
Serial.println("协议类型: ESP-Touch");
} else if (*type == SC_TYPE_AIRKISS) {
Serial.println("协议类型: AirKiss");
}
}
}
else if (status == SC_STATUS_LINK) {
Serial.println("已成功获取 SSID 和密码!正在连接路由器...");

if (result != NULL) {
  struct station_config *sta_conf = (struct station_config *)result;
  
  // 保存配置并连接
  wifi_station_set_config(sta_conf);
  wifi_station_disconnect();
  wifi_station_connect();
}

}
else if (status == SC_STATUS_LINK_OVER) {
Serial.println("SmartConfig 配网成功!已连接到路由器");

if (result != NULL) {
  uint8_t *ip = (uint8_t*)result;
  Serial.printf("手机端 IP: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
}

smartconfig_stop();   // 停止 SmartConfig,释放资源
Serial.print("设备本地 IP: ");
Serial.println(WiFi.localIP());

}
else {
Serial.printf("未知状态: %d\n", status);
}
}

void setup() {
Serial.begin(115200);
delay(1000);
// We start by connecting to a WiFi network
/* Explicitly set the ESP8266 to be a WiFi-client, otherwise, it by default,
would try to act as both a client and an access-point and could cause
network-issues with your other WiFi-devices on your WiFi-network. */
WiFi.mode(WIFI_STA);

Serial.println(smartconfig_get_version());

esptouch_set_timeout(30);

if(smartconfig_start(reinterpret_cast<sc_callback_t>(smartConfigCallback), 1))
{
Serial.println("SmartConfig 已启动,等待手机发送配置...");
} else {
Serial.println("SmartConfig 启动失败!");
return;
}
}

void loop() {

delay(5000);

}`

Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from esp8266/Arduino

All issues in esp8266/Arduino

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.