Skip to content

Commit

Permalink
Simplify system msg handling, add addr release
Browse files Browse the repository at this point in the history
Simplify system msg handling: Network Update() will return immediately
for all system message types, except for re-routed address requests or
responses. This allows additional layers (such as RF24Mesh) to transmit
and receive system payloads, and handle them directly from the
frame_buffer, without interfering with user payloads.
- Added NETWORK_ADDR_RELEASE type. Allows sleeping nodes to release
their assigned address before going down.
  • Loading branch information
TMRh20 committed Oct 9, 2014
1 parent d8dc1d6 commit 9bb97f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
25 changes: 4 additions & 21 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ uint8_t RF24Network::update(void)
// Is this for us?
if ( header.to_node == node_address ){

if( res == NETWORK_ADDR_LOOKUP || res == NETWORK_ACK || (res == NETWORK_REQ_ADDRESS && !node_address) || res == NETWORK_ADDR_CONFIRM ){
IF_SERIAL_DEBUG_ROUTING( printf_P(PSTR("MAC: System payload rcvd %d\n"),res); );
return res;
}
if(res == NETWORK_PING){
returnVal = NETWORK_PING;
continue;
Expand All @@ -157,6 +153,10 @@ uint8_t RF24Network::update(void)
continue;
}

if( res >127 ){
IF_SERIAL_DEBUG_ROUTING( printf_P(PSTR("MAC: System payload rcvd %d\n"),res); );
return res;
}
enqueue();

}else{
Expand Down Expand Up @@ -193,23 +193,6 @@ uint8_t RF24Network::update(void)
#endif
}


// NOT NEEDED anymore. Now all reading pipes are open to start.
#if 0
// If this was for us, from one of our children, but on our listening
// pipe, it could mean that we are not listening to them. If so, open up
// and listen to their talking pipe

if ( header.to_node == node_address && pipe_num == 0 && is_descendant(header.from_node) )
{
uint8_t pipe = pipe_to_descendant(header.from_node);
radio.openReadingPipe(pipe,pipe_address(node_address,pipe));

// Also need to open pipe 1 so the system can get the full 5-byte address of the pipe.
radio.openReadingPipe(1,pipe_address(node_address,1));
}
#endif
//}
}
return returnVal;
}
Expand Down
1 change: 1 addition & 0 deletions RF24Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define NETWORK_POLL 194
#define NETWORK_REQ_ADDRESS 195
#define NETWORK_ADDR_LOOKUP 196
#define NETWORK_ADDR_RELEASE 197

/** Defines for handling written payloads */
#define TX_NORMAL 0
Expand Down

0 comments on commit 9bb97f4

Please sign in to comment.