添加AT命令及对应处理函数
在mcu\custom\common\ps\customer_at_command.c文件中找到custom_cmd_table
数组,添加自己需要的AT命令及对应的处理函数,如下:
const custom_atcmd custom_cmd_table[ ] =
{
{"AT%CUSTOM",custom_test_func},
{"AT+test",test_func}, // example
{NULL, NULL} // this lind should not be removed, it will be treat as
};
实现AT命令处理函数
custom_rsp_type_enum test_func(custom_cmdLine * commandBuffer_p)
{
custom_rsp_type_enum ret_value = CUSTOM_RSP_ERROR;
kal_uint16 position = 0;
kal_uint8 str_data[5] = {0};
char buffer[64] = {0};
kal_uint8 cmd_flag = 0;
if(commandBuffer_p->character[0] == 0)
{
return CUSTOM_RSP_ERROR;
} // '='
position = commandBuffer_p->position + 1;
memset(str_data,0,sizeof(str_data));
str_data[0] = commandBuffer_p->character[position++];
cmd_flag = atoi(str_data);
/* handle the data */
return CUSTOM_RSP_OK;
}
custom_cmdLine
声明如下:
typedef struct
{
short position;
short length;
char character[COMMAND_LINE_SIZE + NULL_TERMINATOR_LENGTH];
} custom_cmdLine;
position
为定义的AT命令的最后一个位置的索引,如AT+test
,其position
= 6,增加1即跳过=
号,取后面的参数。