Sending a PDU message cuases strange CREG behavior

Hello,

I am trying to send a SMS in PDU mode from a Arduino Mega to a GM862 Telit. I can get the module to send and receive SMSs correctly but I am having a problem with CREG. Initially the module will register on the network and a CREG=? command will return

+CREG: 0,1

But after I send a PDU message CREG=? will return

+CREG: 0,4

Also the result of a AT+CSQ command will change from +CSQ: 25,7 to +CSQ: 25,0. These symptoms will persist until I power cycle the module.

I was wondering if you have any ideas about what could cause this problem and any ideas how to fix it.

Here is the code I am using to construct the PDU message and send it.

//**********************************************************************************************
/* 
 Function: sendSMS 
 
 Inputs: String pdu_header - the header for the pdu message
         String phoneNumber - the phone number where the sms should be sent
         String sms_header - the header fro the sms messge
         String text - the sms it self

 Returns: None
 
 Description: This function constructs the PDU message by adding the PDU header, the encoded 
              phone number, the sms header, and the encoded text into one long string. Then it
              transmits the send SMS command to the GSM module and waits fro a response. Then it
              transmite the PDU message and terminate the SMS with a terminates it with a Ctrl-Z
 */
//**********************************************************************************************
void sendSMS (String pdu_header, String phoneNumber, String sms_header, String text) {
  int pduLen = 0;
  int encodedMsgLen = 0;
  String msgPDU;  
  byte msgIndex= 0;
  byte startIndex = 0;
  byte index = 0;
  char msgAck = '\0';
  int ackTimeout = 0;
  // construct PDU message  
  //add pdu header

  msgPDU = pdu_header;
//  Serial.print ("PDU Header Added: ");  Serial.println(msgPDU);

  // add server number length 
  if(phoneNumber.charAt(phoneNumber.length() - 2) == 'F') { // phone number length is odd so it has a fill field. 
    msgPDU +=  itoh((phoneNumber.length() - 1) / 16);       // first digit in the number of digits in the destination address
    msgPDU +=  itoh((phoneNumber.length() - 1) % 16);       //  second digit in the number of digits in the design address
  } 
  else { // phone number length is even
    msgPDU +=  itoh((phoneNumber.length() / 16));           // first digit in the number of digits in the destination address
    msgPDU +=  itoh((phoneNumber.length() % 16));           //  second digit in the number of digits in the design addre
  }
//  Serial.print ("phone number length added "); 
//  Serial.println(msgPDU);

  // add type of address
  msgPDU += typeOfAddress;   
//  Serial.print ("type of address field added: "); Serial.println(msgPDU);  


  // added encoded server number
  msgPDU += phoneNumber;
// Serial.print ("phone number added: "); Serial.println(msgPDU); 

  // add SMS header
  msgPDU += sms_header; 
//  Serial.print ("SMSheader added: "); Serial.println(msgPDU);
  startIndex = msgIndex;                       // record current index value

  // add length of message
  msgPDU += itoh((text.length() / 16)); // 16s column
  msgPDU += itoh((text.length() % 16)); // 1s column 
//  Serial.print ("message lenth added: "); Serial.println(msgPDU);

  // add the text message
  msgPDU += encodeMessage(text);
//  Serial.print ("e hex: "); 
//  Serial.println(msgPDU);


  // send command to GSM mod
  gsmModule -> print ("AT+CMGS=");
  Serial.print ("AT+CMGS=");
  gsmModule -> print (msgPDU.length()/2 - 1);   // make the length in chars into length in octets and remove the SCA address octect ("00")
  Serial.println (msgPDU.length()/2 - 1);
  gsmModule -> print ('\r', BYTE);

  Serial.println ("waiting for ack");
  while (msgAck != '>') {
    if (gsmModule -> available()) {
      msgAck = gsmModule -> read();
//      Serial.print ("ack; "); 
//      Serial.println (msgAck);
    }
    ackTimeout++;
//    Serial.println (ackTimeout);
    if(ackTimeout == 1000) {
      Serial.println("no Ack");
      ackTimeout = -1;
      state = HW_FAILURE;
      event = HW_FAILURE_INTRO;
      break;
    }

  }

  if (ackTimeout > 0 ) {
    Serial.print("s hex: ");
    Serial.println(msgPDU);
    gsmModule -> print(msgPDU);
    
  }
//  Serial.println("");
  gsmModule -> print(0x1A, BYTE);
  //parseResponse(timedOut);
  msgPDU = "";
}

Sincerely

Malcolm Knapp