User defined AT Command makes the module rest
Posted: Tue Feb 14, 2017 2:34 pm
I'm implementing a user defined AT command but it makes the module reset
In at_task.c
When I test it
Why that happens? when I wrote other user defined AT commands with integer parameters or no parameters, this problem doesn't occur
In at_task.c
Code: Select all
static uint8_t at_exeCmdTest(uint8_t para_num)
{
int32_t cnt = 0;
uint8_t *str;
uint8_t *str2;
if (para_num != 1) {
return ESP_AT_RESULT_CODE_ERROR;
}
str = (uint8_t *)malloc(32);
if (!str) {
return ESP_AT_RESULT_CODE_ERROR;
}
str2 = (uint8_t *)malloc(10);
if (!str2) {
free (str);
return ESP_AT_RESULT_CODE_ERROR;
}
if (esp_at_get_para_as_str (cnt++,&str2) != ESP_AT_PARA_PARSE_RESULT_OK) {
free(str);
free(str2);
return ESP_AT_RESULT_CODE_ERROR;
}
sprintf((char*)str, "You've entered \"%s\"\r\n", str2);
esp_at_port_write_data((uint8_t *)str, strlen( (char*)str));
free(str);
free(str2);
esp_at_response_result(ESP_AT_RESULT_CODE_OK);
return ESP_AT_RESULT_CODE_PROCESS_DONE;
}
static esp_at_cmd_struct at_custom_cmd[] = {
{"+UART", NULL, NULL, at_setupCmdUart, NULL},
{"+UART_CUR", NULL, NULL, at_setupCmdUart, NULL},
{"+UART_DEF", NULL, NULL, at_setupCmdUartDef, NULL},
{"+CIUPDATE", NULL, NULL, NULL, at_exeCmdCipupdate},
{"+CITEST", NULL, NULL, at_exeCmdTest, NULL},
};
Code: Select all
at+citest="123"<\r><\n>
You've entered "123"<\r><\n>
<\r><\n>
ready<\r><\n>