How to interface XBeeS2C with ESP32

I am trying to make to receive sample from a remote XBee S2C configured as router in my Coordinator node that is connected to an ESP32. The code used was written through Arduino IDE and is quite simple:

int lengthMSB = 0;
int lengthLSB = 0;
int frameType = 0;
int address4 = 0;
int address5 = 0;
int address6 = 0;
int address7 = 0;
int address8 = 0;
int address9 = 0;
int address10 = 0;
int address11 = 0;
int add16bit12 = 0;
int add16bit13 = 0;
int options14 = 0;
int numberSample15 = 0;
int digitalCMask16 = 0;
int digitalCMask17 = 0;
int analogCMask18 = 0;
int anythingByte = 0;

void setup() {
Serial.begin(115200);
delay(1000);
}

void loop() {
if (Serial.available()>=21){
if(Serial.read()==0x7E){
for(int i=0; i<19; i++){
byte discardByte=Serial.read();
if(i == 0){
lengthMSB = discardByte;
}
if(i == 1){
lengthLSB = discardByte;
}

    if(i == 2){
      frameType = discardByte;
    }
    
    if(i == 3){
      address4 = discardByte;
    }
    if(i == 4){
      address5 = discardByte; 
    }
    if(i == 5){
      address6 = discardByte;
    }
    if(i == 6){
      address7 = discardByte;
    }
    if(i == 7){
      address8 = discardByte;
    }
    if(i == 8){
      address9 = discardByte;
    }
    if(i == 9){
      address10 = discardByte;
    }
    if(i == 10){
      address11 = discardByte;
    }
    if(i == 11){
      add16bit12 = discardByte;
    }
    if(i == 12){
      add16bit13 = discardByte;
    }
    if(i == 13){
      options14 = discardByte;
    }
    if(i == 14){
      numberSample15 = discardByte;
    }
    if(i == 15){
      digitalCMask16 = discardByte;
    }
    if(i == 16){
      digitalCMask17 = discardByte;
    }
    if(i == 17){
      analogCMask18 = discardByte;
    }
    if(i == 18){
      anythingByte = discardByte;
    }
  }
  int analogMSB = Serial.read();
  int analogLSB = Serial.read();
  int analogReading = analogLSB + (analogMSB*256);
  
 
  
  Serial.print("1 - Length MSB: ");
  Serial.println(lengthMSB, HEX);
  Serial.print("2 - Length LSB: ");
  Serial.println(lengthLSB, HEX);
  Serial.print("3 - Frame type: ");
  Serial.println(frameType, HEX);
  Serial.print("4 - 64 bit Address: ");
  Serial.println(address4, HEX);
  Serial.print("5 - 64 bit Address: ");
  Serial.println(address5, HEX);
  Serial.print("6 - 64 bit Address: ");
  Serial.println(address6, HEX);
  Serial.print("7 - 64 bit Address: ");
  Serial.println(address7, HEX);
  Serial.print("8 - 64 bit Address: ");
  Serial.println(address8, HEX);
  Serial.print("9 - 64 bit Address: ");
  Serial.println(address9, HEX);
  Serial.print("10 - 64 bit Address: ");
  Serial.println(address10, HEX);
  Serial.print("11 - 64 bit Address: ");
  Serial.println(address11, HEX);
  Serial.print("12 - 16 bit Address: ");
  Serial.println(add16bit12, HEX);
  Serial.print("13 - 16 bit Address: ");
  Serial.println(add16bit13, HEX);
  Serial.print("14 - Receive Options: ");
  Serial.println(options14, HEX);
  Serial.print("15 - Number of Samples: ");
  Serial.println(numberSample15, HEX);
  Serial.print("16 - Digital Channel Mask: ");
  Serial.println(digitalCMask16, HEX);
  Serial.print("17 - Digital Channel Mask: ");
  Serial.println(digitalCMask17, HEX);
  Serial.print("18 - Analog Channel Mask: ");
  Serial.println(analogCMask18, HEX);
  Serial.print("19 - Analog Sample MSB: ");
  Serial.println(analogMSB, HEX);
  Serial.print("20 - Analog Sample LSB: ");
  Serial.println(analogLSB, HEX);
  Serial.print("21 - Anything");
  Serial.println(anythingByte, HEX);
 
}

}
}

I’ve made some change in the code trying to find out what might be the problem. I know that the I/O Data Sample RX Indicator has the format described here: https://www.digi.com/resources/documentation/Digidocs/90001506/reference/r_frame_0x92.htm?TocPath=Operate%20in%20API%20mode|Frame%20descriptions|_____14

But, I keep receiving data in the follow format:

1 - Length MSB: 0
2 - Length LSB: 12
3 - Frame type: 92
4 - 64 bit Address: 0
5 - 64 bit Address: 7D
6 - 64 bit Address: 33
7 - 64 bit Address: A2
8 - 64 bit Address: 0
9 - 64 bit Address: 41
10 - 64 bit Address: 4
11 - 64 bit Address: AA
12 - 16 bit Address: 64
13 - 16 bit Address: AA
14 - Receive Options: FF
15 - Number of Samples: 1
16 - Digital Channel Mask: 1
17 - Digital Channel Mask: 0
18 - Analog Channel Mask: 0
19 - Analog Sample MSB: 0
20 - Analog Sample LSB: E2

The address of my router node is 00:13:A2:00:41:04:AA:64. So, we can see that appears a byte 0x7D and 0x33 which I do not know how to explain. Also, it is clear that the bytes 13 and 14 are the 16 bit address not 12 and 13 which were expected. But, the bytes 19 and 20 “probably” are the analog sample data. I am not sure about the analog sample data because I’ve measured the environment temperature and received repeatedly wrong samples once. And then, today, I’ve made it again and the samples received was fine and in the format of the frame printed above.

In the day that i’ve received wrong measures of the temperature i received repeatedly the following frame structure:

1 - Length MSB: 0
2 - Length LSB: 12
3 - Frame type: 92
4 - 64 bit Address: 0
5 - 64 bit Address: 7D
6 - 64 bit Address: 33
7 - 64 bit Address: A2
8 - 64 bit Address: 0
9 - 64 bit Address: 41
10 - 64 bit Address: 4
11 - 64 bit Address: AA
12 - 16 bit Address: 64
13 - 16 bit Address: 90
14 - Receive Options: C9
15 - Number of Samples: 1
16 - Digital Channel Mask: 1
17 - Digital Channel Mask: 0
18 - Analog Channel Mask: 0
19 - Analog Sample MSB: 1
20 - Analog Sample LSB: 0

I’ve changed the temperature in the sensor but still got analog samples as 0x1 and 0x0 repeatedly.

Please can anyone help me? Anything would be helpful.