nRF24 / RF24Mesh

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

add releaseAddress() overload for use on master nodes #219

Closed 2bndy5 closed 1 month ago

2bndy5 commented 1 year ago

This idea is born from #218 discussion in which I thought it would be easier on users' code to provide a local way of releasing an assigned address in the master node's addrList. The main benefits are

  1. keep bounds checking on addrList internally implemented
  2. ensure the proper value (0) is assigned to the reserved addresses upon release.

Proposal

Basically I want to

#ifndef MESH_NO_MASTER
inline void RF24Mesh::releaseAddress(uint16_t address)
{
    for (uint8_t i = 0; i < addrListTop; ++i) { 
         if (addrList[i].address == address) { 
             addrList[i].address = 0; 
             break; // avoid further non-op iterations
         } 
     } 
}
#endif

PS - I opened this issue as a reminder.