End while(1)

Some how it doesn end and I tried to and break; after "TEXT DONE" but it doesn't go to the loop part

void setup()
{
  Serial.begin(9600);
  Serial.println("MG2639 example"); 
  pinMode(cellReset, OUTPUT);
  digitalWrite(cellReset, LOW); //Don't reset
  pinMode(cellOnOff, OUTPUT);
  digitalWrite(cellOnOff, LOW); //Don't turn on at this time
  pinMode(trigger, OUTPUT);
  digitalWrite(trigger, LOW);
  delay(5000);
  if(!gpsMG2639()) //Se baud rates and bring module online
  {      
    Serial.println("Module failed to respond. Hanging.");
    setup();
  }
  Serial.println("Module online!");
  
  //MG2639.print("AT+CREG=2\r");
  //delay(100);

  boolean textSent = false;
  
  while(1)
  {
    int rssi = checkSignalStrength();
    Serial.print("RSSI: ");
    Serial.println(rssi, DEC);
    checkRegistration();    
    delay(2000);    
    if(rssi < 40 && textSent == false)
    {
      textSent = true;
      sendTextMessage("09292983237",parse);
      
      digitalWrite(trigger, HIGH);
      
      Serial.println("TEXT DONE");
    }
  }
}
void loop()
{
   Serial.println("DONE");
}
boolean gpsMG2639(void)
{
  //Quick test to see if module is already on and responding to AT commands
  MG2639.begin(9600);
  for(int x = 0 ; x < 5 ; x++)
  {
    if(checkATOK()) return(true);
    delay(100);
  }
  MG2639.end(); //That failed
  
  Serial.println("Turning on module");
  digitalWrite(cellOnOff, HIGH); //Turn on module
  delay(3000);
  digitalWrite(cellOnOff, LOW); //Leave module on

  Serial.println("Module should now be on");  

  MG2639.begin(115200);

  delay(10);

  MG2639.print("AT+IPR=4800\r\n"); //Set baud rate to 9600bps

  delay(10);

  MG2639.end(); //Hang up and go to 9600bps

  MG2639.begin(4800);

  delay(10);

  //Try sending AT 5 times before giving up
  for(int x = 0 ; x < 5 ; x++)
  {
    if(checkATOK()) return(true);
    delay(100);
  }

  return(false);
while (1)

1 will always be true so the while loop will never end of its own accord. What condition(s) should cause it to end ?

I think you want

while(!textSent)

The way you have it written now, though, if a text is sent it will print DONE forever. If you change the while loop to an if statement and put it in loop(), including the serial print in the if statement, it will accomplish the same as waiting for textSent to go true in loop().

You could have

while(1) {
  if (condition) return;
}

--Michael

edit: Tho Blue Eyes idea is cleaner...
edit again: Didn't notice the while(1) is in setup. Oh well...

Any time you want to break out of a while loop, there is a handy command to use to break out. Take a break , and study some. When your break is over, you might have a clue.