Skip to content

Commit f33be1a

Browse files
author
Espressif Systems
committed
1. sync codes from non-os version 1.1.1:
1). update smartconfig to v2.2; 2). add some new APIs; 3). fix bugs in net80211 and wpa; 2. update smart_config demo; 3. fix a bug in app demo; ***internal version 0f73a14a***
1 parent 7824323 commit f33be1a

File tree

14 files changed

+63
-24
lines changed

14 files changed

+63
-24
lines changed

app/user/user_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ void task2(void *pvParameters)
7575
free(recv_buf);
7676

7777
if (recbytes <= 0) {
78+
close(sta_socket);
7879
printf("C > read data fail!\n");
7980
}
8081
}
@@ -159,8 +160,8 @@ user_init(void)
159160

160161
{
161162
struct station_config *config = (struct station_config *)zalloc(sizeof(struct station_config));
162-
sprintf(config->ssid, "CVR100W_T");
163-
sprintf(config->password, "justfortest");
163+
sprintf(config->ssid, "ZTE_5560");
164+
sprintf(config->password, "espressif");
164165

165166
/* need to sure that you are in station mode first,
166167
* otherwise it will be failed. */

examples/smart_config/user/user_main.c

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,54 @@
2222
#define server_ip "192.168.101.142"
2323
#define server_port 9669
2424

25+
sc_type SC_Type = 0;
26+
2527
void ICACHE_FLASH_ATTR
26-
smartconfig_done(void *data)
28+
smartconfig_done(sc_status status, void *pdata)
2729
{
28-
struct station_config *sta_conf = data;
30+
switch(status) {
31+
case SC_STATUS_WAIT:
32+
printf("SC_STATUS_WAIT\n");
33+
break;
34+
case SC_STATUS_FIND_CHANNEL:
35+
printf("SC_STATUS_FIND_CHANNEL\n");
36+
break;
37+
case SC_STATUS_GETTING_SSID_PSWD:
38+
printf("SC_STATUS_GETTING_SSID_PSWD\n");
39+
break;
40+
case SC_STATUS_LINK:
41+
printf("SC_STATUS_LINK\n");
42+
struct station_config *sta_conf = pdata;
43+
44+
wifi_station_set_config(sta_conf);
45+
wifi_station_disconnect();
46+
wifi_station_connect();
47+
break;
48+
case SC_STATUS_LINK_OVER:
49+
printf("SC_STATUS_LINK_OVER\n");
50+
if (SC_Type == SC_TYPE_ESPTOUCH) {
51+
uint8 phone_ip[4] = {0};
52+
53+
memcpy(phone_ip, (uint8*)pdata, 4);
54+
printf("Phone ip: %d.%d.%d.%d\n",phone_ip[0],phone_ip[1],phone_ip[2],phone_ip[3]);
55+
}
56+
smartconfig_stop();
57+
break;
58+
}
2959

30-
wifi_station_set_config(sta_conf);
31-
wifi_station_disconnect();
32-
wifi_station_connect();
3360
}
3461

3562
void ICACHE_FLASH_ATTR
3663
smartconfig_task(void *pvParameters)
3764
{
38-
smartconfig_start(SC_TYPE_ESPTOUCH, smartconfig_done);//SC_TYPE_AIRKISS
65+
SC_Type = SC_TYPE_ESPTOUCH;
66+
67+
smartconfig_start(SC_Type, smartconfig_done);//SC_TYPE_AIRKISS
3968

4069
vTaskDelete(NULL);
4170
}
4271

43-
void ICACHE_FLASH_ATTR
44-
sc_smartconfig_check(void)
45-
{
46-
if(SC_STATUS_LINK_OVER == smartconfig_get_status()) {
47-
smartconfig_stop();
48-
}
49-
50-
}
72+
5173
/******************************************************************************
5274
* FunctionName : user_init
5375
* Description : entry of user application, init user function here

include/espressif/esp_system.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
#include "c_types.h"
1010

1111
enum rst_reason {
12-
DEFAULT_RST = 0,
13-
WDT_RST = 1,
14-
EXCEPTION_RST = 2,
15-
SOFT_RST = 3
12+
DEFAULT_RST_FLAG = 0,
13+
WDT_RST_FLAG,
14+
EXCEPTION_RST_FLAG,
15+
SOFT_WDT_RST_FLAG,
16+
SOFT_RESTART_FLAG,
17+
DEEP_SLEEP_AWAKE_FLAG
1618
};
1719

1820
struct rst_info{
@@ -55,4 +57,19 @@ void system_uart_de_swap(void);
5557
uint16 system_adc_read(void);
5658
uint16 system_get_vdd33(void);
5759

60+
enum flash_size_map {
61+
FLASH_SIZE_4M_MAP_256_256 = 0,
62+
FLASH_SIZE_2M,
63+
FLASH_SIZE_8M_MAP_512_512,
64+
FLASH_SIZE_16M_MAP_512_512,
65+
FLASH_SIZE_32M_MAP_512_512,
66+
FLASH_SIZE_16M_MAP_1024_1024,
67+
FLASH_SIZE_32M_MAP_1024_1024
68+
};
69+
70+
enum flash_size_map system_get_flash_size_map(void);
71+
72+
bool system_param_save_with_protect(uint16 start_sec, void *param, uint16 len);
73+
bool system_param_load(uint16 start_sec, uint16 offset, void *param, uint16 len);
74+
5875
#endif

include/espressif/smartconfig.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
#ifndef __SMARTCONFIG_H__
77
#define __SMARTCONFIG_H__
88

9-
typedef void (*sc_callback_t)(void *data);
10-
119
typedef enum {
1210
SC_STATUS_WAIT = 0,
1311
SC_STATUS_FIND_CHANNEL,
1412
SC_STATUS_GETTING_SSID_PSWD,
15-
SC_STATUS_GOT_SSID_PSWD,
1613
SC_STATUS_LINK,
1714
SC_STATUS_LINK_OVER,
1815
} sc_status;
@@ -22,9 +19,11 @@ typedef enum {
2219
SC_TYPE_AIRKISS,
2320
} sc_type;
2421

25-
sc_status smartconfig_get_status(void);
22+
typedef void (*sc_callback_t)(sc_status status, void *pdata);
23+
2624
const char *smartconfig_get_version(void);
2725
bool smartconfig_start(sc_type type, sc_callback_t cb, ...);
2826
bool smartconfig_stop(void);
27+
bool esptouch_set_timeout(uint8 time_s);//15s~255s, offset:45s
2928

3029
#endif

lib/libfreertos.a

0 Bytes
Binary file not shown.

lib/libjson.a

0 Bytes
Binary file not shown.

lib/liblwip.a

0 Bytes
Binary file not shown.

lib/libmain.a

1.81 KB
Binary file not shown.

lib/libnet80211.a

1.14 KB
Binary file not shown.

lib/libpp.a

52 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)