Codec for an NRF24L01 based protocol

swtp_codec.h

Committer:
ihunter
Date:
2011-08-30
Revision:
1:c189b357fc3c
Parent:
0:b61d45ff9b8e
Child:
2:4dd0a9382f0d

File content as of revision 1:c189b357fc3c:

#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(uint8* packetToFill, int packetSize, PacketData* headerData);
    void decodeHeaderPacket(uint8* packet,       int packetSize, PacketData* headerDataToFill);
}

#endif /* SWTP_CODEC */