Bare minimum code for SIM900A GPRS serial AT command

Hi all..
Not quite sure if this is suitable topic in this section. I'm quite new with AT command in arduino. Based on my research the following is my own functions to initialize GSM SIM900A module using NodeMCU. The idea is to use GPRS connection and submit my GET url every now and then.

void initSim900a() {
  Serial.println("Sim900A begin initialization...");
  delay(1000);
  serialSIM900.println("AT");
  delay(1000);
  ShowSerialData("AT");
  serialSIM900.println("AT+CPIN?");
  delay(1000);
  ShowSerialData("CPIN");
  serialSIM900.println("AT+COPS=4,2,\"50219\"");
  delay(2000);
  ShowSerialData("COPS");
  serialSIM900.println("AT+CREG?");
  delay(1000);
  ShowSerialData("CREG");
  serialSIM900.println("AT+CGATT?");
  delay(1000);
  ShowSerialData("CGATT");
  serialSIM900.println("AT+CIPSHUT");
  delay(1000);
  ShowSerialData("CIPSHUT");
  serialSIM900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(1000);
  ShowSerialData("SAPBR31-GPRS");
  serialSIM900.println("AT+CIFSR");
  delay(1000);
  ShowSerialData("CIFSR-IP");
  serialSIM900.println("AT+CIPSTATUS");
  delay(2000);
  ShowSerialData("CIPSTATUS");
  serialSIM900.println("AT+SAPBR=3,1,\"APN\",\"unifi\"");
  delay(4000);
  ShowSerialData("SAPBR31-UNIFI");
  serialSIM900.println("AT+SAPBR=1,1");
  delay(5000);
  ShowSerialData("SAPBR11");
  serialSIM900.println("AT+HTTPINIT");
  delay(3000);
  ShowSerialData("HTTPINIT");
  delay(20);
  Serial.println("SIM900A Initilizaton completed");
}

void ShowSerialData(String a)
{
  String data="";
  Serial.write("SIM900A RESPOND:");
  while(serialSIM900.available()!=0){
    data += serialSIM900.readString();
  }
   Serial.println(a+":"+data);
}

void sim900aSendHttp() {
  ATcomm = "AT+HTTPPARA=\"URL\",\"" ;
  ATcomm += "http://uumresearch.com/bustracking/update_location.php?busid=";
  ATcomm += String(busid);
  ATcomm += "&latitude=" + String(gps.location.lat(), 8);
  ATcomm += "&longitude=" + String(gps.location.lng(), 8);
  ATcomm += "\"" ;
  delay(1000);
  Serial.println("SENDING AT+HTTPPARA");
  serialSIM900.println(ATcomm);
  delay(4000);
  ShowSerialData("ATcomm");
  serialSIM900.println("AT+HTTPACTION=0");
  delay(10000);
  ShowSerialData("HTTPACTION");
  delay(2000);
}

The above code seems to work just fairly ok but from time to time the serial return bogus data or failed. I need to make reliable. Which AT command when it is failed I need to reset and reinitialized the SIM900A again. What is the bare minimum code to initialize sim900a and send HTTPINIT data. I know there is TinyGSM library but seems it didn't do HTTPINIT. Only TCP connection which doesn't work with my network.

This is not a complete sketch, and the issues you encounter are most likely the result of some other part of it (like the BAUD-rate and or the Serial wiring setup)