 #define DEBUG 1
+#define PROTOCOL 2 //1 = TCP and 2 = UDP
+
+#ifdef PROTOCOL
+  static int const prot = PROTOCOL;
+#else
+  static int const prot = 1;          // default value TCP
+#endif
+
 //#include <DFRobot_sim808.h>
 #include <sim808.h>
 #include <SoftwareSerial.h>

  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)){  
    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");*/

    if(prot == TCP){
      if(!SendCIPSTART(TCP)){
        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(50);

  if (!CheckConnectionStatus()) {
