Skip to content

Commit

Permalink
Fix setAddress, set default addy on renew fail
Browse files Browse the repository at this point in the history
- Change char to uint8_t per
#50
- Revert address to default if address confirmation fails
  • Loading branch information
TMRh20 committed Dec 15, 2015
1 parent 170bfb1 commit 39eaf27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions RF24Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,12 @@ bool RF24Mesh::requestAddress(uint8_t level){
header.type = MESH_ADDR_CONFIRM;

while( !network.write(header,0,0) ){
if(registerAddrCount++ >= 6 ){ return 0; }
if(registerAddrCount++ >= 6 ){
network.begin(MESH_DEFAULT_ADDRESS);
mesh_address = MESH_DEFAULT_ADDRESS;
return 0;
}
delay(3);
}

return 1;
Expand All @@ -416,13 +421,13 @@ void RF24Mesh::setNodeID(uint8_t nodeID){

/*****************************************************/

void RF24Mesh::setStaticAddress(char nodeID, uint16_t address){
void RF24Mesh::setStaticAddress(uint8_t nodeID, uint16_t address){
setAddress(nodeID,address);
}

/*****************************************************/

void RF24Mesh::setAddress(char nodeID, uint16_t address){
void RF24Mesh::setAddress(uint8_t nodeID, uint16_t address){

uint8_t position = addrListTop;

Expand Down
4 changes: 2 additions & 2 deletions RF24Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class RF24Mesh
* @param address The octal RF24Network address to assign
* @return If the nodeID exists in the list,
*/
void setAddress(char nodeID, uint16_t address);
void setAddress(uint8_t nodeID, uint16_t address);

void saveDHCP();
void loadDHCP();
Expand Down Expand Up @@ -260,7 +260,7 @@ class RF24Mesh
/**
* Calls setAddress()
*/
void setStaticAddress(char nodeID, uint16_t address);
void setStaticAddress(uint8_t nodeID, uint16_t address);

private:
RF24& radio;
Expand Down

0 comments on commit 39eaf27

Please sign in to comment.