AT指令文档
调用树
at_client_init();at_client_para_init();client_parser();
struct at_client
{rt_device_t device;at_status_t status;char end_sign;char *send_buf;/* The maximum supported send cmd length */rt_size_t send_bufsz;/* The length of last cmd */rt_size_t last_cmd_len;/* the current received one line data buffer */char *recv_line_buf;/* The length of the currently received one line data */rt_size_t recv_line_len;/* The maximum supported receive data length */rt_size_t recv_bufsz;rt_sem_t rx_notice;rt_mutex_t lock;at_response_t resp;rt_sem_t resp_notice;at_resp_status_t resp_status;struct at_urc_table *urc_table;rt_size_t urc_table_size;const struct at_urc *urc;rt_thread_t parser;
};
#define at_exec_cmd(resp, ...) at_obj_exec_cmd(at_client_get_first(), resp, __VA_ARGS__)
#define at_client_wait_connect(timeout) at_client_obj_wait_connect(at_client_get_first(), timeout)
#define at_client_send(buf, size) at_client_obj_send(at_client_get_first(), buf, size)
#define at_client_recv(buf, size, timeout) at_client_obj_recv(at_client_get_first(), buf, size, timeout)
#define at_set_end_sign(ch) at_obj_set_end_sign(at_client_get_first(), ch)
#define at_set_urc_table(urc_table, table_sz) at_obj_set_urc_table(at_client_get_first(), urc_table, table_sz)
AT指令发-收处理例程
/* disable echo */if (at_obj_exec_cmd(device->client, resp, "ATE0") != RT_EOK){result = -RT_ERROR;goto __exit;}/* disable sleep mode */if (at_obj_exec_cmd(device->client, resp, "AT+QSCLK=0") != RT_EOK){result = -RT_ERROR;goto __exit;}/* Get the baudrate */if (at_obj_exec_cmd(device->client, resp, "AT+IPR?") != RT_EOK){result = -RT_ERROR;goto __exit;}
/* check signal strength */
for (i = 0; i < CSQ_RETRY; i++)
{rt_thread_mdelay(1000);if (at_obj_exec_cmd(device->client, resp, "AT+CSQ") == RT_EOK){int signal_strength = 0, err_rate = 0;if (at_resp_parse_line_args_by_kw(resp, "+CSQ:", "+CSQ: %d,%d", &signal_strength, &err_rate) > 0){if ((signal_strength != 99) && (signal_strength != 0)){LOG_D("%s device signal strength: %d, channel bit error rate: %d",device->name, signal_strength, err_rate);break;}}}
}