title: STM32 GSM AT command response parser
body: <p>I am sending AT command to get IMEI no.</p>
  
  <pre><code>char CGSN[] = "AT+CGSN\r\n";
  
  // in while loop 
  HAL_UART_Transmit(&amp;huart2,(uint8_t *)CGSN, sizeof(CGSN),100);
  HAL_Delay(1000);    
  HAL_UART_Receive_IT(&amp;huart2,(uint8_t *)&amp;ch,1);  
  
  // Callback 
  void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
  {
    if(huart-&gt;Instance == USART2){
      if(buf[i]!=13){
        buf[i]=ch;
        i++;
      } 
  
    }
    HAL_UART_Receive_IT(&amp;huart2,(uint8_t *)&amp;ch,1);
  
    buf[i]=0;
  }
  </code></pre>
  
  <p>the response stored in buffer is - <code>\r\n9876543212345\r\n\r\nOK\r\n</code>
  What is best way to receive response and filter out n"9876543212345" &amp; "OK" and store separately in a array to further process </p>
  
  <p>Thanks </p>