Codec for an NRF24L01 based protocol

swtp_codec.h

Committer:
ihunter
Date:
2011-08-30
Revision:
2:4dd0a9382f0d
Parent:
1:c189b357fc3c
Child:
3:80ed23c0ae01

File content as of revision 2:4dd0a9382f0d:

#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 decodePacket(uint8* packet, int packetSize, PacketData* headerDataToFill);

}

#endif /* SWTP_CODEC */