ESP8266 Developer Zone The Official ESP8266 Forum 2016-05-23T23:46:22+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1997 2016-05-23T23:46:22+08:00 2016-05-23T23:46:22+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1997&p=7039#p7039 <![CDATA[Re: rtos_sdk 库中无system_init_done_cb 如何调用 wifi_station_scan()]]> Statistics: Posted by dearwind153 — Mon May 23, 2016 11:46 pm


]]>
2016-04-12T13:35:01+08:00 2016-04-12T13:35:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1997&p=6424#p6424 <![CDATA[Re: rtos_sdk 库中无system_init_done_cb 如何调用 wifi_station_scan()]]>
在您的代码中,user_scan

Code:

memcpy(config.ssid, g_store_station_config.ssid, strlen(g_store_station_config.ssid));

这里的 config.ssid 是个空指针,会引起程序崩溃。

Statistics: Posted by ESP_Faye — Tue Apr 12, 2016 1:35 pm


]]>
2016-04-08T00:14:12+08:00 2016-04-08T00:14:12+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1997&p=6384#p6384 <![CDATA[rtos_sdk 库中无system_init_done_cb 如何调用 wifi_station_scan()]]> 2. 我的代码实现如下

Code:

#include "esp_common.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
#include "user_esp_platform.h"
#include "user_config.h"
#include "esp_sta.h"

#define server_ip "192.168.101.142"
#define server_port 9669


struct station_config g_store_station_config;



void smartconfig_done(sc_status status, void *pdata)
{
    switch(status) {
        case SC_STATUS_WAIT:
            printf("SC_STATUS_WAIT\n");
            break;
        case SC_STATUS_FIND_CHANNEL:
            printf("SC_STATUS_FIND_CHANNEL\n");
            break;
        case SC_STATUS_GETTING_SSID_PSWD:
            printf("SC_STATUS_GETTING_SSID_PSWD\n");
            sc_type *type = pdata;
            if (*type == SC_TYPE_ESPTOUCH) {
                printf("SC_TYPE:SC_TYPE_ESPTOUCH\n");
            } else {
                printf("SC_TYPE:SC_TYPE_AIRKISS\n");
            }
            break;
        case SC_STATUS_LINK:
            printf("SC_STATUS_LINK\n");
            struct station_config *sta_conf = pdata;
         memcpy(g_store_station_config.ssid, sta_conf->ssid, strlen(sta_conf->ssid));
         memcpy(g_store_station_config.password, sta_conf->password, strlen(sta_conf->password));
   
           wifi_station_set_config(sta_conf);
           wifi_station_disconnect();
           wifi_station_connect();
            break;
        case SC_STATUS_LINK_OVER:
            printf("SC_STATUS_LINK_OVER\n");
            if (pdata != NULL) {
                uint8 phone_ip[4] = {0};

                memcpy(phone_ip, (uint8*)pdata, 4);
                printf("Phone ip: %d.%d.%d.%d\n",phone_ip[0],phone_ip[1],phone_ip[2],phone_ip[3]);
            }
            smartconfig_stop();
         wifi_station_set_config(&g_store_station_config);
            break;
    }
   
}

void user_scan_done(void *arg, STATUS status)
{
   struct station_config config;
   STATION_STATUS station_status;
   memcpy(config.ssid, g_store_station_config.ssid, strlen(g_store_station_config.ssid));
   memcpy(config.password, g_store_station_config.password, strlen(g_store_station_config.password));

   wifi_station_set_config(&config);
   wifi_station_disconnect();
   wifi_station_connect();

   while(1)
   {
       vTaskDelay( 100 / portTICK_RATE_MS );
      station_status = wifi_station_get_connect_status();
      switch(station_status)
      {
         case STATION_IDLE:
            printf("STATION_IDLE\r\n");
            break;
         case STATION_CONNECTING:
            printf("STATION_CONNECTING\r\n");
            break;
         case STATION_WRONG_PASSWORD:
            printf("STATION_WRONG_PASSWORD\r\n");
            break;
         case STATION_NO_AP_FOUND:
            printf("STATION_NO_AP_FOUND\r\n");
            break;
         case STATION_CONNECT_FAIL:
            printf("STATION_CONNECT_FAIL\r\n");
            break;
         case STATION_GOT_IP:
            printf("STATION_GOT_IP\r\n");
            return;
         default:
            break;
      }
   }
}




