using RFM22 library in framing mode (more than 64bytes packets)

I'm trying to send more than 64 bytes over radio using the RFM22 modules. Now my transmitter looks great but for some reason the receivers fails after several successfully receptions.

I was test the transmitter printing all the data every time that the receivers get a valid frame.

I only want to concat this frame in another to get almost 400 bytes packet.

Now my code:

RF22ReliableDatagram rf22(MyNODEID,CHIP_SS,RFM22_INT);


uint8_t  buffer[500];
uint16_t buffer_index=0;
uint16_t tiempo_ultimo_rx=millis();
void loop(){
    uint8_t buf[RF22_MAX_MESSAGE_LEN+1];
    uint8_t len = sizeof(buf);
    uint8_t from;
    uint8_t to;
    uint8_t id;

    if (buffer_index >= 400){buffer_index=0;}
    
    if(millis() - tiempo_ultimo_rx >= 200) {buffer_index=0;}
    
    if (rf22.recvfromAckTimeout(buf, &len, 1000, &from, &to, &id)){ 
       for (int i=0; i<len; i++){
         buffer[buffer_index+i] = buf[i]; 
         //Serial.write(buf[i]);
         tiempo_ultimo_rx=millis();  
         }
       
    buffer_index = buffer_index +len;
    Serial.println(buffer_index,DEC);
    }
}

This code only concat all the frames into a local buffer, and after this I will proccess it.
500 bytes like buffer is too much for a ATmega 328?
It's realy strange because it work for several receptions and then fails and stay like this.
If I debug how many bytes I get into the buffer:

Right:
127 (1º first frame)
254 (2º first frame)
342 (3º first frame)

When it fails and stay like this:
127 (1º first frame) loads the firts 127 bytes
127 (2º first frame) do not load nothing
88 (3º first frame) loads the rest

I test others ways but the problem still there..

I-D-E-A-S?? :grin:

500 bytes like buffer is too much for a ATmega 328?

You have a 500 byte buffer, buffer, and another buffer, buf, that is RF22_MAX_MESSAGE_LEN+1 bytes long. Between them, yes, that may be too much.

What value does RF22_MAX_MESSAGE_LEN have?

    if (buffer_index >= 400){buffer_index=0;}

Doyouhavesomethingagainstspaces?

This allows you to copy up to 100 bytes into a buffer that already contains data.

       for (int i=0; i<len; i++){
         buffer[buffer_index+i] = buf[i];

Here you copy len bytes. Is len less than 100?

Hi Paul!
The packet size is the buffer value (500)
And the frame RF22_MAX_MESSAGE_LEN is a 128 byte size.

The data that I'm reading do not have blank spaces, what I see about the transmitter is that it needs more time to send the 3 frames.

I will test is in a mega 128, this have a lot of RAM so I can discard if the problem comes from it.
Other idea is process the data at the incoming frame but I think that some data field is partial from the actual frame to the next, I mean is divided in to different frames.

I will try the same but in a bigger uP or using only datagram and not reliabledatagram

Best Regards!
Frank