Skip to content

Commit

Permalink
Fix for RF24Mesh
Browse files Browse the repository at this point in the history
Issue #214
  • Loading branch information
TMRh20 committed Sep 23, 2023
1 parent db9c62f commit 7698c29
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
37 changes: 26 additions & 11 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ void ESBNetwork<radio_t>::begin(uint8_t _channel, uint16_t _node_address)
radio.setChannel(_channel);

#if defined (multichannel)
baseChannel = radio.getChannel();
baseChannel = USE_CURRENT_CHANNEL == 255 ? 97 : _channel;
//Serial.print("Base Chan:");
//Serial.println(baseChannel);
networkChannel = baseChannel;
#endif
//radio.enableDynamicAck();
radio.setAutoAck(1);
Expand Down Expand Up @@ -963,17 +966,29 @@ void ESBNetwork<radio_t>::logicalToPhysicalAddress(logicalToPhysicalStruct* conv
}
#endif

if (*directTo > TX_ROUTED) {
#if defined (multichannel)
newChannel = baseChannel;
#endif
if (*directTo > TX_ROUTED) { //Serial.println("txrouted");

#if defined (multichannel)
uint16_t node_mask_check = 0xFFFF;
uint8_t count = 0;
while (*to_node & node_mask_check) {
node_mask_check <<= 3;
count++;
}
//Serial.print("to_node");
//Serial.println(*to_node, OCT);

newChannel = (networkChannel + (5 * count));
#endif


pre_conversion_send_node = *to_node;
*multicast = 1;
//if(*directTo == USER_TX_MULTICAST || *directTo == USER_TX_TO_PHYSICAL_ADDRESS){
pre_conversion_send_pipe = 0;
//}
}
else if (is_descendant(*to_node)) {
else if (is_descendant(*to_node)) { //Serial.println("desc");
pre_conversion_send_pipe = 5; // Send to its listening pipe
// If the node is a direct child,
if (is_direct_child(*to_node)) {
Expand All @@ -984,7 +999,7 @@ void ESBNetwork<radio_t>::logicalToPhysicalAddress(logicalToPhysicalStruct* conv
// talk on our child's listening pipe,
// and let the direct child relay it.
else {
pre_conversion_send_node = direct_child_route_to(*to_node);
pre_conversion_send_node = direct_child_route_to(*to_node); //Serial.println("default");
}
#if defined (multichannel)
newChannel = baseChannel + 5;
Expand Down Expand Up @@ -1026,7 +1041,7 @@ bool ESBNetwork<radio_t>::write_to_pipe(uint16_t node, uint8_t pipe, bool multic
}
#if defined (multichannel)
radio.setChannel(baseChannel);
//Serial.print("Set channel");
//Serial.print("Set channel write");
//Serial.println(baseChannel);
#endif
/*
Expand Down Expand Up @@ -1095,9 +1110,9 @@ void ESBNetwork<radio_t>::setup_address(void)
#endif
#if defined (multichannel)
radio.setChannel( (baseChannel + (_multicast_level * 5)) % 127);
baseChannel = radio.getChannel();
//Serial.print("Set channel");
//Serial.println(baseChannel + (_multicast_level *5));
baseChannel = (baseChannel + (_multicast_level * 5)) % 127;
//Serial.print("Set Initial channel");
//Serial.println(baseChannel);

#endif

Expand Down
1 change: 1 addition & 0 deletions RF24Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ class ESBNetwork

#if defined (multichannel)
uint8_t baseChannel;
uint8_t networkChannel;
#endif

/** @} */
Expand Down

0 comments on commit 7698c29

Please sign in to comment.