nRF24 / RF24Network

OSI Layer 3 Networking for nRF24L01(+) and nRF52x on Arduino and Raspberry Pi
https://nrf24.github.io/RF24Network/
GNU General Public License v2.0
355 stars 163 forks source link

Missing byte in address_translation array. #172

Closed adrmcintyre closed 3 years ago

adrmcintyre commented 3 years ago

https://github.com/nRF24/RF24Network/blob/ecb31c222bb9499a191cb2a303a82f4e2b13c02e/RF24Network.cpp#L1155

Looks like there's a missing byte 0xcc. It would be wise to initialise with an explicit array size as follows instead:

static uint8_t address_translation[8] = { 0xcc,0xc3,0x3c,0x33,0xce,0x3e,0xe3,0xec };
2bndy5 commented 3 years ago

The 0xCC byte is used for all bytes in the result buffer before continuing with translation.

It would be wise to initialise with an explicit array size

Agreed, but the compiler (at least for the Arduino IDE) outputs an error for explicitly sized arrays when declaring an array with initialized values.

2bndy5 commented 3 years ago

@adrmcintyre I see you forked ManiacBug's RF24 repo, but I have to warn you that repo is no longer maintained. we are currently maintaining the RF24 lib here at the nRF24 org

adrmcintyre commented 3 years ago

I was concerned that the subsequent % 8 returns a value from 0-7, and that 7 would index outside of this array, but actually I see is_valid_address guarantees the octal digits will not include 7, so this function is safe as written. Nevertheless this is not clear at first glance.

Thanks for the tip about the fork which I've now deleted. I'll be sure to stick to the supported version

2bndy5 commented 3 years ago

I recently did a deep dive into the RF24Network source code, and practically none of it seemed clear at first glance. I now understand that much of the confusing parts (at least to me) were accommodations for RF24Mesh.