void user_scan(void)
{
   struct scan_config config;
   memset(&config, 0, sizeof(config));
   memcpy(config.ssid, g_store_station_config.ssid, strlen(g_store_station_config.ssid));
   wifi_station_scan(&config, user_scan_done);
}


void smartconfig_task(void *pvParameters)
{
   memset(&g_store_station_config, 0, sizeof(g_store_station_config));
   
   wifi_station_get_config_default(&g_store_station_config);
    if (strlen(g_store_station_config.ssid) != 0)
   {
      printf("user_scan, ssid:%s\n", g_store_station_config.ssid);
      user_scan();
    }
   else
   {
      os_printf("smartconfig\n");
      smartconfig_start(smartconfig_done);
    }
   
    vTaskDelete(NULL);
}

/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{
     /*uart_div_modify(0, UART_CLK_FREQ / (115200));
      SET_PERI_REG_MASK(UART_CONF0(0), UART_RXFIFO_RST | UART_TXFIFO_RST);
      CLEAR_PERI_REG_MASK(UART_CONF0(0), UART_RXFIFO_RST | UART_TXFIFO_RST);*/
     //user_esp_platform_init();

    printf("SDK version:%s\n", system_get_sdk_version());
    printf("ESP8266 chip ID:0x%x\n", system_get_chip_id());

    /* need to set opmode before you set config */
    wifi_set_opmode(STATION_MODE);
   
    //xTaskCreate(task1, "task1", 256, "task1 running!\r\n", 2, NULL);
    //xTaskCreate(task2, "task2", 256, "task2 running!\r\n", 2, NULL);

    xTaskCreate(smartconfig_task, "smartconfig_task", 256, NULL, 2, NULL);
}


3. 第一次smart_config可以正常配置连接路由器,但rst之后,就会出现无限重启

Code:

SDK version:1.4.0(c599790)
ESP8266 chip ID:0xc1b01
mode : sta(5c:cf:7f:0c:1b:01)
add if0
smartconfig
SC version: V2.5.3
f r0, scandone
f r0, scandone
SC_STATUS_FIND_CHANNEL

TYPE: ESPTOUCH
T|sniffer on ch:11
T|PHONE MAC: 58 44 98 fa 97 87
T|AP MAC   : a8 57 4e 65 7c aa
T|Head Len : 82
SC_STATUS_GETTING_SSID_PSWD
SC_TYPE:SC_TYPE_ESPTOUCH
T|SYNC STATUS
T|28-0
T|8-1
T|51-2
T|118-3
T|SCAN SSID: MERCURY-JQY
T|all lenth: 28,pswd lenth: 8
T|SCAN CRC SSID: 1
T|61-4
T|192-5
T|168-6
T|1-7
T|108-8
T|P-9
T|@-10
T|s-11
T|s-12
T|w-13
T|0-14
T|r-15
T|d-16
T|0-28-1
T|1-8-1
T|2-51-1
T|3-118-1
T|4-61-1
T|5-192-1
T|6-168-1
T|7-1-1
T|8-108-1
T|9-P-1
T|10-@-1
T|11-s-1
T|12-s-1
T|13-w-1
T|14-0-1
T|15-r-1
T|16-d-1
T|pswd: P@ssw0rd
T|ssid: MERCURY-JQY
T|bssid: a8 57 4e 65 7c aa
SC_STATUS_LINK
f r0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
pm open phy_2,type:2 0 0
cnt

