RF24Network v1

Sync.h

00001 /*
00002  Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
00003 
00004  This program is free software; you can redistribute it and/or
00005  modify it under the terms of the GNU General Public License
00006  version 2 as published by the Free Software Foundation.
00007  */
00008 
00009 #ifndef __SYNC_H__
00010 #define __SYNC_H__
00011 
00012 // STL headers
00013 // C headers
00014 #include <stdlib.h>
00015 #include <string.h>
00016 // Framework headers
00017 // Library headers
00018 #include <RF24Network_config.h>
00019 // Project headers
00020 
00021 class RF24Network;
00022 
00027 class Sync
00028 {
00029 private:
00030   RF24Network& network;
00031   uint8_t* app_data; 
00032   uint8_t* internal_data; 
00033   size_t len; 
00034   uint16_t to_node; 
00036 protected:
00037 public:
00043   Sync(RF24Network& _network): network(_network), app_data(NULL),
00044     internal_data(NULL), len(0), to_node(0)
00045   {
00046   }
00052   void begin(uint16_t _to_node)
00053   {
00054     to_node = _to_node;
00055   }
00061   template <class T>
00062   void register_me(T& _data)
00063   {
00064     app_data = reinterpret_cast<uint8_t*>(&_data);
00065     len = sizeof(_data);
00066     internal_data = reinterpret_cast<uint8_t*>(malloc(len));
00067     memcpy(internal_data,app_data,len);
00068   }
00069 
00073   void update(void);
00074 };
00075 
00076 #endif // __SYNC_H__
00077 // vim:cin:ai:sts=2 sw=2 ft=cpp
 All Classes Files Functions Variables