Sending data continuously using TCP IP singel connection

hi guys,

I am using a SIM808 board with sending AT commands over soft serial.

Did found some code here http://dostmuhammad.com/blog/tcp-connection-over-gprs-using-sim900-and-similar-modems-using-at-commands/ but i cant get it working with my modifications.

#include <SoftwareSerial.h>
SoftwareSerial cell(2, 3); // RX, TX

int8_t answer;
int onModulePin = 7;

void setup() {
  pinMode(onModulePin, OUTPUT);
  Serial.begin(115200);
  cell.begin(9600);
  Serial.println("Starting...");
  power_on();
  delay(3000);
  // sets the PIN code
  //sendATcommand2("AT+CPIN=0000", "OK", "ERROR", 2000);
   while( sendATcommand2("AT+CREG?", "+CREG: 0,1", "+CREG: 0,5", 1000)== 0 );
  delay(3000);
  Serial.println("Connecting to the network...");

  Setup_TCPIP();

}

void loop{

sendDATA("hello world");
}

void sendDATA(String data)
{
  Serial.println(data);
  int data_len = data.length() + 1;
  char char_array[data_len];
  data.toCharArray(char_array, data_len);

  //cell.println("AT+CIPSEND");
  delay(100);

  /*content = "";
    while (cell.available() != 0)
    {
    if ( cell.available() > 0 )
    {
      //Get the character from the cellular serial port.
      incoming_char = cell.read();
      content = content + String(incoming_char);
      if (content == ">")
      {
        cell.println(data);
        delay(100);
        cell.println((char)26);

      }
      else if (content == "ERROR")
      {
        sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
        Setup_TCPIP();
      }
    }
    }
    }*/

  // sprintf(char_array,"AT+CIPSEND=%d", strlen(data));
  if (sendATcommand2("AT+CIPSEND", ">", "ERROR", 10000) == 1)
  {

    sendATcommand2(char_array +(char)26, "SEND OK", "ERROR", 10000);
    //sendATcommand2((char)26, "SEND OK", "ERROR", 1000);
  }
  else
  {
    Serial.println("Error sending");
    sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
    Setup_TCPIP();
  }
}

void Setup_TCPIP() {
  // Selects Single-connection mode
  if (sendATcommand2("AT+CIPMUX=0", "OK", "ERROR", 1000) == 1)
  {
    // Waits for status IP INITIAL
    while (sendATcommand2("AT+CIPSTATUS", "INITIAL", "", 500)  == 0 );
    delay(5000);

    // Sets the APN, user name and password
    if (sendATcommand2("AT+CSTT=\"APN\",\"\",\"\"", "OK",  "ERROR", 30000) == 1)
    {
      // Waits for status IP START
      while (sendATcommand2("AT+CIPSTATUS", "START", "", 500)  == 0 );
      delay(5000);

      // Brings Up Wireless Connection
      if (sendATcommand2("AT+CIICR", "OK", "ERROR", 30000) == 1)
      {
        // Waits for status IP GPRSACT
        while (sendATcommand2("AT+CIPSTATUS", "GPRSACT", "", 500)  == 0 );
        delay(5000);

        // Gets Local IP Address
        if (sendATcommand2("AT+CIFSR", ".", "ERROR", 10000) == 1)
        {
          // Waits for status IP STATUS
          while (sendATcommand2("AT+CIPSTATUS", "IP STATUS", "", 500)  == 0 );
          delay(5000);
          Serial.println("Openning TCP");

          // Opens a TCP socket
          if (sendATcommand2("AT+CIPSTART=\"tcp\",\"SERVER\",\"8867\"", "CONNECT OK", "CONNECT FAIL", 30000) == 1) 
          {
            while (sendATcommand2("AT+CIPSTATUS", "IP STATUS", "", 500)  == 0 );
            Serial.println("Connected");


          }
          else
          {
            Serial.println("Error openning the connection");
            sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
            //Setup_TCPIP();
            power_on();
          }
        }
        else
        {
          Serial.println("Error getting the IP address");
          sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
          //Setup_TCPIP();
          power_on();
        }
      }
      else
      {
        Serial.println("Error bring up wireless connection");
        sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
        //Setup_TCPIP();
        power_on();
      }
    }
    else
    {
      Serial.println("Error setting the APN");
      sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
      //Setup_TCPIP();
      power_on();
    }
  }
  else
  {
    Serial.println("Error setting the single connection");
    sendATcommand2("AT+CIPSHUT", "OK", "ERROR", 10000);
    //Setup_TCPIP();
    power_on();
  }

}

void power_on() {

  uint8_t answer = 0;

  // checks if the module is started
  answer = sendATcommand2("AT", "OK", "OK", 2000);
  if (answer == 0)
  {
    // power on pulse
    digitalWrite(onModulePin, LOW);
    delay(100);
    digitalWrite(onModulePin, HIGH);
    //delay(2000);

    // waits for an answer from the module
    while (answer == 0) {   // Send AT every two seconds and wait for the answer
      answer = sendATcommand2("AT", "OK", "OK", 2000);
    }
    Setup_TCPIP();
  }

}

int8_t sendATcommand2(char* ATcommand, char* expected_answer1, char* expected_answer2, unsigned int timeout) {
  //show();

  uint8_t x = 0,  answer = 0;
  char response[100];
  unsigned long previous;

  memset(response, "" , 100);   // Initialize the string

  delay(100);

  while ( cell.available() > 0) cell.read();   // Clean the input buffer
  //cell.flush();

  cell.println(ATcommand);
  Serial.println(ATcommand); // Send the AT command


  x = 0;
  previous = millis();

  // this loop waits for the answer
  do {
    // if there are data in the UART input buffer, reads it and checks for the asnwer
    if (cell.available() != 0) {
      response[x] = cell.read();
      x++;
      // check if the desired answer 1  is in the response of the module
      if (strstr(response, expected_answer1) != NULL)
      {
        answer = 1;
      }
      // check if the desired answer 2 is in the response of the module
      else if (strstr(response, expected_answer2) != NULL)
      {
        answer = 2;
      }
    }
  }

  // Waits for the asnwer with time out
  while ((answer == 0) && ((millis() - previous) < timeout));
  //Serial.println(response);

  return answer;
}

I am using some LDR to read out led indicators and send it when something changes. the propose is that it makes automatically connection when it looses it .

could some one help me out ?