Hi Rob,
thanks for taking a look.
A quick look (not going to use the lib fro now)
void rf24::tx(const void *data, uint8_t len, uint8_t max)
{
for (uint8_t ind=0; ind < len; ind++) {
if (ind < max) {
transfer(((uint8_t *)data)[ind]);
} else {
transfer(0);
}
}
}
can be simpler I guess . You don't want to send all those zero's or do I miss something? (RX idem)
void rf24::tx(const void *data, uint8_t len, uint8_t max)
{
if (len < max)
{
for (uint8_t ind=0; ind < len; ind++) transfer(((uint8_t *)data)[ind]);
} else {
transfer(0);
}
}
The function is intended to be used internally to write data into registers. The case where it is used to transfer zeros is for the send() function where the user provides less data than the current packet length, so the tx() function fill out the rest of the tx buffer with zeros.
For rx(), yes I can probably not bother reading in zero's - I just haven't experimented with reading fewer bytes than the register holds yet.
functionname mismatches content ? as also an RX ADDR is set,...
void rf24::setTxAddr(const void *addr)
{
writeReg(RX_ADDR_P0, (const uint8_t *)addr, RF24_ADDR_LEN);
writeReg(TX_ADDR, (const uint8_t *)addr, RF24_ADDR_LEN);
}
Good point. The RX_ADDR_P0 address is set for use with the auto-ack feature. I'll update this so it only sets the RX address if auto-ack is enabled, and I'll have the enableAck() function copy the TX address to RX_ADDR_P0.
this code is blocking, you might add a test function boolean canSend(); so the user has the choice to test is it would block?
void rf24::send(void *data, uint8_t size)
{
while (isSending(false));
Yes it blocks. The user can call isSending() to see if the tx is busy - which I think is the same as canSend()?
I've considered ways to support all three TX buffers, but I haven't worked out a way to let the user work out if a transmit was successful in this case. Using only one TX buffer means gotAck() works correctly.
if (delay < 1) {
delay = 1;
}
delay = (delay + 249) / 250;
if (delay > 15) {
delay = 15; /* Max 4000us */
}
delay = constrain(delay,1,15); // simpler ?
why not test the value of start too? > 125?
void rf24::scan(uint8_t *chans, uint8_t start, uint8_t count, uint8_t depth)
{
uint8_t end = start+count;
if (end > 125) {
end = 125;
}
Okay I can make this a bit safer :-).
So some small remarks, in general it looks well done.
Thanks for sharing!
Cheers!