connected with MERCURY-JQY, channel 11
dhcp client start...
ip:192.168.1.105,mask:255.255.255.0,gw:192.168.1.1
SC_STATUS_LINK_OVER
Phone ip: 192.168.1.108
free heap size:48600

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 1856, room 16
tail 0
chksum 0x63
load 0x3ffe8000, len 776, room 8
tail 0
chksum 0x02
load 0x3ffe8310, len 552, room 8
tail 0
chksum 0x79
csum 0x79

2nd boot version : 1.5
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

OS SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17
犟+P禇h〥r phy ver: 762, pp ver: 10.4

SDK version:1.4.0(c599790)
ESP8266 chip ID:0xc1b01
mode : sta(5c:cf:7f:0c:1b:01)
add if0
f r0, user_scan, ssid:MERCURY-JQY
Fatal exception (29):
epc1=0x4000df82
epc2=0x00000000
epc3=0x40100470
epcvaddr=0x00000000
depc=0x00000000
@*r吥P钡盞韙r@轾.┭Ko8a 晟*盩北暴┠P盉┑眳ⅫnzAl )閙~盩[!Pt盄j|锦*爹*眽鴑zAl )閙~盤[!Pt莔盄j|┑眽鴑zAl )閙~盫r迸…囬r当X鑒晇 倒夅鑒壯* 〉戝鑒嵣-Ae瓑Xz噉Z彭乭 i~P法vA顅P北仮麿S SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17
phy ver: 762, pp ver: 10.4

SDK version:1.4.0(c599790)
ESP8266 chip ID:0xc1b01
mode : sta(5c:cf:7f:0c:1b:01)
add if0
f r0, user_scan, ssid:MERCURY-JQY
Fatal exception (29):
epc1=0x4000df82
epc2=0x00000000
epc3=0x40100479
epcvaddr=0x00000000
depc=0x00000000
@*r吥P钡盞韙r@轾.┭Ko8a 晟*盩北暴┠P盉┑眳ⅫnzAl )閙~盩[!Pt盄j|锦*爹*眽鴑zAl )閙~盤[!Pt莔盄j|┑眽鴑zAl )閙~盫r迸…囬r当X鑒晇 倒夅鑒壯* 〉戝鑒嵣-Ae瓑Xz噉Z彭乭 i~P法vA顅P北仮麿S SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17
phy ver: 762, pp ver: 10.4

SDK version:1.4.0(c599790)
ESP8266 chip ID:0xc1b01
mode : sta(5c:cf:7f:0c:1b:01)
add if0
f r0, user_scan, ssid:MERCURY-JQY
Fatal exception (29):
epc1=0x4000df82
epc2=0x00000000
epc3=0x4010046a
epcvaddr=0x00000000
depc=0x00000000
@*r吥P钡盞韙r@轾.┭Ko8a 晟*盩北暴┠P盉┑眳ⅫnzAl )閙~盩[!Pt盄j|锦*爹*眽鴑zAl )閙~盤[!Pt莔盄j|┑眽鴑zAl )閙~盫r迸…囬r当X鑒晇 倒夅鑒壯* 〉戝鑒嵣-Ae瓑Xz噉Z彭乭 i~P法vA顅P北仮麿S SDK ver: 1.4.0(c599790) compiled @ Mar  1 2016 17:25:17
phy ver: 762, pp ver: 10.4

SDK version:1.4.0(c599790)
ESP8266 chip ID:0xc1b01
mode : sta(5c:cf:7f:0c:1b:01)
add if0
f r0, user_scan, ssid:MERCURY-JQY
Fatal exception (29):
epc1=0x4000df82
epc2=0x00000000
epc3=0x40202918
epcvaddr=0x00000000
depc=0x00000000

4. 我应该怎办?期待解答,谢谢!

Statistics: Posted by dearwind153 — Fri Apr 08, 2016 12:14 am


]]>