【修改】M26 模块域名解析响应时间为 14 秒

Signed-off-by: chenyong <1521761801@qq.com>
This commit is contained in:
chenyong 2018-07-23 14:29:10 +08:00
parent 366d077535
commit 3409194356
2 changed files with 39 additions and 20 deletions

View File

@ -323,7 +323,9 @@ __exit:
*/
static int esp8266_domain_resolve(const char *name, char ip[16])
{
int result = RT_EOK;
#define RESOLVE_RETRY 5
int i, result = RT_EOK;
char recv_ip[16] = { 0 };
at_response_t resp = RT_NULL;
@ -339,26 +341,37 @@ static int esp8266_domain_resolve(const char *name, char ip[16])
rt_mutex_take(at_event_lock, RT_WAITING_FOREVER);
__restart:
if (at_exec_cmd(resp, "AT+CIPDOMAIN=\"%s\"", name) < 0)
for(i = 0; i < RESOLVE_RETRY; i++)
{
result = -RT_ERROR;
goto __exit;
if (at_exec_cmd(resp, "AT+CIPDOMAIN=\"%s\"", name) < 0)
{
result = -RT_ERROR;
goto __exit;
}
/* parse the third line of response data, get the IP address */
if(at_resp_parse_line_args(resp, at_resp_get_line_num_by_kw(resp, "+CIPDOMAIN:"),
"+CIPDOMAIN:%s", recv_ip) < 0)
{
rt_thread_delay(rt_tick_from_millisecond(100));
/* resolve failed, maybe receive an URC CRLF */
continue;
}
if (strlen(recv_ip) < 8)
{
rt_thread_delay(rt_tick_from_millisecond(100));
/* resolve failed, maybe receive an URC CRLF */
continue;
}
else
{
strncpy(ip, recv_ip, 15);
ip[15] = '\0';
break;
}
}
/* parse the third line of response data, get the IP address */
at_resp_parse_line_args(resp, 1, "+CIPDOMAIN:%s", recv_ip);
if (strlen(recv_ip) < 8)
{
rt_thread_delay(rt_tick_from_millisecond(100));
/* resolve failed, maybe receive an URC CRLF */
goto __restart;
}
strncpy(ip, recv_ip, 15);
ip[15] = '\0';
__exit:
rt_mutex_release(at_event_lock);
@ -623,7 +636,12 @@ int esp8266_ping(int argc, char **argv)
return -RT_ERROR;
}
at_resp_parse_line_args(resp, 1, "+%d", &req_time);
if(at_resp_parse_line_args(resp, at_resp_get_line_num_by_kw(resp, "+"),
"+%d", &req_time) < 0)
{
continue;
}
if (req_time)
{
rt_kprintf("32 bytes from %s icmp_seq=%d time=%d ms\n", argv[1], icmp_seq, req_time);

View File

@ -384,7 +384,8 @@ static int m26_domain_resolve(const char *name, char ip[16])
RT_ASSERT(name);
RT_ASSERT(ip);
resp = at_create_resp(128, 4, rt_tick_from_millisecond(5000));
/* The maximum response time is 14 seconds, affected by network status */
resp = at_create_resp(128, 4, rt_tick_from_millisecond(14 * 1000));
if (!resp)
{
LOG_E("No memory for response structure!");