Codec for an NRF24L01 based protocol

Revision:
1:c189b357fc3c
Parent:
0:b61d45ff9b8e
Child:
2:4dd0a9382f0d
--- a/swtp_codec.h	Tue Aug 30 10:30:50 2011 +0000
+++ b/swtp_codec.h	Tue Aug 30 17:45:12 2011 +0000
@@ -1,8 +1,35 @@
 #ifndef SWTP_CODEC
 #define SWTP_CODEC
 
+#define SWTP_VERSION (0)
+
+// I cant bear these '_t'
+typedef uint8_t  uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef int8_t   sint8;
+typedef int16_t  sint16;
+typedef int32_t  sint32;
+
+typedef struct  {
+    uint16 mimeType;
+    uint32 payloadLengthBytes;
+    uint16 startPayloadSequenceNumber;
+} MessageHeader;
+
+typedef struct {
+    bool isMessageHeader;
+    bool isControlPacket;
+    uint8  flags;
+    uint8  version;
+    union {
+        MessageHeader messageHeader;
+    };
+} PacketData;
+
 extern "C" {
-    void encodeHeaderPacket(char* packetToFill, int mimeType, int payloadLengthBytes, int startPayloadSequenceNumber);
+    void encodeHeaderPacket(uint8* packetToFill, int packetSize, PacketData* headerData);
+    void decodeHeaderPacket(uint8* packet,       int packetSize, PacketData* headerDataToFill);
 }
 
-#endif
\ No newline at end of file
+#endif /* SWTP_CODEC */
\ No newline at end of file