   strcat(data2db,",");
   strcat(data2db,Speed);
 
-  //Serial.println("valor de data2db: ");
-  //Serial.println(data2db);
+  Serial.println("valor de data2db: ");
+  Serial.println(data2db);
   
   
   
   if(!SendDataCIPSEND(data2db,sizeof(data2db))){
-    if(prot == TCP){
-      if(!SendCIPSTART(TCP)){
-        delay(1);
-        //Serial.println("AT+CIPSTART => FAIL"); 
-      } else {
-        delay(1);
-        //Serial.println("AT+CIPSTART => OK");
-      }
-  
+    if(prot == TCP){                  //TCP protocol
+      if(!SendCIPSTART(TCP)){         //Trying to restart TCP protocol     
+        return START_GPRS_TCP_FAIL;        
+      } 
+
       //delay(1000);
       delay(100);
-      if(!SendDataCIPSEND(data2db,sizeof(data2db))){
-        //Serial.println("CIPSEND =>RESEND FAIL");
-        delay(50);
-      } else {
-        delay(1);
-        //Serial.println("CIPSEND => RESEND OK");
-      }
-    }    
-  } else {
-    delay(1);
-    //Serial.println("CIPSEND => OK");
-  }
+      if(!SendDataCIPSEND(data2db,sizeof(data2db))){    //Trying to resend TCP data
+        return SEND_TCP_DATA_FAIL;                      //"CIPSEND =>RESEND FAIL"        
+      } 
+
+    }else{                             //UDP protocol
+      return SEND_UDP_DATA_FAIL;      
+    }
+  } 
 
   delay(50);
 


  //check if mobile number is register in the network
  //GPRS.println("AT+CREG=?");
 
  /*******************************************************
   * configuration of GPRS data 
   *******************************************************/
 InitGPRS();

 /***********************************************************
  * GPS configuration
  ***********************************************************/
  //GPS configuration
  GPRS.println("AT+CGPSPWR=1");  //POWER ON of GPS interface
  //SerialSim808_Read();
  delay(50);
  
  GPRS.println("AT+CGPSRST=1");  //1 = HOT start of GPS or COLD start = 0
  //SerialSim808_Read();
  delay(50);
  
//  GPRS.println("AT+CGPSSTATUS?");

  

  
//  //Receiving call 
//  if(sim808.readable()){
//    sim808_read_buffer(gprsBuffer,32,DEFAULT_TIMEOUT);
//    //Serial.print("LoopBuf:");
//    //Serial.println(gprsBuffer);
//  
//    //**** Detect the current state of the telephone or SMS ****************
//    if(NULL != strstr(gprsBuffer,"RING")) {
//        sim808.answer(); 
//        createSMSMessage(smsMessage,latitude, longitude, MSL_altitude, Speed);
//        if(extractCallingNumber(gprsBuffer)){
//          sim808.sendSMS(phone,smsMessage);
//        }else{
//          //Serial.println("No CLIP to send SMS");
//        }
//        delay(2000);
//        sim808_send_cmd("AT+CTTS=2,\"hello,欢迎使用语音合系统\"\r\n");            
//  }
//
//  //check if GPRS signal still good
//  if(NULL != (s = strstr(gprsBuffer,"CDNSGIP: 0,8"))) {
//    Serial.println("No signal or DNS fault loop");
//    DNS_OK = false; 
//  }        
//  

  //Receive SMS message   
//  if(NULL != (s = strstr(gprsBuffer,"+CMTI: \"SM\""))) { //SMS: $$+CMTI: "SM",24$$
