Esp8266 communication with arduino

after trials and errors

byte receive_command(void) {
  char c = 0;
  char a[input_buffer] = {0};
  byte b = 0;
  unsigned long _time = 0;
  const int max_wait_time = 10000;
  _time = millis();
  byte i = 0;
  while (!Serial.available()) {
    if ((millis() - _time) > max_wait_time) return b;
  }

 while((c=Serial.read())!='\n'){
    digitalWrite(ledPin, !digitalRead(ledPin));
    a[i] = c;
    i++;
 }
  a[i+1]='\0';
  b = process_text(a, i+1);

  return b;
}