MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / at_client_para_init

Function at_client_para_init

components/net/at/src/at_client.c:942–976  ·  view source on GitHub ↗

initialize the client object parameters */

Source from the content-addressed store, hash-verified

940
941/* initialize the client object parameters */
942static int at_client_para_init(at_client_t client)
943{
944#define AT_CLIENT_LOCK_NAME "at_c"
945#define AT_CLIENT_EVENT_NAME "at_ce"
946#define AT_CLIENT_THREAD_NAME "at_clnt"
947
948 int result = RT_EOK;
949 char name[RT_NAME_MAX];
950
951 rt_base_t level = rt_hw_interrupt_disable();
952 unsigned int at_client_num = rt_slist_len(&g_at_client_list);
953 rt_hw_interrupt_enable(level);
954
955 rt_snprintf(name, RT_NAME_MAX, "%s%d", AT_CLIENT_THREAD_NAME, at_client_num);
956 client->parser = rt_thread_create(name,
957 (void (*)(void *parameter))client_parser,
958 client,
959 1024 + 512,
960 RT_THREAD_PRIORITY_MAX / 3 - 1,
961 5);
962 if (client->parser == RT_NULL)
963 {
964 result = -RT_ENOMEM;
965 goto __exit;
966 }
967
968 rt_snprintf(name, RT_NAME_MAX, "%s%d", AT_CLIENT_LOCK_NAME, at_client_num);
969 rt_mutex_init(&client->lock, name, RT_IPC_FLAG_PRIO);
970
971 rt_snprintf(name, RT_NAME_MAX, "%s%d", AT_CLIENT_EVENT_NAME, at_client_num);
972 rt_event_init(&client->event, name, RT_IPC_FLAG_FIFO);
973
974__exit:
975 return result;
976}
977
978/**
979 * AT client initialize.

Callers 1

at_client_initFunction · 0.85

Calls 7

rt_slist_lenFunction · 0.85
rt_snprintfFunction · 0.85
rt_thread_createFunction · 0.85
rt_mutex_initFunction · 0.85
rt_event_initFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected