Skip to content

Commit

Permalink
Added id field to header
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Jun 8, 2011
1 parent 4c9141b commit 48d22a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions RF24Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#undef PSTR
#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];}))

uint16_t RF24NetworkHeader::next_id = 1;

RF24Network::RF24Network( RF24& _radio, const RF24NodeLine* _topology ): radio(_radio), topology(_topology), next_frame(frame_queue)
{
// Find out how many nodes are defined
Expand Down Expand Up @@ -269,8 +271,8 @@ uint16_t RF24Network::find_node( uint16_t current_node, uint16_t target_node )

const char* RF24NetworkHeader::toString(void) const
{
static char buffer[20];
snprintf(buffer,sizeof(buffer),"from %04x to %04x",from_node,to_node);
static char buffer[28];
snprintf(buffer,sizeof(buffer),"id %04x from %04x to %04x",id,from_node,to_node);
return buffer;
}

Expand Down
4 changes: 3 additions & 1 deletion RF24Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ struct RF24NetworkHeader
{
uint16_t from_node;
uint16_t to_node;
uint16_t id;
static uint16_t next_id;
RF24NetworkHeader() {}
RF24NetworkHeader(uint16_t _to): to_node(_to) {}
RF24NetworkHeader(uint16_t _to): to_node(_to), id(next_id++) {}
const char* toString(void) const;
};

Expand Down

0 comments on commit 48d22a6

Please sign in to comment.