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

Function client_parser

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

Source from the content-addressed store, hash-verified

838}
839
840static void client_parser(at_client_t client)
841{
842 while (1)
843 {
844 if (at_recv_readline(client) > 0)
845 {
846 if (client->urc != RT_NULL)
847 {
848 /* current receive is request, try to execute related operations */
849 if (client->urc->func != RT_NULL)
850 {
851 client->urc->func(client, client->recv_line_buf, client->recv_line_len);
852 }
853 client->urc = RT_NULL;
854 }
855 else if (client->resp != RT_NULL)
856 {
857 at_response_t resp = client->resp;
858
859 char end_ch = client->recv_line_buf[client->recv_line_len - 1];
860
861 /* current receive is response */
862 client->recv_line_buf[client->recv_line_len - 1] = '\0';
863 if (resp->buf_len + client->recv_line_len < resp->buf_size)
864 {
865 /* copy response lines, separated by '\0' */
866 rt_memcpy(resp->buf + resp->buf_len, client->recv_line_buf, client->recv_line_len);
867
868 /* update the current response information */
869 resp->buf_len += client->recv_line_len;
870 resp->line_counts++;
871 }
872 else
873 {
874 client->resp_status = AT_RESP_BUFF_FULL;
875 LOG_E("Read response buffer failed. The Response buffer size is out of buffer size(%d)!", resp->buf_size);
876 }
877 /* check response result */
878 if ((client->end_sign != 0) && (end_ch == client->end_sign) && (resp->line_num == 0))
879 {
880 /* get the end sign, return response state END_OK.*/
881 client->resp_status = AT_RESP_OK;
882 }
883 else if (rt_memcmp(client->recv_line_buf, AT_RESP_END_OK, rt_strlen(AT_RESP_END_OK)) == 0
884 && resp->line_num == 0)
885 {
886 /* get the end data by response result, return response state END_OK. */
887 client->resp_status = AT_RESP_OK;
888 }
889 else if (rt_strstr(client->recv_line_buf, AT_RESP_END_ERROR)
890 || (rt_memcmp(client->recv_line_buf, AT_RESP_END_FAIL, rt_strlen(AT_RESP_END_FAIL)) == 0))
891 {
892 client->resp_status = AT_RESP_ERROR;
893 }
894 else if (resp->line_counts == resp->line_num && resp->line_num)
895 {
896 /* get the end data by response line, return response state END_OK.*/
897 client->resp_status = AT_RESP_OK;

Callers

nothing calls this directly

Calls 7

at_recv_readlineFunction · 0.85
rt_memcpyFunction · 0.85
rt_memcmpFunction · 0.85
rt_strlenFunction · 0.85
rt_strstrFunction · 0.85
rt_event_sendFunction · 0.85
funcMethod · 0.80

Tested by

no test coverage detected