From d8f2d02f227d7778d1c7c775e7ec797cc4ee4b99 Mon Sep 17 00:00:00 2001 From: chenyong <1521761801@qq.com> Date: Fri, 1 Nov 2019 14:00:09 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=AE=BE=E5=A4=87=E7=BD=91=E5=8D=A1=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=20down/up=20=E6=97=B6=E5=AF=BC=E8=87=B4=20check=5Flink=20?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E9=87=8D=E5=A4=8D=E5=88=9B=E5=BB=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyong <1521761801@qq.com> --- class/ec20/at_device_ec20.c | 11 +++++++++-- class/m26/at_device_m26.c | 8 ++++++-- class/sim76xx/at_device_sim76xx.c | 8 ++++++-- class/sim800c/at_device_sim800c.c | 8 ++++++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/class/ec20/at_device_ec20.c b/class/ec20/at_device_ec20.c index e566f4e..197c16c 100644 --- a/class/ec20/at_device_ec20.c +++ b/class/ec20/at_device_ec20.c @@ -436,11 +436,14 @@ static int ec20_netdev_check_link_status(struct netdev *netdev) #define EC20_LINK_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX - 2) rt_thread_t tid; + char tname[RT_NAME_MAX] = {0}; RT_ASSERT(netdev); + rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name); + /* create ec20 link status polling thread */ - tid = rt_thread_create("ec20_link", ec20_check_link_status_entry, (void *)netdev, + tid = rt_thread_create(tname, ec20_check_link_status_entry, (void *)netdev, EC20_LINK_THREAD_STACK_SIZE, EC20_LINK_THREAD_PRIORITY, EC20_LINK_THREAD_TICK); if (tid != RT_NULL) { @@ -886,7 +889,11 @@ static void ec20_init_thread_entry(void *parameter) { /* set network interface device status and address information */ ec20_netdev_set_info(device->netdev); - ec20_netdev_check_link_status(device->netdev); + /* check and create link staus sync thread */ + if (rt_thread_find(device->netdev->name) == RT_NULL) + { + ec20_netdev_check_link_status(device->netdev); + } LOG_I("%s device network initialize success.", device->name); } diff --git a/class/m26/at_device_m26.c b/class/m26/at_device_m26.c index 6a4cf45..fb489cf 100644 --- a/class/m26/at_device_m26.c +++ b/class/m26/at_device_m26.c @@ -294,7 +294,7 @@ static int m26_netdev_check_link_status(struct netdev *netdev) RT_ASSERT(netdev); - rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name); + rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name); tid = rt_thread_create(tname, check_link_status_entry, (void *)netdev, M26_LINK_THREAD_STACK_SIZE, M26_LINK_THREAD_PRIORITY, M26_LINK_THREAD_TICK); @@ -707,7 +707,11 @@ static void m26_init_thread_entry(void *parameter) if (result == RT_EOK) { m26_netdev_set_info(device->netdev); - m26_netdev_check_link_status(device->netdev); + /* check and create link staus sync thread */ + if (rt_thread_find(device->netdev->name) == RT_NULL) + { + m26_netdev_check_link_status(device->netdev); + } LOG_I("%s device network initialize success.", device->name); } diff --git a/class/sim76xx/at_device_sim76xx.c b/class/sim76xx/at_device_sim76xx.c index 547d1ea..f5fc271 100644 --- a/class/sim76xx/at_device_sim76xx.c +++ b/class/sim76xx/at_device_sim76xx.c @@ -277,7 +277,7 @@ static int sim76xx_netdev_check_link_status(struct netdev *netdev) RT_ASSERT(netdev); - rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name); + rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name); tid = rt_thread_create(tname, check_link_status_entry, (void *)netdev, SIM76XX_LINK_THREAD_STACK_SIZE, SIM76XX_LINK_THREAD_PRIORITY, SIM76XX_LINK_THREAD_TICK); @@ -704,7 +704,11 @@ static void sim76xx_init_thread_entry(void *parameter) { /* set network interface device status and address information */ sim76xx_netdev_set_info(device->netdev); - sim76xx_netdev_check_link_status(device->netdev); + /* check and create link staus sync thread */ + if (rt_thread_find(device->netdev->name) == RT_NULL) + { + sim76xx_netdev_check_link_status(device->netdev); + } LOG_I("%s device network initialize success!", device->name); } diff --git a/class/sim800c/at_device_sim800c.c b/class/sim800c/at_device_sim800c.c index d03a11f..25d913f 100644 --- a/class/sim800c/at_device_sim800c.c +++ b/class/sim800c/at_device_sim800c.c @@ -298,7 +298,7 @@ static int sim800c_netdev_check_link_status(struct netdev *netdev) RT_ASSERT(netdev); - rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name); + rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name); tid = rt_thread_create(tname, check_link_status_entry, (void *) netdev, SIM800C_LINK_THREAD_STACK_SIZE, SIM800C_LINK_THREAD_PRIORITY, SIM800C_LINK_THREAD_TICK); @@ -796,7 +796,11 @@ static void sim800c_init_thread_entry(void *parameter) { /* set network interface device status and address information */ sim800c_netdev_set_info(device->netdev); - sim800c_netdev_check_link_status(device->netdev); + /* check and create link staus sync thread */ + if (rt_thread_find(device->netdev->name) == RT_NULL) + { + sim800c_netdev_check_link_status(device->netdev); + } LOG_I("%s device network initialize success!", device->name);