Skip to content

Commit

Permalink
example: freertos: bug fix in esp8266_wifi example
Browse files Browse the repository at this point in the history
Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
  • Loading branch information
IRISZZW committed Dec 10, 2018
1 parent c18ba91 commit 911ff5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 5 additions & 3 deletions example/freertos/esp8266_wifi/esp8266.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ int32_t esp8266_wifi_mode_set(ESP8266_DEF_PTR obj, ESP8266_WIFI_MODE mode, bool
}

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

Expand Down Expand Up @@ -167,7 +169,7 @@ int32_t esp8266_wifi_disconnect(ESP8266_DEF_PTR obj)

int32_t esp8266_address_get(ESP8266_DEF_PTR obj)
{
char rcv_buf[64];
char rcv_buf[128];
AT_PARSER_DEF_PTR p_at = obj->p_at;
at_send_cmd(p_at, AT_EXECUTE, "CIFSR");
return at_get_reply(p_at, rcv_buf, AT_NORMAL_TIMEOUT);
Expand Down
8 changes: 4 additions & 4 deletions example/freertos/esp8266_wifi/esp8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ int32_t esp8266_test(ESP8266_DEF_PTR obj);

int32_t esp8266_wifi_mode_get(ESP8266_DEF_PTR obj, bool flash);
int32_t esp8266_wifi_mode_set(ESP8266_DEF_PTR obj, ESP8266_WIFI_MODE, bool flash);
int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char * rcv_buf);
int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char *rcv_buf, char *ssid);
int32_t esp8266_wifi_connect(ESP8266_DEF_PTR obj, AT_STRING ssid, AT_STRING pwd, bool flash);
int32_t esp8266_wifi_disconnect(ESP8266_DEF_PTR obj);
int32_t esp8266_address_get(ESP8266_DEF_PTR obj);
int32_t esp8266_conn_status(ESP8266_DEF_PTR obj);

int32_t esp8266_dns_lookup(ESP8266_DEF_PTR obj, char * domain_ip, AT_STRING domain_name);
int32_t esp8266_dns_lookup(ESP8266_DEF_PTR obj, char *domain_ip, AT_STRING domain_name);
int32_t esp8266_tcp_connect(ESP8266_DEF_PTR obj, AT_STRING server_IP, uint32_t port);
int32_t esp8266_tcp_server_open(ESP8266_DEF_PTR obj, uint32_t port);
int32_t esp8266_tcp_server_close(ESP8266_DEF_PTR obj, uint32_t port);
Expand All @@ -88,10 +88,10 @@ int32_t esp8266_passthr_start(ESP8266_DEF_PTR obj);
int32_t esp8266_passthr_end(ESP8266_DEF_PTR obj);
int32_t esp8266_passthr_write(ESP8266_DEF_PTR obj, char *buf, uint32_t cnt);
uint32_t esp8266_normal_write(ESP8266_DEF_PTR obj, char *buf, uint32_t cnt);
uint32_t esp8266_connect_write(ESP8266_DEF_PTR obj, char *buf, char* connect, uint32_t cnt);
uint32_t esp8266_connect_write(ESP8266_DEF_PTR obj, char *buf, char *connect, uint32_t cnt);
int32_t esp8266_read(ESP8266_DEF_PTR obj, char *buf, uint32_t timeout);
uint32_t esp8266_nread(ESP8266_DEF_PTR obj, char *buf, uint32_t n);

int32_t esp8266_CIPCLOSE(ESP8266_DEF_PTR obj, char * conn_buf);
int32_t esp8266_CIPCLOSE(ESP8266_DEF_PTR obj, char *conn_buf);

#endif
4 changes: 2 additions & 2 deletions example/freertos/esp8266_wifi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static char http_html_body_2[] =
"<p>This Website is used to test the AT command about HttpServer of ESP8266.</p></body></html>";


static char http_server_buf[1024];
static char http_server_buf[2048];

int main(void)
{
Expand All @@ -74,7 +74,7 @@ int main(void)
EMBARC_PRINTF("============================ Connect WiFi ============================\n");

do {
esp8266_wifi_scan(esp8266, http_server_buf);
esp8266_wifi_scan(esp8266, http_server_buf, WIFI_SSID);
EMBARC_PRINTF("Searching for WIFI %s ......\n", WIFI_SSID);
board_delay_ms(100, 1);
} while (strstr(http_server_buf, WIFI_SSID)==NULL);
Expand Down

0 comments on commit 911ff5a

Please sign in to comment.