Skip to content

Commit 911ff5a

Browse files
committed
example: freertos: bug fix in esp8266_wifi example
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
1 parent c18ba91 commit 911ff5a

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

example/freertos/esp8266_wifi/esp8266.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ int32_t esp8266_wifi_mode_set(ESP8266_DEF_PTR obj, ESP8266_WIFI_MODE mode, bool
103103
}
104104

105105
/* rcv_buf should be large enough for scan result */
106-
int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char *rcv_buf)
106+
int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char *rcv_buf, char *ssid)
107107
{
108-
at_send_cmd(obj->p_at, AT_EXECUTE, "CWLAP");
108+
char cmd_str[64]= {0};
109+
sprintf(cmd_str, "CWLAP=%s", ssid);
110+
at_send_cmd(obj->p_at, AT_EXECUTE, cmd_str);
109111
return at_get_reply(obj->p_at, rcv_buf, AT_LONG_TIMEOUT);
110112
}
111113

@@ -167,7 +169,7 @@ int32_t esp8266_wifi_disconnect(ESP8266_DEF_PTR obj)
167169

168170
int32_t esp8266_address_get(ESP8266_DEF_PTR obj)
169171
{
170-
char rcv_buf[64];
172+
char rcv_buf[128];
171173
AT_PARSER_DEF_PTR p_at = obj->p_at;
172174
at_send_cmd(p_at, AT_EXECUTE, "CIFSR");
173175
return at_get_reply(p_at, rcv_buf, AT_NORMAL_TIMEOUT);

example/freertos/esp8266_wifi/esp8266.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ int32_t esp8266_test(ESP8266_DEF_PTR obj);
7272

7373
int32_t esp8266_wifi_mode_get(ESP8266_DEF_PTR obj, bool flash);
7474
int32_t esp8266_wifi_mode_set(ESP8266_DEF_PTR obj, ESP8266_WIFI_MODE, bool flash);
75-
int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char * rcv_buf);
75+
int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char *rcv_buf, char *ssid);
7676
int32_t esp8266_wifi_connect(ESP8266_DEF_PTR obj, AT_STRING ssid, AT_STRING pwd, bool flash);
7777
int32_t esp8266_wifi_disconnect(ESP8266_DEF_PTR obj);
7878
int32_t esp8266_address_get(ESP8266_DEF_PTR obj);
7979
int32_t esp8266_conn_status(ESP8266_DEF_PTR obj);
8080

81-
int32_t esp8266_dns_lookup(ESP8266_DEF_PTR obj, char * domain_ip, AT_STRING domain_name);
81+
int32_t esp8266_dns_lookup(ESP8266_DEF_PTR obj, char *domain_ip, AT_STRING domain_name);
8282
int32_t esp8266_tcp_connect(ESP8266_DEF_PTR obj, AT_STRING server_IP, uint32_t port);
8383
int32_t esp8266_tcp_server_open(ESP8266_DEF_PTR obj, uint32_t port);
8484
int32_t esp8266_tcp_server_close(ESP8266_DEF_PTR obj, uint32_t port);
@@ -88,10 +88,10 @@ int32_t esp8266_passthr_start(ESP8266_DEF_PTR obj);
8888
int32_t esp8266_passthr_end(ESP8266_DEF_PTR obj);
8989
int32_t esp8266_passthr_write(ESP8266_DEF_PTR obj, char *buf, uint32_t cnt);
9090
uint32_t esp8266_normal_write(ESP8266_DEF_PTR obj, char *buf, uint32_t cnt);
91-
uint32_t esp8266_connect_write(ESP8266_DEF_PTR obj, char *buf, char* connect, uint32_t cnt);
91+
uint32_t esp8266_connect_write(ESP8266_DEF_PTR obj, char *buf, char *connect, uint32_t cnt);
9292
int32_t esp8266_read(ESP8266_DEF_PTR obj, char *buf, uint32_t timeout);
9393
uint32_t esp8266_nread(ESP8266_DEF_PTR obj, char *buf, uint32_t n);
9494

95-
int32_t esp8266_CIPCLOSE(ESP8266_DEF_PTR obj, char * conn_buf);
95+
int32_t esp8266_CIPCLOSE(ESP8266_DEF_PTR obj, char *conn_buf);
9696

9797
#endif

example/freertos/esp8266_wifi/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static char http_html_body_2[] =
4848
"<p>This Website is used to test the AT command about HttpServer of ESP8266.</p></body></html>";
4949

5050

51-
static char http_server_buf[1024];
51+
static char http_server_buf[2048];
5252

5353
int main(void)
5454
{
@@ -74,7 +74,7 @@ int main(void)
7474
EMBARC_PRINTF("============================ Connect WiFi ============================\n");
7575

7676
do {
77-
esp8266_wifi_scan(esp8266, http_server_buf);
77+
esp8266_wifi_scan(esp8266, http_server_buf, WIFI_SSID);
7878
EMBARC_PRINTF("Searching for WIFI %s ......\n", WIFI_SSID);
7979
board_delay_ms(100, 1);
8080
} while (strstr(http_server_buf, WIFI_SSID)==NULL);

0 commit comments

Comments
 (0)