From de64cc79b3583dc6005a62719429555d2f4c506d Mon Sep 17 00:00:00 2001 From: zylx Date: Mon, 22 Apr 2019 18:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=E5=92=8C=20mac=20?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- at_socket_esp8266.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/at_socket_esp8266.c b/at_socket_esp8266.c index a7d64ba..4df9c38 100644 --- a/at_socket_esp8266.c +++ b/at_socket_esp8266.c @@ -562,7 +562,8 @@ static void exp8266_get_netdev_info(struct rt_work *work, void *work_data) const char *resp_dns = "+CIPDNS_CUR:%s"; const char *resp_dhcp = "+CWDHCP_CUR:%d"; ip_addr_t sal_ip_addr; - rt_uint8_t mac_addr[6] = {0}; + rt_uint32_t mac_addr[6] = {0}; + rt_uint32_t num = 0; rt_uint8_t dhcp_stat = 0; struct netdev *netdev = RT_NULL; @@ -616,13 +617,16 @@ static void exp8266_get_netdev_info(struct rt_work *work, void *work_data) netdev_low_level_set_gw(netdev, &sal_ip_addr); inet_aton(netmask, &sal_ip_addr); netdev_low_level_set_netmask(netdev, &sal_ip_addr); - sscanf(mac, "%x:%x:%x:%x:%x:%x", (rt_uint32_t *)&mac_addr[0], (rt_uint32_t *)&mac_addr[1], (rt_uint32_t *)&mac_addr[2], (rt_uint32_t *)&mac_addr[3], (rt_uint32_t *)&mac_addr[4], (rt_uint32_t *)&mac_addr[5]); - memcpy(netdev->hwaddr, (const void *)mac_addr, netdev->hwaddr_len); + sscanf(mac, "%x:%x:%x:%x:%x:%x", &mac_addr[0], &mac_addr[1], &mac_addr[2], &mac_addr[3], &mac_addr[4], &mac_addr[5]); + for (num = 0; num < netdev->hwaddr_len; num++) + { + netdev->hwaddr[num] = mac_addr[num]; + } /* send dns server query commond "AT+CIPDNS_CUR?" and wait response */ if (at_exec_cmd(resp, "AT+CIPDNS_CUR?") < 0) { - LOG_E("AT send \"AT+CIPDNS_CUR?\" commands error!"); + LOG_W("Get dns server failed! Please check and update your firmware to support the \"AT+CIPDNS_CUR?\" command."); goto __exit; } @@ -630,7 +634,6 @@ static void exp8266_get_netdev_info(struct rt_work *work, void *work_data) at_resp_parse_line_args(resp, 2, resp_dns, dns_server2) <= 0) { LOG_E("Prase \"AT+CIPDNS_CUR?\" commands resposne data error!"); - LOG_E("get dns server failed! Please check whether your firmware supports the \"AT+CIPDNS_CUR?\" command."); goto __exit; } @@ -950,7 +953,7 @@ static int esp8266_netdev_ping(struct netdev *netdev, const char *host, size_t d RT_ASSERT(host); RT_ASSERT(ping_resp); - resp = at_create_resp(64, 0, rt_tick_from_millisecond(5000)); + resp = at_create_resp(64, 0, timeout); if (!resp) { LOG_E("No memory for response structure!");