Xbee AT command

HI all, i have an Arduino with XBee shield and one XBee series 2 setting in AT mode.

In my code i want to use the AT command to see and set my parameters, but i have some problem.
I copy her a part of my code:

void setParameters() {
  Serial.print("+++");
  Serial.println(ForSerialGet());
  //ForSerialSet();
    Serial.print("ATID ");
    Serial.print(ID);
    while (Serial.available() > 0) {
      Serial.print(Serial.read());
    }
    Serial.println();
Serial.println("ATCN");
    Serial.flush();
}

void getParameters() {
  Serial.print("+++");
  Serial.println(ForSerialGet());
    Serial.println("ATID");
    myId = ForSerialGet();
Serial.print("ATCN");
    Serial.println();
    Serial.flush();

String ForSerialGet(){
    while (true) {
      if (Serial.available() > 0) {
        return Serial.readString();
      }
      delay(100);
    }
  return "";
  }

So when i use this function in my code like:

void loop(){
getParameters();
setParameters();
}

In my monitor mode, i can see the AT command, but after the setParameters(), in the new loop, the device can change his parameters.

Can someone help me? thanks

Auron6:
HI all, i have an Arduino with XBee shield and one XBee series 2 setting in AT mode.

In my code i want to use the AT command to see and set my parameters, but i have some problem.
I copy her a part of my code:

void setParameters() {

Serial.print("+++");
 Serial.println(ForSerialGet());
 //ForSerialSet();
   Serial.print("ATID ");
   Serial.print(ID);
   while (Serial.available() > 0) {
     Serial.print(Serial.read());
   }
   Serial.println();
Serial.println(“ATCN”);
   Serial.flush();
}

void getParameters() {
 Serial.print("+++");
 Serial.println(ForSerialGet());
   Serial.println(“ATID”);
   myId = ForSerialGet();
Serial.print(“ATCN”);
   Serial.println();
   Serial.flush();

String ForSerialGet(){
   while (true) {
     if (Serial.available() > 0) {
       return Serial.readString();
     }
     delay(100);
   }
 return “”;
 }




So when i use this function in my code like:



void loop(){
getParameters();
setParameters();
}




In my monitor mode, i can see the AT command, but after the setParameters(), in the new loop, the device can change his parameters.

Can someone help me? thanks

I’m confused, did you ask a question? I didn’t see any specific questions or detailed descriptions of any problems.

My problem is this, when i execute the code i see something like this

+++OK
ATID
2548
ATCN


+++OK
ATID 2000
ATCN

In the next execution , i want that my ID is 2000 but it remains 2548, my xbee dont set his value.

Are you using Serial to talk to the PC? Or, are you using it to talk to the XBee? Yes is the wrong answer. So is both.