Layer 2 Aloha packet
Diff: AlohaFrame.h
- Revision:
- 0:bd0c4fdc6833
- Child:
- 1:b714fce6e23b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AlohaFrame.h Tue Jul 12 13:08:01 2016 +0000 @@ -0,0 +1,52 @@ +#ifndef ALOHAFRAME_H_ +#define ALOHAFRAME_H_ + +#include <stdint.h> + +#define MAX_FRAME_SZ 20 +#define MAX_PAYLOAD_SZ 16 + +class AlohaFrame +{ +private: + uint8_t _buffer[MAX_FRAME_SZ]; + + bool _isVerified; + +public: + AlohaFrame(); + AlohaFrame(uint8_t *data, uint8_t sz=MAX_PAYLOAD_SZ); + ~AlohaFrame(); + +public: + void generateCrc(); + + bool verify(); + + uint8_t serialize(uint8_t *buffer); + +public: + void setType(uint8_t type); + void setPayloadLength(uint8_t length); + void setSourceAddress(uint8_t sa); + void setDestinationAddress(uint8_t da); + void setFullMessageFlag(uint8_t fmf); + void setSequenceID(uint8_t seqid); + void setPayload(uint8_t payload, uint8_t idx); + + uint8_t getType(); + uint8_t getPayloadLength(); + uint8_t getSourceAddress(); + uint8_t getDestinationAddress(); + uint8_t getFullMessageFlag(); + uint8_t getSequenceID(); + uint8_t getPayload(uint8_t idx); + uint8_t getCrc(); + +#ifdef _DEBUG +public: + void unit_test(); +#endif +}; + +#endif