I used latest SDK 1.1.0 ( both Opensdk or Espressif sdk is fine) , and run the smart config code below , But the Official espressif IOT esptouch apk was not able to assign the SSID or Password
Then used this esp8266 dash app from
https://github.com/DeqingSun/ESP8266-Dash-Button/tree/master/pre_compiled_bin_files
app_SDK_110.apk
IN case if it didn’t work try to replace following files from
esp_iot_sdk_v1.1.0_15_05_26\lib
-libsmartconfig.a
-libmain.a
To your development environment
Smartconfig Code on ESP8266
#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
#include "smartconfig.h"
sc_type SC_Type = 0;
void ICACHE_FLASH_ATTR
smartconfig_done(sc_status status, void *pdata)
{
int i =0;
switch(status) {
case SC_STATUS_WAIT:
os_printf("SC_STATUS_WAIT\n");
break;
case SC_STATUS_FIND_CHANNEL:
os_printf("SC_STATUS_FIND_CHANNEL\n");
break;
case SC_STATUS_GETTING_SSID_PSWD:
os_printf("SC_STATUS_GETTING_SSID_PSWD\n");
break;
case SC_STATUS_LINK:
os_printf("SC_STATUS_LINK\n");
struct station_config *sta_conf = pdata;
wifi_station_set_config(sta_conf);
wifi_station_disconnect();
wifi_station_connect();
break;
case SC_STATUS_LINK_OVER:
os_printf("SC_STATUS_LINK_OVER\n");
if (SC_Type == SC_TYPE_ESPTOUCH) {
uint8 phone_ip[4] = {0};
os_memcpy(phone_ip, (uint8*)pdata, 4);
os_printf("Phone ip: %d.%d.%d.%d\n",phone_ip[0],phone_ip[1],phone_ip[2],phone_ip[3]);
}
smartconfig_stop();
break;
}
}
user_rf_pre_init()
{
}
void user_init(void)
{
uart_init(115200, 115200);
os_printf("SDK version:%s\n", system_get_sdk_version());
SC_Type = SC_TYPE_ESPTOUCH;
wifi_set_opmode(STATION_MODE);
smartconfig_start(SC_Type, smartconfig_done);
}
Sample run of the code on esp8266
SDK version:1.1.0
TYPE: ESPTOUCH V2.1
mode : sta(18:fe:34:a1:c3:5f)
add if0
scandone
scandone
scandone
SC_STATUS_FIND_CHANNEL
T|!!!
T|!!!
T|!!!
T|sniffer on ch:6
T|PHONE MAC: 34 bb 26 92 f0 d7
T|AP MAC : 2c 3f 38 7e 62 12
T|Head Len : 66
SC_STATUS_GETTING_SSID_PSWD
T|SYNC STATUS
T|103-5
T|0-6
T|17-7
T|16-0
T|154-2
T|133-3
T|103-5
T|0-6
T|17-7
T|16-0
T|0-1
T|SSID: internet
T|all lenth: 16,pswd lenth: 0
T|SCAN CRC SSID: 1
T|133-3
T|10-4
T|0-16-2
T|1-0-1
T|2-154-1
T|3-133-2
T|4-10-1
T|5-103-2
T|6-0-2
T|7-17-2
T|pswd:
T|ssid: internet
T|token: 10
SC_STATUS_LINK
scandone
reconnect
No comments:
Post a Comment