Skip to content

Commit

Permalink
satisfy #187
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Aug 11, 2021
1 parent ae8ec89 commit 936d564
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
10 changes: 5 additions & 5 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ uint8_t RF24Network::update(void)
uint8_t val = enqueue(header);

if (multicastRelay) {
IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("%u: MAC FWD multicast frame from 0%o to level %u\n"), millis(), header->from_node, multicast_level + 1););
IF_SERIAL_DEBUG_ROUTING(printf_P(PSTR("%u: MAC FWD multicast frame from 0%o to level %u\n"), millis(), header->from_node, _multicast_level + 1););
if ((node_address >> 3) != 0) {
// for all but the first level of nodes, those not directly connected to the master, we add the total delay per level
delayMicroseconds(600 * 4);
}
delayMicroseconds((node_address % 4) * 600);
write(levelToAddress(multicast_level) << 3, USER_TX_MULTICAST);
write(levelToAddress(_multicast_level) << 3, USER_TX_MULTICAST);
}
if (val == 2) { //External data received
return EXTERNAL_DATA_TYPE;
Expand Down Expand Up @@ -638,7 +638,7 @@ bool RF24Network::multicast(RF24NetworkHeader &header, const void *message, uint
// Fill out the header
header.to_node = NETWORK_MULTICAST_ADDRESS;
header.from_node = node_address;
return write(header, message, len, levelToAddress(level > 3 ? multicast_level : level));
return write(header, message, len, levelToAddress(level > 3 ? _multicast_level : level));
}
#endif

Expand Down Expand Up @@ -1011,7 +1011,7 @@ void RF24Network::setup_address(void)
#if defined(RF24NetworkMulticast)
count++;
}
multicast_level = count;
_multicast_level = count;
#else
}
#endif
Expand Down Expand Up @@ -1101,7 +1101,7 @@ bool RF24Network::is_valid_address(uint16_t node)

void RF24Network::multicastLevel(uint8_t level)
{
multicast_level = level;
_multicast_level = level;
radio.stopListening();
radio.openReadingPipe(0, pipe_address(levelToAddress(level), 0));
radio.startListening();
Expand Down
16 changes: 10 additions & 6 deletions RF24Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,13 @@ class RF24Network
*/
uint8_t networkFlags;

protected:

#if defined(RF24NetworkMulticast)
uint8_t _multicast_level; /* The current node's network level (used for multicast TX/RX-ing) */
#endif
uint16_t node_address; /** Logical node address of this unit, 1 .. UINT_MAX */

private:

/**
Expand Down Expand Up @@ -794,10 +801,11 @@ class RF24Network
uint8_t enqueue(RF24NetworkHeader *header);

/*
* Called from begin(), this sets up the radio to act as according to a logical node address.
* Called from begin(), this sets up the radio to act accordingly per the
* logical `_node_address` parameter passed to `begin()`.
*
* Based on the value of the private member `node_address`, the resulting confiuration affects
* private members `node_mask`, `parent_node`, `parent_pipe`, and `multicast_level`.
* private members `node_mask`, `parent_node`, `parent_pipe`, and `_multicast_level`.
*/
void setup_address(void);

Expand Down Expand Up @@ -838,10 +846,6 @@ class RF24Network

RF24 &radio; /** Underlying radio driver, provides link/physical layers */

#if defined(RF24NetworkMulticast)
uint8_t multicast_level; /* The current node's network level (used for multicast TX/RX-ing) */
#endif
uint16_t node_address; /** Logical node address of this unit, 1 .. UINT_MAX */
uint8_t frame_size; /* The outgoing frame's total size including the header info. Ranges [8, MAX_PAYLOAD_SIZE] */
const static unsigned int max_frame_payload_size = MAX_FRAME_SIZE - sizeof(RF24NetworkHeader); /* always 24 bytes to compensate for the frame's header */

Expand Down

0 comments on commit 936d564

Please sign in to comment.