Skip to content

Commit d0c6d6f

Browse files
authored
[at] optimize at_vprintfln
为什么提交这份PR (why to submit this PR) 现在的at指令发送接口,底层会自动添加"\r\n",某些场景需要发送空指令。如ESP32的蓝牙发送数据指令,收到">"后 发数据,等待接收OK。 详细讨论可见: https://club.rt-thread.org/ask/question/185810c0aed98558.html 你的解决方案是什么 (what is your solution) 判断at指令长度,长度为0,则直接返回
1 parent 522ac86 commit d0c6d6f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

components/net/at/src/at_utils.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2018-04-14 chenyong first version
9+
* 2023-06-09 CX optimize at_vprintfln interface
910
*/
1011

1112
#include <at.h>
@@ -91,8 +92,16 @@ rt_size_t at_vprintfln(rt_device_t device, const char *format, va_list args)
9192
rt_size_t len;
9293

9394
last_cmd_len = vsnprintf(send_buf, sizeof(send_buf) - 2, format, args);
95+
96+
if(last_cmd_len == 0)
97+
{
98+
return 0;
99+
}
100+
94101
if(last_cmd_len > sizeof(send_buf) - 2)
102+
{
95103
last_cmd_len = sizeof(send_buf) - 2;
104+
}
96105
rt_memcpy(send_buf + last_cmd_len, "\r\n", 2);
97106

98107
len = last_cmd_len + 2;

0 commit comments

Comments
 (0)