initialize the client object parameters */
| 940 | |
| 941 | /* initialize the client object parameters */ |
| 942 | static 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. |
no test coverage detected