diff --git a/RF24Network.cpp b/RF24Network.cpp
index 413031b3..70bcbf4d 100644
--- a/RF24Network.cpp
+++ b/RF24Network.cpp
@@ -168,7 +168,6 @@ uint8_t RF24Network::update(void)
// Is this for us?
if ( header.to_node == node_address ){
-
if(res == NETWORK_PING){
returnVal = NETWORK_PING;
continue;
@@ -179,6 +178,7 @@ uint8_t RF24Network::update(void)
requester |= frame_buffer[9] << 8;
if(requester != node_address){
header.to_node = requester;
+ memcpy(frame_buffer,&header,sizeof(RF24NetworkHeader));
write(header.to_node,USER_TX_TO_PHYSICAL_ADDRESS);
delay(50);
write(header.to_node,USER_TX_TO_PHYSICAL_ADDRESS);
@@ -190,6 +190,7 @@ uint8_t RF24Network::update(void)
//printf("Fwd add req to 0\n");
header.from_node = node_address;
header.to_node = 0;
+ memcpy(frame_buffer,&header,sizeof(RF24NetworkHeader));
write(header.to_node,TX_NORMAL);
continue;
}
@@ -214,7 +215,7 @@ uint8_t RF24Network::update(void)
#endif
}else{
-
+
#if defined (RF24NetworkMulticast)
if( header.to_node == 0100){
if(header.id != lastMultiMessageID || (header.type>=NETWORK_FIRST_FRAGMENT && header.type<=NETWORK_LAST_FRAGMENT)){
@@ -228,6 +229,7 @@ uint8_t RF24Network::update(void)
header.to_node = header.from_node;
header.from_node = node_address;
delay((node_address%5)*5);
+ memcpy(frame_buffer,&header,sizeof(RF24NetworkHeader));
write(header.to_node,USER_TX_TO_PHYSICAL_ADDRESS);
continue;
}
diff --git a/RF24Network.h b/RF24Network.h
index a1c314c8..ce8a2d3e 100644
--- a/RF24Network.h
+++ b/RF24Network.h
@@ -99,7 +99,12 @@ struct RF24NetworkHeader
* When requesting a response from another node, for example, a network ACK is not required, and will add extra traffic to the network.
*/
unsigned char type; /**< Type of the packet. 0-127 are user-defined types, 128-255 are reserved for system */
- unsigned char reserved; /**< Reserved for future use */
+
+ /**
+ * The reserved byte is used for system purposes. During fragmentation, it carries the fragment_id, and on the last fragment
+ * it carries the header_type.
+ */
+ unsigned char reserved; /**< Reserved for system use */
static uint16_t next_id; /**< The message ID of the next message to be sent */
@@ -155,15 +160,20 @@ struct RF24NetworkHeader
{
RF24NetworkHeader header; /**< Header which is sent with each message */
size_t message_size; /**< The size in bytes of the payload length */
+
+ /**
+ * On Arduino, to simplify things, the message buffer is just a pointer, and can be pointed to any message buffer.
+ * The RPi supports receiving multiple frames at once, from different senders, and frames use a static message buffer size
+ */
#if defined (RF24_LINUX)
uint8_t message_buffer[MAX_PAYLOAD_SIZE];
- #else
+ #else
uint8_t *message_buffer; /**< Pointer to the buffer storing the actual message */
#endif
/**
* Default constructor
*
- * Simply constructs a blank frame
+ * Simply constructs a blank frame. Frames are generally used internally. See RF24NetworkHeader.
*/
//RF24NetworkFrame() {}
@@ -171,7 +181,7 @@ struct RF24NetworkHeader
/**
* Send constructor
*
- * Use this constructor to create a frame with header and payload and then send a message
+ * Frames are generally used internally. See RF24NetworkHeader.
*/
#if defined (RF24_LINUX)
RF24NetworkFrame(RF24NetworkHeader& _header, const void* _message = NULL, size_t _len = 0) :
@@ -244,8 +254,9 @@ class RF24Network
/**
* Main layer loop
*
- * This function must be called regularly to keep the layer going. This is where all
- * the action happens!
+ * This function must be called regularly to keep the layer going. This is where payloads are
+ * re-routed, received, and all the action happens.
+ * @return Returns the type of the last received payload.
*/
uint8_t update(void);
@@ -522,11 +533,18 @@ class RF24Network
RF24NetworkFrame frag_queue;
uint8_t frag_queue_message_buffer[MAX_PAYLOAD_SIZE+11]; //frame size + 1
#endif
- uint8_t frame_buffer[MAX_FRAME_SIZE]; /**< Space to put the frame that will be sent/received over the air */
+
public:
-
+ uint8_t frame_buffer[MAX_FRAME_SIZE]; /**< Space to put the frame that will be sent/received over the air */
+
#if !defined ( DISABLE_FRAGMENTATION ) && !defined (RF24_LINUX)
+ /**
+ * The frag_ptr is only used with Arduino (not RPi/Linux) and is mainly used for external data systems like RF24Ethernet. When
+ * an EXTERNAL_DATA payload type is received, and returned from network.update(), the frag_ptr will always point to the starting
+ * memory location of the received frame. This is used by external data systems (RF24Ethernet) to immediately copy the received
+ * data to a buffer, without using the user-cache.
+ */
RF24NetworkFrame* frag_ptr;
#endif
@@ -613,11 +631,11 @@ class RF24Network
* @section Features Features
*
* Whats new?
- * New functionality: (Nov 24) Fragmentation & reassembly supported on both RPi and Arduino
- * New functionality: (Nov 24) Partial support for fragmented multicast payloads. (Only working with sending from RPi to Arduino)
- * Note: structure of network frames is changed, these are only used by external applications like RF24Ethernet and RF24toTUN, and for fragmentation
- * Network Message Types Change: (Oct 8, 2014) Requires re-installation on all nodes
- * New functionality: User message types 1 through 64 will not receive a network ack
+ * @li New: (Dec 8) Merge of RPi and Arduino code. Finally moving closer to a stable release. Report issues at https://github.com/TMRh20/RF24Network/issues
+ * @li New functionality: (Dec 8) Support for fragmented multicast payloads on both RPi and Arduino
+ * @li New functionality: (Nov 24) Fragmentation & reassembly supported on both RPi and Arduino
+ * @li Note: structure of network frames is changed, these are only used by external applications like RF24Ethernet and RF24toTUN, and for fragmentation
+ * @li New functionality: User message types 1 through 64 will not receive a network ack
*
* The layer provides:
* @li New (2014): Network ACKs: Efficient acknowledgement of network-wide transmissions, via dynamic radio acks and network protocol acks.
@@ -634,16 +652,18 @@ class RF24Network
*
* The layer does not provide:
* @li Dynamic address assignment. (See RF24Mesh)
+ * @li Layer 4 protocols (TCP/IP - See RF24Ethernet and RF24toTUN)
*
* @section More How to learn more
*
* @li RF24Network Class Documentation
- * @li Performance and Data Loss: Tuning the Network
+ * @li Topology, Performance and Data Loss: Tuning the Network
* @li My Blog: RF24 Optimization Overview
- * @li My Blog: RF24 Wireless Audio
- * @li RF24: Underlying radio driver
- * @li Download Current Package
+ * @li Download Current Development Package
* @li Examples Page. Start with helloworld_rx and helloworld_tx.
+ * @li RF24Mesh: Dynamic Mesh Layer for RF24Network Dev
+ * @li RF24Ethernet: TCP/IP over RF24Network
+ * @li My Blog: RF24 Wireless Audio
* @li RF24: Original Author
* @section Topology Topology for Mesh Networks using nRF24L01(+)
*