Codec for an NRF24L01 based protocol
swtp_codec.h@3:80ed23c0ae01, 2011-08-30 (annotated)
- Committer:
- ihunter
- Date:
- Tue Aug 30 21:20:23 2011 +0000
- Revision:
- 3:80ed23c0ae01
- Parent:
- 2:4dd0a9382f0d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ihunter | 0:b61d45ff9b8e | 1 | #ifndef SWTP_CODEC |
ihunter | 0:b61d45ff9b8e | 2 | #define SWTP_CODEC |
ihunter | 0:b61d45ff9b8e | 3 | |
ihunter | 3:80ed23c0ae01 | 4 | #include "types.h" |
ihunter | 1:c189b357fc3c | 5 | |
ihunter | 3:80ed23c0ae01 | 6 | #define SWTP_VERSION (0) |
ihunter | 1:c189b357fc3c | 7 | |
ihunter | 1:c189b357fc3c | 8 | typedef struct { |
ihunter | 1:c189b357fc3c | 9 | uint16 mimeType; |
ihunter | 1:c189b357fc3c | 10 | uint32 payloadLengthBytes; |
ihunter | 1:c189b357fc3c | 11 | uint16 startPayloadSequenceNumber; |
ihunter | 1:c189b357fc3c | 12 | } MessageHeader; |
ihunter | 1:c189b357fc3c | 13 | |
ihunter | 1:c189b357fc3c | 14 | typedef struct { |
ihunter | 1:c189b357fc3c | 15 | bool isMessageHeader; |
ihunter | 1:c189b357fc3c | 16 | bool isControlPacket; |
ihunter | 1:c189b357fc3c | 17 | uint8 flags; |
ihunter | 1:c189b357fc3c | 18 | uint8 version; |
ihunter | 1:c189b357fc3c | 19 | union { |
ihunter | 1:c189b357fc3c | 20 | MessageHeader messageHeader; |
ihunter | 1:c189b357fc3c | 21 | }; |
ihunter | 1:c189b357fc3c | 22 | } PacketData; |
ihunter | 1:c189b357fc3c | 23 | |
ihunter | 0:b61d45ff9b8e | 24 | extern "C" { |
ihunter | 1:c189b357fc3c | 25 | void encodeHeaderPacket(uint8* packetToFill, int packetSize, PacketData* headerData); |
ihunter | 2:4dd0a9382f0d | 26 | |
ihunter | 2:4dd0a9382f0d | 27 | void decodePacket(uint8* packet, int packetSize, PacketData* headerDataToFill); |
ihunter | 2:4dd0a9382f0d | 28 | |
ihunter | 0:b61d45ff9b8e | 29 | } |
ihunter | 0:b61d45ff9b8e | 30 | |
ihunter | 1:c189b357fc3c | 31 | #endif /* SWTP_CODEC */ |