Arduino i2c slave not replying on request

I am trying to makes some request - reply protocol between two Arduino. Master Arduino request some data from slave Arduino and depend what is the request it send back required commands.
There is example codes:
Master:

#include <Wire.h>
#include <Arduino.h>
void setup() 
{
Serial.begin(9600);
Wire.begin();
//Wire.setClock(333000L); //333000
}
void loop() 
{
int address=0x55;
    Wire.beginTransmission(address); 
    Wire.write(0xA2); // must act as a position pointer
    Wire.endTransmission();
    Wire.requestFrom(address, 32); // request 32 bytes from slave device 
    delay(20);
   Wire.beginTransmission(address); 
   Wire.write(0xA8); // must act as a position pointer
   Wire.endTransmission();
   Wire.requestFrom(address, 1); // request 32 bytes from slave device 
}

Slave:

#include <Wire.h>
byte answer1[]={0xA1, 0, 0x01, 0x0E, 0x0E, 0x05, 0, 0, 0, 0, 0, 0x01, 0x20, 0x18, 0x11, 0x07, 0x01, 0, 0, 0x95, 0, 0, 0, 0, 0x80, 0x01, 0x49, 0xB9, 0x80, 0xC8, 0x60, 0x2F};
byte answer2[]={0x20, 0x08, 0x3D,0x5B,0, 0, 0xBE, 0x06,0x2C, 0x6A, 0xBB, 0x83, 0x95, 0xCA, 0x5F, 0x34};
void setup()
{
  Wire.begin(0x55);                // join i2c bus with address #55
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(115200);           // start serial for output
}
void loop()
{
  //delay(1);
  //Serial.println("***********");
}
void receiveEvent(int howMany)
{
  byte x = Wire.read();// receive byte as an integer
  //Serial.print(" Just reading: ");
  //Serial.println(x, HEX);         // print the integer
  if (x==0xA2)
  {
    Wire.beginTransmission(0x55);
    Wire.write(answer1,32);
    //Wire.write(0x02);
    //Serial.println(" sending answer1 ");
    //for(int i = 0; i < 31; i++) {Serial.print(answer1[i], HEX);}
    //Serial.println(" Finish sending first answer...");
    }
if (x==0xA8)
  {
    Wire.write(0x10);
    Serial.println(" Sending byte 0x10 to request from A8 ");
    //for(int i = 0; i < 31; i++) {Serial.print(answer1[i], HEX);}
    Serial.println(" Finish sending 0x10 ");
    }
}

When I am checking on logic analyzer I am expecting some data please have a look attached file.
However currently I am getting first byte 0 and all the rest is FF
Can you point me where I am wrong.

Try the following revised sketches:

Master Sketch:

#include <Wire.h>
byte myData[32];

void setup()
{
  Serial.begin(9600);
  Wire.begin();
}

void loop()
{
  int address = 0x55;
  Wire.beginTransmission(address);
  Wire.write(0xA2); // must act as a position pointer
  Wire.endTransmission();
  
  byte m1 = Wire.requestFrom(address, 32); // request 32 bytes from slave device
  for(int i =0; i<m1; i++)
  {
    myData[i] = Wire.read();    //received bytes are stored in myData[] array
    Serial.print(myData[i], HEX);
  }
  
  Serial.println();
  
  Wire.beginTransmission(address);
  Wire.write(0xA8); // must act as a position pointer
  Wire.endTransmission();
  Wire.requestFrom(address, 1); // request 32 bytes from slave device
  byte x = Wire.read();  //received byte is saved in variable x.
  Seria.println(x, HEX);
}

Slave Sketch:

#include <Wire.h>
byte answer1[] = {0xA1, 0, 0x01, 0x0E, 0x0E, 0x05, 0, 0, 0, 0, 0, 0x01, 0x20, 0x18, 0x11, 0x07, 0x01, 0, 0, 0x95, 0, 0, 0, 0, 0x80, 0x01, 0x49, 0xB9, 0x80, 0xC8, 0x60, 0x2F};
byte answer2[] = {0x20, 0x08, 0x3D, 0x5B, 0, 0, 0xBE, 0x06, 0x2C, 0x6A, 0xBB, 0x83, 0x95, 0xCA, 0x5F, 0x34};
volatile bool flag1 = false;
volatile bool flag2 = false;
volatile byte x;

void setup()
{
  Wire.begin(0x55);                // join i2c bus with address #55
  Wire.onReceive(receiveEvent); // register event
  Wire.onRequest(sendEvent);
  Serial.begin(115200);           // start serial for output
}
void loop()
{
  if (flag1 || flag2)
  {
    Serial.println(x, HEX);
  }
}

void receiveEvent(int howMany)
{
  x = Wire.read();
  if (x == 0xA2)
  {
    flag1 = true;
  }
  if (x == 0xA8)
  {
    flag2 = true;
  }
}

void sendEvent()
{
  if (flag1 == true)
  {
    Wire.write(answer1, sizeof(answer1));
    flag1 = false;
  }
  if (flag2 == true)
  {
    Wire.write(answer2[0]);
    flag2 = false;
  }
}

The post of this link may be worth reading and practicing.

This Arduino to Arduino I2C Tutorial may be of interest.

...R

Thanks a lot! It is actually helps! I did not know that there are function Wire.onRequest() exist. I did create this event and it works! Again Thanks a lot GolamMostafa and Robin2 for taking your time and give right direction!