Setting Xbe(AP=1) Arduino

Hello,

I have a problem,

I am a beginner and trying to make the initial settings of the Xbee arduino. I'm trying to put the name in module M2 and save the settings. I'm putting down the code that did, is not working. I appreciate if someone can help

void setup(){

Serial.begin (9600);
Serial.flush();
delay(100);
Serial.print(0x7E,BYTE);
Serial.print(0x00,BYTE);
Serial.print(0x06,BYTE);
Serial.print(0x08,BYTE);
Serial.print(0x00,BYTE);
Serial.print(0x4E,BYTE);
Serial.print(0x49,BYTE);
Serial.print(0x4D,BYTE);
Serial.print(0x32,BYTE);
Serial.print(0xE1,BYTE);
Serial.flush();
delay(20);
Serial.println(" ");
Serial.flush();
delay(100);
Serial.print(0x7E,BYTE);
Serial.print(0x00,BYTE);
Serial.print(0x04,BYTE);
Serial.print(0x08,BYTE);
Serial.print(0x00,BYTE);
Serial.print(0x57,BYTE);
Serial.print(0x52,BYTE);
Serial.print(0x4E,BYTE);

Serial.flush();
delay(20);
Serial.println(" ");

}
void loop(){

}

Serial.begin (9600);
Serial.flush();

You just opened the serial port. How much data do you suppose has arrived in the 62.5 nano-seconds since that happened? Why do you need to flush an empty input buffer?

  Serial.print(0x7E,BYTE);
  Serial.print(0x00,BYTE);
  Serial.print(0x06,BYTE);
  Serial.print(0x08,BYTE);
  Serial.print(0x00,BYTE);
  Serial.print(0x4E,BYTE);
  Serial.print(0x49,BYTE);
  Serial.print(0x4D,BYTE);
  Serial.print(0x32,BYTE);
  Serial.print(0xE1,BYTE);
  Serial.flush();

Send some data to the XBee. Discard any reply. Great idea. I wonder why more people don't do that.

Some comments about what these magic numbers mean would be useful.

Why are you not using X-CTU to configure the XBees?

I'm trying to make the settings without the help of X-CTU. I'm trying to make the arduino settings.

below for explanation of entries API

Serial.print (0x7E, BYTE); API FRAME
Serial.print (0x00, BYTE); Length
Serial.print (0x06, BYTE); Length
Serial.print (0x08, BYTE); AT mode
Serial.print (0x00, BYTE); Frame ID
Serial.print (0x4E, BYTE); N
Serial.print (0x49, BYTE); I
Serial.print (0x4D, BYTE); M
Serial.print (0x32, BYTE); 2
Serial.print (0xE1, BYTE); Checksun

I'm trying to send the command to name the module ATNIM2 as M2

I'm trying to send the command to name the module ATNIM2 as M2

Each AT command should generate a response. What response are you getting? Or, would you be getting, if you weren't flushing it?

the datasheet, if you put Serial.print (0x08, BYTE); AT commands
Serial.print (0x00, BYTE); No response
putting the frame in the x-CTU is working properly. I'm just not able to do this through the Arduino