cancel
Showing results for 
Search instead for 
Did you mean: 

Problem about Transmitting different ATcommands according to response of previous command inside HAL_UART_RxCpltCallback

G_A.
Associate II

Hello,

I am using AT command for ESP8266. First, I am sending AT\r\n in main.c and receiving with interrupt Rx. After receiving first response, I am going on to transmit second AT command inside HAL_UART_RxCpltCallback. Everything was good with this method. But when I start to check the response and sending other command according to this response inside HAL_UART_RxCpltCallback, the responses has lost some letters.

I know that the reason of this loss is the control codes inside the part of if(RECEIVE_TAMAMLANDI==1) . I add ' this if condition which is waiting all receive data has completed 'to this control code. (I dont use this if condition, I can not get even first response properly.)

But I can not find any solution for understanding all data has come and it is possible to make RECEIVE_TAMAMLANDI set. I tried to check RXNE flag ,controll the change of rx_index but ıt does not work.

(Btw the commands which I will send has not specific lenght because of this I sent them byte to byte with rx interrupt)

If you have any idea,please share with me.Thanks in advance.

/* USER CODE BEGIN 4 */

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

{

if(huart->Instance==USART2)

{

HAL_UART_Receive_IT(&huart2,&rx_data, 1);  

Receive_Data[rx_index]=rx_data;       

rx_index++;

// UART_WaitOnFlagUntilTimeout(&huart2,UART_FLAG_RXNE,RESET,0,100);

 // if(__HAL_UART_GET_FLAG(&huart2,UART_FLAG_RXNE)==0){RECEIVE_TAMAMLANDI=1}

if(RECEIVE_TAMAMLANDI==1) //wait all data has come

{

char *Resp1_serverconnect=strstr(Receive_Data,CIPSTART_Response_2);

char *Resp2_serverconnect=strstr(Receive_Data,CIPSTART_Response_1);

if( Resp1_serverconnect !=0 || Resp2_serverconnect!=0 ) //check if comman'already connected ' has come 

{

HAL_UART_Transmit(&huart2, (uint8_t*)"AT+CIPSEND=4\r\n",strlen("AT+CIPSEND=4\r\n"),100);

yedek=1;ayedek=2;

}

else  //ERROR send command providing connect to server

{

   HAL_UART_Transmit(&huart2, (uint8_t*)"AT+CIPSTART=\"TCP\",\"192.168.0.28\",1234\r\n",strlen("AT+CIPSTART=\"TCP\",\"192.168.0.28\",1234\r\n"),10);

}

}

}

}

/* USER CODE END 4 */

0 REPLIES 0