Send array of bytes over I2C?

I had been sending an array of 6 bytes over I2C and realised that it wasnt always reliable. One of the things I was doing wrong was forgetting to declare a variable volatile. However I m still struggling to send this array. I am only getting 3 out of the 6 bytes. My master and slave code are shown below.

Slave code,

#include <Wire.h>

volatile byte* leArray[6];
volatile boolean sendStuff;
volatile byte someByte1 = 0x2A;
volatile byte someByte2 = 0x2B;
volatile byte someByte3 = 0x2C;
volatile byte someByte4 = 0x1A;
volatile byte someByte5 = 0x1B;
volatile byte someByte6 = 0x1C;

void setup()
{
  Wire.begin(100);                // join i2c bus with address #2
  Wire.onRequest(requestEvent); // register event
}

void loop()
{
  fillArray();
  sendStuff = true;
}

void fillArray()
{
  leArray[0] = (volatile byte*)someByte1;
  leArray[1] = (volatile byte*)someByte2;
  leArray[2] = (volatile byte*)someByte3;
  leArray[3] = (volatile byte*)someByte4;
  leArray[4] = (volatile byte*)someByte5;
  leArray[5] = (volatile byte*)someByte6;

}
void requestEvent()
{  
  if(sendStuff)
  {
    Wire.write((byte*)&leArray, 6);
  }
  sendStuff= false;
}

Master code,

#include <Wire.h>

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}

void loop()
{
  Wire.requestFrom(100, 6);    // request 6 bytes from slave device #2

  while(Wire.available())    // slave may send less than requested
  { 
    volatile byte c = Wire.read(); // receive a byte as character
    Serial.println(c, HEX);         // print the character
    Serial.println();
    
  }
  delay(2000);
}

The result is

2A

0

2B

0

2C

0

Why am I not getting the full 6 bytes. Note: i dont fully understand the way i m using pointers. I m not
sure if the code below is correct.

Wire.write((byte*)&leArray, 6);

You're using an array of byte pointers when you really want an array of bytes. A pointer is an address, which is 16-bits on your machine. So each element of leArray is 2-bytes. When you set leArray[0] to 0x2A it's really set to 0x002A. That's why you're getting those zero inserted.

Declare leArray as "volatile byte leArray[6];" and send it as "Wire.write(leArray, 6);".
I think that would work.

I tried this before but it doesnt compile. it just gives the error,

invalid conversion from 'volatile byte*' to 'const uint8_t*'

edit: see post below...

Apparently write can take data and data length.

#include <Wire.h>

volatile byte leArray[6];
volatile boolean sendStuff;
volatile byte someByte1 = 0x2A;
volatile byte someByte2 = 0x2B;
volatile byte someByte3 = 0x2C;
volatile byte someByte4 = 0x1A;
volatile byte someByte5 = 0x1B;
volatile byte someByte6 = 0x1C;

void setup()
{
  Wire.begin(100);                // join i2c bus with address #2
  Wire.onRequest(requestEvent); // register event
}

void loop()
{
  fillArray();
  sendStuff = true;
}

void fillArray()
{
  leArray[0] = someByte1;
  leArray[1] = someByte2;
  leArray[2] = someByte3;
  leArray[3] = someByte4;
  leArray[4] = someByte5;
  leArray[5] = someByte6;
}
void requestEvent()
{  
  if(sendStuff)
  {
    Wire.write((byte*)leArray, 6);
  }
  sendStuff= false;
}

This compiles for me with slight changes.

This worked. Great. Thanks for that. I had been spending alot of time trying to get this right.