From 39eaf27f1039aecbe894d48c2c7302a9c54a39d1 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Mon, 14 Dec 2015 21:13:59 -0600 Subject: [PATCH] Fix setAddress, set default addy on renew fail - Change char to uint8_t per https://github.com/TMRh20/RF24Mesh/issues/50 - Revert address to default if address confirmation fails --- RF24Mesh.cpp | 11 ++++++++--- RF24Mesh.h | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/RF24Mesh.cpp b/RF24Mesh.cpp index 513f84a..d16957e 100644 --- a/RF24Mesh.cpp +++ b/RF24Mesh.cpp @@ -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; @@ -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; diff --git a/RF24Mesh.h b/RF24Mesh.h index 5a41f9f..6092c2c 100644 --- a/RF24Mesh.h +++ b/RF24Mesh.h @@ -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(); @@ -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;