diff --git a/RF24.cpp b/RF24.cpp index 5efc4ea..dc3e2a5 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -616,9 +616,9 @@ void RF24::openReadingPipe(uint8_t child, uint64_t address) { // For pipes 2-5, only write the LSB if ( child < 2 ) - write_register(child_pipe[child], reinterpret_cast(&value), 5); + write_register(child_pipe[child], reinterpret_cast(&address), 5); else - write_register(child_pipe[child], reinterpret_cast(&value), 1); + write_register(child_pipe[child], reinterpret_cast(&address), 1); write_register(child_payload_size[child],payload_size); @@ -861,14 +861,16 @@ bool RF24::setDataRate(rf24_datarate_e speed) write_register(RF_SETUP,setup); // Verify our result - setup = read_register(RF_SETUP) ; - if( setup == setup ) + if ( read_register(RF_SETUP) == setup ) { - return true ; + result = true; + } + else + { + wide_band = false; } - wide_band = false ; - return false ; + return result; } /******************************************************************/ diff --git a/RF24.h b/RF24.h index 7f69bb4..bfd5b13 100644 --- a/RF24.h +++ b/RF24.h @@ -569,9 +569,21 @@ public: /** * Set the transmission data rate * + * @warning setting RF24_250KBPS will fail for non-P units + * * @param speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps + * @return true if the change was successful */ - void setDataRate(rf24_datarate_e speed); + bool setDataRate(rf24_datarate_e speed); + + /** + * Fetches the transmission data rate + * + * @return Returns the hardware's currently configured datarate. The value + * is one of 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS, as defined in the + * rf24_datarate_e enum. + */ + rf24_datarate_e getDataRate( void ) ; /** * Set the CRC length