[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,则直接返回
This commit is contained in:
JasonCang 2023-06-10 11:40:37 +08:00 committed by GitHub
parent 522ac86bd9
commit d0c6d6f4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2018-04-14 chenyong first version
* 2023-06-09 CX optimize at_vprintfln interface
*/
#include <at.h>
@ -91,8 +92,16 @@ rt_size_t at_vprintfln(rt_device_t device, const char *format, va_list args)
rt_size_t len;
last_cmd_len = vsnprintf(send_buf, sizeof(send_buf) - 2, format, args);
if(last_cmd_len == 0)
{
return 0;
}
if(last_cmd_len > sizeof(send_buf) - 2)
{
last_cmd_len = sizeof(send_buf) - 2;
}
rt_memcpy(send_buf + last_cmd_len, "\r\n", 2);
len = last_cmd_len + 2;