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

Function at_create_resp

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

* Create response object. * * @param buf_size the maximum response buffer size * @param line_num the number of setting response lines * = 0: the response data will auto return when received 'OK' or 'ERROR' * != 0: the response data will return when received setting lines number data * @param timeout the maximum response time * * @return != RT_NULL: response object *

Source from the content-addressed store, hash-verified

62 * = RT_NULL: no memory
63 */
64at_response_t at_create_resp(rt_size_t buf_size, rt_size_t line_num, rt_int32_t timeout)
65{
66 at_response_t resp = RT_NULL;
67
68 resp = (at_response_t)rt_calloc(1, sizeof(struct at_response));
69 if (resp == RT_NULL)
70 {
71 LOG_E("AT create response object failed! No memory for response object!");
72 return RT_NULL;
73 }
74
75 resp->buf = (char *)rt_calloc(1, buf_size);
76 if (resp->buf == RT_NULL)
77 {
78 LOG_E("AT create response object failed! No memory for response buffer!");
79 rt_free(resp);
80 return RT_NULL;
81 }
82
83 resp->buf_size = buf_size;
84 resp->line_num = line_num;
85 resp->line_counts = 0;
86 resp->timeout = timeout;
87
88 return resp;
89}
90
91/**
92 * Delete and free response object.

Callers 1

Calls 2

rt_callocFunction · 0.85
rt_freeFunction · 0.85

Tested by

no test coverage detected