Skip to content

Commit

Permalink
Handle zero-length messages (where the header is enough info)
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Dec 17, 2011
1 parent 9438bd1 commit 1ea7f80
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,14 @@ bool RF24Network::write(RF24NetworkHeader& header,const void* message, size_t le

// Build the full frame to send
memcpy(frame_buffer,&header,sizeof(RF24NetworkHeader));
memcpy(frame_buffer + sizeof(RF24NetworkHeader),message,min(frame_size-sizeof(RF24NetworkHeader),len));
if (len)
memcpy(frame_buffer + sizeof(RF24NetworkHeader),message,min(frame_size-sizeof(RF24NetworkHeader),len));

IF_SERIAL_DEBUG(printf_P(PSTR("%lu: NET Sending %s\n\r"),millis(),header.toString()));
IF_SERIAL_DEBUG(const uint16_t* i = reinterpret_cast<const uint16_t*>(message);printf_P(PSTR("%lu: NET message %04x\n\r"),millis(),*i));
if (len)
{
IF_SERIAL_DEBUG(const uint16_t* i = reinterpret_cast<const uint16_t*>(message);printf_P(PSTR("%lu: NET message %04x\n\r"),millis(),*i));
}

// If the user is trying to send it to himself
if ( header.to_node == node_address )
Expand Down

0 comments on commit 1ea7f80

Please sign in to comment.