nRF24L01+ excellent example code won't compile ???

Bajdi.com has provided an excellent & simple code example of using nRF24L01+ at this link: http://www.bajdi.com/rf24-library-revisited/.
This code has been expanded at another link by Nathan where even more well documented code is provided as follows: http://sobisource.com/nrf24l01-2-way-communication/

Both code sources have a similar compile error as follows:
error: void value not ignored as it ought to be

I don’t know if this a result of me using the later December revision of the RF24 library or what???

This is the receiver sketch from bajdi.com by way of example:
1 /*
2
3 http://www.bajdi.com
4
5 This sketch receives 2 analog values through an nRF24L01 wireless module.
6 */
7
8 #include <SPI.h>
9 #include “nRF24L01.h”
10 #include “RF24.h”
11
12 int joystick[2];
13
14 RF24 radio(48,49);
15 const uint64_t pipe = 0xE8E8F0F0E1LL;
16
17 void setup(void)
18 {
19 Serial.begin(9600);
20 radio.begin();
21 radio.openReadingPipe(1,pipe);
22 radio.startListening();
23 }
24
25 void loop(void)
26 {
27 if ( radio.available() )
28 {
29 // Dump the payloads until we’ve gotten everything
30 bool done = false;
31 while (!done)
32 {
33 // Fetch the payload, and see if this was the last one.
34 done = radio.read( joystick, sizeof(joystick) ); // THIS IS THE COMPILE ERROR
35 Serial.println(joystick[0]);
36 Serial.println(joystick[1]);
37 }
38 }
39 else
40 {
41 Serial.println(“No radio available”);
42 }
43 }

The error is that the code does not like the line 34 as follows:
done = radio.read( joystick, sizeof(joystick) );

In this line the radio.read should be reading the payload & return True if the payload was delivered successfully False if not into the bool value identified as “done”

Can anyone see what the problem is ???

This same error occurs in the tutorial examples from:
http://shanes.net/another-nrf24l01-sketch-string-sendreceive/

I’m sure I’m not the only person finding these compile errors

The radio.available() function will now always return true of data is available. The radio.read() function no longer returns a boolean value, so the code compilation fails.

27 while ( radio.available() ) 28 { 29 // Dump the payloads until we've gotten everything 33 // Fetch the payload, and see if this was the last one. 34 radio.read( joystick, sizeof(joystick) ); // THIS IS THE COMPILE ERROR 35 Serial.println(joystick[0]); 36 Serial.println(joystick[1]); 38 } 39 else 40 { 41 Serial.println("No radio available"); 42 } 43 } payload, and see if this was the last one.

Thank you TRMh20 I just found your blog which explains the logic of the later fork of RF24 that you authored in about December 2014.

For the benefit of others following this post, the usual expression like: done = radio.read( &rx_data, sizeof(rx_data) ); is no longer used as explained from your updated documentation at link http://tmrh20.github.io/RF24/classRF24.html#a8e2eacacfba96426c192066f04054c5b where you get rid of the if/while & boolean code, see extract of link explaining below:

void RF24::read ( void * buf, uint8_t len)
Read the available payload. The size of data read is the fixed payload size, see getPayloadSize()
Note I specifically chose ‘void*’ as a data type to make it easier for beginners to use. No casting needed.
No longer boolean. Use available to determine if packets are available. Interrupt flags are now cleared during reads instead of when calling available().
Parameters
buf Pointer to a buffer where the data should be written
len Maximum number of bytes to read into the buffer
example:
if(radio.available()){
radio.read(&data,sizeof(data));
}
Returns - No return value. Use available().

The old format expression “done = radio.read( &rx_data, sizeof(rx_data) );” was used a lot with earlier tutorial examples on the web, modify them along the lines described above & kill the boolean and the while/if.

I’d recommend readers follow these 2 links to TMRh20:
http://tmrh20.blogspot.com.au/ and specifically page down to the heading “Arduino: Using the full potential of NRF24L01 radio modules” Updated Jan 2015
http://tmrh20.github.io/RF24/ which is the documentation for the new fork of December 2014
Testing New RF24 Arduino Library Fork: Comparative Data Transfers - YouTube YouTube explaining

Enjoy…