提交 02c1f0c6 编写于 作者: Lawlieta's avatar Lawlieta

[net][at] Add AT Client Error LOG for multiple clients

上级 33a5cf15
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define AT_SW_VERSION "1.0.0"
#define AT_SW_VERSION "1.0.1"
#define AT_SW_VERSION_NUM 0x10000 #define AT_SW_VERSION_NUM 0x10000
#define DBG_ENABLE #define DBG_ENABLE
......
...@@ -290,9 +290,14 @@ int at_obj_exec_cmd(at_client_t client, at_response_t resp, const char *cmd_expr ...@@ -290,9 +290,14 @@ int at_obj_exec_cmd(at_client_t client, at_response_t resp, const char *cmd_expr
rt_err_t result = RT_EOK; rt_err_t result = RT_EOK;
const char *cmd = RT_NULL; const char *cmd = RT_NULL;
RT_ASSERT(client);
RT_ASSERT(cmd_expr); RT_ASSERT(cmd_expr);
if (client == RT_NULL)
{
LOG_E("input AT Client object is NULL, please create or get AT Client object!");
return -RT_ERROR;
}
rt_mutex_take(client->lock, RT_WAITING_FOREVER); rt_mutex_take(client->lock, RT_WAITING_FOREVER);
client->resp_status = AT_RESP_OK; client->resp_status = AT_RESP_OK;
...@@ -348,8 +353,8 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout) ...@@ -348,8 +353,8 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout)
if (client == RT_NULL) if (client == RT_NULL)
{ {
LOG_E("Input AT Client is NULL, please create or get AT Client!"); LOG_E("input AT Client object is NULL, please create or get AT Client object!");
return RT_NULL; return -RT_ERROR;
} }
resp = at_create_resp(16, 0, rt_tick_from_millisecond(500)); resp = at_create_resp(16, 0, rt_tick_from_millisecond(500));
...@@ -400,13 +405,19 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout) ...@@ -400,13 +405,19 @@ int at_client_obj_wait_connect(at_client_t client, rt_uint32_t timeout)
* @param buf send data buffer * @param buf send data buffer
* @param size send fixed data size * @param size send fixed data size
* *
* @return send data size * @return >0: send data size
* =0: send failed
*/ */
rt_size_t at_client_obj_send(at_client_t client, const char *buf, rt_size_t size) rt_size_t at_client_obj_send(at_client_t client, const char *buf, rt_size_t size)
{ {
RT_ASSERT(client);
RT_ASSERT(buf); RT_ASSERT(buf);
if (client == RT_NULL)
{
LOG_E("input AT Client object is NULL, please create or get AT Client object!");
return 0;
}
#ifdef AT_PRINT_RAW_CMD #ifdef AT_PRINT_RAW_CMD
at_print_raw_cmd("send", buf, size); at_print_raw_cmd("send", buf, size);
#endif #endif
...@@ -436,16 +447,22 @@ static char at_client_getchar(at_client_t client) ...@@ -436,16 +447,22 @@ static char at_client_getchar(at_client_t client)
* *
* @note this function can only be used in execution function of URC data * @note this function can only be used in execution function of URC data
* *
* @return success receive data size * @return >0: receive data size
* =0: receive failed
*/ */
rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size) rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size)
{ {
rt_size_t read_idx = 0; rt_size_t read_idx = 0;
char ch; char ch;
RT_ASSERT(client);
RT_ASSERT(buf); RT_ASSERT(buf);
if (client == RT_NULL)
{
LOG_E("input AT Client object is NULL, please create or get AT Client object!");
return 0;
}
while (1) while (1)
{ {
if (read_idx < size) if (read_idx < size)
...@@ -475,7 +492,11 @@ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size) ...@@ -475,7 +492,11 @@ rt_size_t at_client_obj_recv(at_client_t client, char *buf, rt_size_t size)
*/ */
void at_obj_set_end_sign(at_client_t client, char ch) void at_obj_set_end_sign(at_client_t client, char ch)
{ {
RT_ASSERT(client); if (client == RT_NULL)
{
LOG_E("input AT Client object is NULL, please create or get AT Client object!");
return;
}
client->end_sign = ch; client->end_sign = ch;
} }
...@@ -491,6 +512,12 @@ void at_obj_set_urc_table(at_client_t client, const struct at_urc *urc_table, rt ...@@ -491,6 +512,12 @@ void at_obj_set_urc_table(at_client_t client, const struct at_urc *urc_table, rt
{ {
rt_size_t idx; rt_size_t idx;
if (client == RT_NULL)
{
LOG_E("input AT Client object is NULL, please create or get AT Client object!");
return;
}
for (idx = 0; idx < table_sz; idx++) for (idx = 0; idx < table_sz; idx++)
{ {
RT_ASSERT(urc_table[idx].cmd_prefix); RT_ASSERT(urc_table[idx].cmd_prefix);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册