fix at_client, avoid creating the same client repeatedly and prevent working exceptions and memory leaks.

This commit is contained in:
qiyongzhong0 2020-11-02 17:43:23 +08:00
parent 60e9808677
commit db0880bd26
1 changed files with 5 additions and 0 deletions

View File

@ -917,6 +917,11 @@ int at_client_init(const char *dev_name, rt_size_t recv_bufsz)
RT_ASSERT(dev_name); RT_ASSERT(dev_name);
RT_ASSERT(recv_bufsz > 0); RT_ASSERT(recv_bufsz > 0);
if (at_client_get(dev_name) != RT_NULL)
{
return result;
}
for (idx = 0; idx < AT_CLIENT_NUM_MAX && at_client_table[idx].device; idx++); for (idx = 0; idx < AT_CLIENT_NUM_MAX && at_client_table[idx].device; idx++);
if (idx >= AT_CLIENT_NUM_MAX) if (idx >= AT_CLIENT_NUM_MAX)