   delay(1000);
   
   //start a connection to TCP to URL and port 
-  if(!sim808_check_with_cmd("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789\r\n","OK\r\n",CMD)){  
+  /*if(!sim808_check_with_cmd("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789\r\n","OK\r\n",CMD)){  
     Serial.println("AT+CIPSTART => FAIL");    
   }else Serial.println("AT+CIPSTART => OK");
+  delay(1000);*/
+
+  if (prot == TCP){
+    if(!SendCIPSTART(TCP)){
+      Serial.println("AT+CIPSTART => FAIL"); 
+    } else Serial.println("AT+CIPSTART => OK");
+  }else {
+    if(!SendCIPSTART(UDP)){
+      Serial.println("AT+CIPSTART => FAIL"); 
+    } else Serial.println("AT+CIPSTART => OK");    
+  }
+  
   delay(1000);
-  //delay(50);
 
   //copy latitude and longitude to send via TCP server
   memset(data2db,'\0',sizeof(data2db));

  if(!SendDataCIPSEND(data2db,sizeof(data2db))){
    Serial.println("CIPSEND => FAIL");
    //Try to resend    
    if(!sim808_check_with_cmd("AT+CIPSTART=\"TCP\",\"ardugps.hopto.org\",6789\r\n","OK\r\n",CMD)){  
      Serial.println("AT+CIPSTART => FAIL");    
    }else Serial.println("AT+CIPSTART => OK");

    delay(1000);
    if(!SendDataCIPSEND(data2db,sizeof(data2db))){
    Serial.println("CIPSEND =>RESEND FAIL");
    delay(50);
    } else Serial.println("CIPSEND => RESEND OK");
  } else Serial.println("CIPSEND => OK");
  //delay(5000);
  delay(50);

  if (!CheckConnectionStatus()) {

SoftwareSerial GPRS(rxPin, txPin); // RX, TX
//DFRobot_SIM808 sim808(&GPRS);
SimpleTimer timer;

enum Protocol {
    CLOSED = 0,
    TCP    = 1,
    UDP    = 2,
};


char* key;
