Xbee reject api frame from arduino

Hi All from Peru,

I am using xbee and Arduino Mega to send a series of frames to xbee coordinator. My xbee coordinator is collecting data for processing through a Java application. I use the api 2 mode for xbee and the firmware of this Router module is 23A7. I don’t understand why my frame is rejected arduino. I had success with the xbee library but i shouldn’t use it.

My code is as follows:

uint8_t buffer [0x04];

uint8_t address [0x08];

uint8_t payload[0x05];

#define START_BYTE 0x7e

#define ZB_TX_REQUEST 0x10

#define ESCAPE 0x7d

#define XON 0x11

#define XOFF 0x13

#define COMMAND_TEMPERATURA 0x04

#define COMMAND_PRESION 0x03

#define COMMAND_TOXICIDAD 0x02

#define COMMAND_HUMEDAD 0x01

#define ZB_BROADCAST_ADDRESS 0xfffe

#define ZB_BROADCAST_RADIUS_MAX_HOPS 0

#define ZB_TRAMA_LENGHT 0x11

#define DEFAULT_FRAME_ID 0

#define ZB_TX_UNICAST 0

Stream* _serial;

void setSerial(Stream &serial) {

_serial = &serial;

}

void send_xbee1(){

byte trama [0x19];

trama[0]=0x7e;

trama[1]=0x00;

trama[2]=0x7d;

trama[3]=0x33;

trama[4]=0x10;

trama[5]=0x00;

trama[6]=0x7d;

trama[7]=0x33;

trama[8]=0xc2;

trama[9]=0xa2;

trama[10]=0x00;

trama[11]=0x40;

trama[12]=0xc1;

trama[13]=0xaf;

trama[14]=0x2e;

trama[15]=0xff;

trama[16]=0xfe;

trama[17]=0x00;

trama[18]=0x00;

trama[19]=0x04;

trama[20]=0x00;

trama[21]=0x00;

trama[22]=0x03;

trama[23]=0x31;

trama[24]=0x26;

for(int j=0;j<25;j++){

_serial->write(trama[j]);

}

delay(10);

_serial->flush();

}

void setup() {

// initialize both serial ports:

Serial1.begin(9600);

setSerial(Serial1);

//init_xbee();

}

void loop() {

// read from port 1, send to port 0:

// readTemperatura();

//send_xbee(COMMAND_TEMPERATURA); // envia por xbee

send_xbee1();

delay(1000);

}

I didn’t look past the first three bytes of your frame but…

7E 00 7D …

indicates a frame 7D bytes long, which your frame definitely is not, so that alone would cause rejection on anything that parsed XBEE API frames.