nRF24 / RF24Mesh

OSI Layer 7 Mesh Networking for RF24Network & nrf24L01+ & nrf52x devices
http://nrf24.github.io/RF24Mesh
GNU General Public License v2.0
422 stars 153 forks source link

move `addrList` allocation into `setNodeID()` #221

Open 2bndy5 opened 1 year ago

2bndy5 commented 1 year ago

I'm only pursuing this proposal because it would obsolete the private member addrMemAllocated. Initially, this idea came to me (in #220) when discovering that static addresses have to be assigned after calling begin(). In order for a network administrator to give priority to statically assigned addresses, they'd have to assign the addresses before calling update(); this proposal won't change that. However, the requirement for calling begin() feels a bit cumbersome as the addrList array has nothing to do with initializing the required hardware.

I can't think of a reason to keep the allocating code in begin(), so maybe there's a historical reason about why it was written the way it is now.

The proposed code change is pretty straight forward as mentioned in the issue title.

2bndy5 commented 1 year ago

I can't think of a reason to keep the allocating code in begin()

I just thought of a reason: Allocating the array is dependent on the ID number passed to setNodeID(). I'm not sure if this proposal is feasible now.

2bndy5 commented 1 year ago

Maybe we can move the allocating code into setNodeID(). As for obsoleting the addrMemAllocated member, we might be able to check if the pointer is null instead.

TMRh20 commented 1 year ago

I think those are probably both good ideas.