Skip to content

Commit 920beb0

Browse files
authored
Merge pull request #77 from Lawlieta/master
修复 check_link 线程重复创建问题,更新 README
2 parents ce5bfc9 + 1601bdd commit 920beb0

File tree

5 files changed

+36
-16
lines changed

5 files changed

+36
-16
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 1. 简介 ##
44

5-
AT device 软件包是由 RT-Thread AT 组件针对不同 AT 设备的移植文件和示例代码组成,目前支持的 AT 设备有:ESP8266、M26、MC20、RW007、MW31、SIM800C 以及 SIM76XX 系列设备等,目前上述设备都完成对 `AT socket` 功能的移植,及设备通过 AT 命令实现标准 socket 编程接口,完成 socket 通讯的功能,具体功能介绍可参考 [《RT-Thread 编程指南》](https://www.rt-thread.org/document/site/programming-manual/at/at/)AT 命令章节 。
5+
AT device 软件包是由 RT-Thread AT 组件针对不同 AT 设备的移植文件和示例代码组成,目前支持的 AT 设备有:ESP8266、ESP32、M26、MC20、RW007、MW31、SIM800C 以及 SIM76XX 系列设备等,目前上述设备都完成对 `AT socket` 功能的移植,及设备通过 AT 命令实现标准 socket 编程接口,完成 socket 通讯的功能,具体功能介绍可参考 [《RT-Thread 编程指南》](https://www.rt-thread.org/document/site/programming-manual/at/at/)AT 命令章节 。
66

77
### 1.1. 目录结构 ###
88

@@ -44,7 +44,8 @@ AT device 软件包目前已经发布多个版本,各个版本之间选项配
4444
- **V1.4.0**:适用于 RT-Thread 版本小于 V3.1.3或等于 V4.0.0, AT 组件版本等于 V1.2.0;
4545
- **V1.5.0**:适用于 RT-Thread 版本小于 V3.1.3 或等于 V4.0.0, AT 组件版本等于 V1.2.0;
4646
- **V1.6.0**:适用于 RT-Thread 版本等于 V3.1.3 或等于 V4.0.1, AT 组件版本等于 V1.2.0;
47-
- **laster**:只适用于 RT-Thread 版本大于 V4.0.1 或者大于 3.1.3, AT 组件版本大于 V1.2.0;
47+
- **V2.0.0/V2.0.1**:适用于 RT-Thread 版本大于 V4.0.1 或者大于 3.1.3, AT 组件版本等于 V1.3.0;
48+
- **laster**:只适用于 RT-Thread 版本大于 V4.0.1 或者大于 3.1.3, AT 组件版本等于 V1.3.0;
4849

4950
> 上述 版本判断在 menuconfig 中自动完成,at_device 软件包选择版本时会根据当前系统环境给出最佳版本支持,这里版本介绍作为运行环境参考。
5051
@@ -81,6 +82,7 @@ RT-Thread online packages --->
8182
(uart3) AT client device name
8283
(512) The maximum length of receive line buffer
8384
[ ] Quectel EC20 --->
85+
[ ] Espressif ESP32 --->
8486
[*] Espressif ESP8266 --->
8587
[*] Enable initialize by thread
8688
[*] Enable sample
@@ -111,12 +113,6 @@ RT-Thread online packages --->
111113
- **AT client device name**:配置该示例设备使用的串口设备名称;
112114
- **The maximum length of receive line buffer**:配置该示例设备最大一行接收的数据长度;
113115
- **Espressif ESP32**:开启 ESP32 (WIFI 模块)设备支持;
114-
- **Enable initialize by thread**:开启使用线程进行设备初始化功能(非阻塞模式初始化);
115-
- **Enable sample**:开启示例代码,该示例代码中有对示例设备的注册;
116-
- **WIFI ssid**:配置该示例设备连接的 WIFI 用户名;
117-
- **WIFI password**:配置该示例设备连接的 WIFI 密码;
118-
- **AT client device name**:配置该示例设备使用的串口设备名称;
119-
- **The maximum length of receive line buffer**:配置该示例设备最大一行接收的数据长度;
120116
- **Realthread RW007**:开启 RW007 (WIFI 模块)设备支持;
121117
- **SIMCom SIM800C**:开启 SIM800C (2G 模块)设备支持;
122118
- **SIMCom SIM76XX**:开启 SIM76XX (4G 模块)设备支持;
@@ -161,6 +157,11 @@ RT-Thread Components --->
161157
- `laster` 版本支持多个选中多个 AT 设备接入实现 AT Socket 功能,`V1.X.X` 版本只支持单个 AT 设备接入。
162158
- AT device 软件包目前多个版本主要用于适配 AT 组件和系统的改动,推荐使用最新版本 RT-Thread 系统,并在 menuconfig 选项中选择 `latest` 版本;
163159

160+
## 4. 相关文档
161+
162+
- [AT 组件编程指南](https://www.rt-thread.org/document/site/programming-manual/at/at/)
163+
- [应用 AT 组件连接 ESP8266 模块](https://www.rt-thread.org/document/site/application-note/components/at/an0014-at-client/)
164+
164165
## 5. 联系方式
165166

166167
* 维护:RT-Thread 开发团队及社区开发者

class/ec20/at_device_ec20.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,14 @@ static int ec20_netdev_check_link_status(struct netdev *netdev)
436436
#define EC20_LINK_THREAD_PRIORITY (RT_THREAD_PRIORITY_MAX - 2)
437437

438438
rt_thread_t tid;
439+
char tname[RT_NAME_MAX] = {0};
439440

440441
RT_ASSERT(netdev);
441442

443+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
444+
442445
/* create ec20 link status polling thread */
443-
tid = rt_thread_create("ec20_link", ec20_check_link_status_entry, (void *)netdev,
446+
tid = rt_thread_create(tname, ec20_check_link_status_entry, (void *)netdev,
444447
EC20_LINK_THREAD_STACK_SIZE, EC20_LINK_THREAD_PRIORITY, EC20_LINK_THREAD_TICK);
445448
if (tid != RT_NULL)
446449
{
@@ -886,7 +889,11 @@ static void ec20_init_thread_entry(void *parameter)
886889
{
887890
/* set network interface device status and address information */
888891
ec20_netdev_set_info(device->netdev);
889-
ec20_netdev_check_link_status(device->netdev);
892+
/* check and create link staus sync thread */
893+
if (rt_thread_find(device->netdev->name) == RT_NULL)
894+
{
895+
ec20_netdev_check_link_status(device->netdev);
896+
}
890897

891898
LOG_I("%s device network initialize success.", device->name);
892899
}

class/m26/at_device_m26.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static int m26_netdev_check_link_status(struct netdev *netdev)
294294

295295
RT_ASSERT(netdev);
296296

297-
rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name);
297+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
298298

299299
tid = rt_thread_create(tname, check_link_status_entry, (void *)netdev,
300300
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)
707707
if (result == RT_EOK)
708708
{
709709
m26_netdev_set_info(device->netdev);
710-
m26_netdev_check_link_status(device->netdev);
710+
/* check and create link staus sync thread */
711+
if (rt_thread_find(device->netdev->name) == RT_NULL)
712+
{
713+
m26_netdev_check_link_status(device->netdev);
714+
}
711715

712716
LOG_I("%s device network initialize success.", device->name);
713717
}

class/sim76xx/at_device_sim76xx.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static int sim76xx_netdev_check_link_status(struct netdev *netdev)
277277

278278
RT_ASSERT(netdev);
279279

280-
rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name);
280+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
281281

282282
tid = rt_thread_create(tname, check_link_status_entry, (void *)netdev,
283283
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)
704704
{
705705
/* set network interface device status and address information */
706706
sim76xx_netdev_set_info(device->netdev);
707-
sim76xx_netdev_check_link_status(device->netdev);
707+
/* check and create link staus sync thread */
708+
if (rt_thread_find(device->netdev->name) == RT_NULL)
709+
{
710+
sim76xx_netdev_check_link_status(device->netdev);
711+
}
708712

709713
LOG_I("%s device network initialize success!", device->name);
710714
}

class/sim800c/at_device_sim800c.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static int sim800c_netdev_check_link_status(struct netdev *netdev)
298298

299299
RT_ASSERT(netdev);
300300

301-
rt_snprintf(tname, RT_NAME_MAX, "%s_link", netdev->name);
301+
rt_snprintf(tname, RT_NAME_MAX, "%s", netdev->name);
302302

303303
tid = rt_thread_create(tname, check_link_status_entry, (void *) netdev,
304304
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)
796796
{
797797
/* set network interface device status and address information */
798798
sim800c_netdev_set_info(device->netdev);
799-
sim800c_netdev_check_link_status(device->netdev);
799+
/* check and create link staus sync thread */
800+
if (rt_thread_find(device->netdev->name) == RT_NULL)
801+
{
802+
sim800c_netdev_check_link_status(device->netdev);
803+
}
800804

801805
LOG_I("%s device network initialize success!", device->name);
802806

0 commit comments

Comments
 (0)