From 027bd8e8803aa6e484b78286001ecc2c0df0c10a Mon Sep 17 00:00:00 2001 From: qiyongzhong0 <917768104@qq.com> Date: Thu, 23 Apr 2020 18:03:02 +0800 Subject: [PATCH] fix bug of me3616 --- class/me3616/at_device_me3616.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/class/me3616/at_device_me3616.c b/class/me3616/at_device_me3616.c index c9643b7..d74c74e 100644 --- a/class/me3616/at_device_me3616.c +++ b/class/me3616/at_device_me3616.c @@ -336,7 +336,7 @@ static int me3616_netdev_set_info(struct netdev *netdev) } /* parse response data "+CGPADDR: 1," */ - if (at_resp_parse_line_args_by_kw(resp, "+CGPADDR:", "+CGPADDR: %*d,\"%s\"", ipaddr) <= 0) + if (at_resp_parse_line_args_by_kw(resp, "+CGPADDR:", "+CGPADDR: %*[^\"]\"%[^\"]", ipaddr) <= 0) { LOG_E("%s device \"AT+CGPADDR=1\" cmd error.", device->name); result = -RT_ERROR; @@ -553,6 +553,12 @@ static struct netdev *me3616_netdev_add(const char *netdev_name) #define HWADDR_LEN 8 struct netdev *netdev = RT_NULL; + netdev = netdev_get_by_name(netdev_name); + if(netdev != RT_NULL) + { + return(netdev); + } + netdev = (struct netdev *)rt_calloc(1, sizeof(struct netdev)); if (netdev == RT_NULL) { @@ -656,7 +662,7 @@ static void me3616_init_thread_entry(void *parameter) result = -RT_ERROR; goto __exit; } - at_resp_parse_line_args_by_kw(resp, "+IPR:", "+IPR: %d", &i); + at_resp_parse_line_args_by_kw(resp, "+IPR:", "+IPR: %d\r", &i); LOG_D("%s device baudrate %d", device->name, i); /* get module version */ @@ -748,7 +754,7 @@ static void me3616_init_thread_entry(void *parameter) char ipaddr[IP_ADDR_SIZE_MAX] = {0}; /* parse response data "+CGPADDR: 1," */ - if (at_resp_parse_line_args_by_kw(resp, "+CGPADDR:", "+CGPADDR: %*d,%s", ipaddr) > 0) + if (at_resp_parse_line_args_by_kw(resp, "+CGPADDR:", "+CGPADDR: %*[^\"]\"%[^\"]", ipaddr) > 0) { LOG_D("%s device IP address: %s", device->name, ipaddr); break;