When playing with RF12, I stumbled on something I think is worth some attention.
sending and receiving a packet is sort of "half duplex" : as long as you are sending a packet, you cannot receive data. this is because there is only one buffer.
this buffer is rf12buf and it is internal to RF12. rf12data is a pointer which points to rf12buf[2]. the first two bytes contain packet header information.
The array in RF12Demo.pde, testbuf, is being copied into rf12buf when calling SendStart()
however, SendStart does not test for maximum array size. if parameter len > RF12MAXDATA then memory will be corrupted (as far as I understand it..).
I replaced the memcpy with a (ugly nuts and bolts, granted) for loop, testing against RF12MAXDATA.
void rf12sendStart (uint8t hdr, uint8t ptr, uint8t len, uint8t sync) {
rf12hdr = hdr & RF12HDRDST ? hdr :
(hdr & ~RF12HDRMASK) + (nodeid & NODEID);
rf12len = len;
for(int i = 0; (i< len)&&(i< RF12MAXDATA); i++) {
rf12datai;
}
// memcpy((void) rf12data, ptr, len);
rf12crc = crcInit;
rxstate = TXPRE1;
rf12xfer(RFXMITTERON); // bytes will be fed via interrupts if (sync)
while (rxstate != TXIDLE)
;
}
Maybe testing on RF12MAXDATA in some form is worthwhile including in the original RF12 library ?
happy hacking !
