Layer 2 Aloha packet

Dependents:   AlohaTransceiver

Committer:
rba90
Date:
Tue Jul 12 13:08:01 2016 +0000
Revision:
0:bd0c4fdc6833
Child:
1:b714fce6e23b
Layer 2 Mac Protocol

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rba90 0:bd0c4fdc6833 1 #ifndef ALOHAFRAME_H_
rba90 0:bd0c4fdc6833 2 #define ALOHAFRAME_H_
rba90 0:bd0c4fdc6833 3
rba90 0:bd0c4fdc6833 4 #include <stdint.h>
rba90 0:bd0c4fdc6833 5
rba90 0:bd0c4fdc6833 6 #define MAX_FRAME_SZ 20
rba90 0:bd0c4fdc6833 7 #define MAX_PAYLOAD_SZ 16
rba90 0:bd0c4fdc6833 8
rba90 0:bd0c4fdc6833 9 class AlohaFrame
rba90 0:bd0c4fdc6833 10 {
rba90 0:bd0c4fdc6833 11 private:
rba90 0:bd0c4fdc6833 12 uint8_t _buffer[MAX_FRAME_SZ];
rba90 0:bd0c4fdc6833 13
rba90 0:bd0c4fdc6833 14 bool _isVerified;
rba90 0:bd0c4fdc6833 15
rba90 0:bd0c4fdc6833 16 public:
rba90 0:bd0c4fdc6833 17 AlohaFrame();
rba90 0:bd0c4fdc6833 18 AlohaFrame(uint8_t *data, uint8_t sz=MAX_PAYLOAD_SZ);
rba90 0:bd0c4fdc6833 19 ~AlohaFrame();
rba90 0:bd0c4fdc6833 20
rba90 0:bd0c4fdc6833 21 public:
rba90 0:bd0c4fdc6833 22 void generateCrc();
rba90 0:bd0c4fdc6833 23
rba90 0:bd0c4fdc6833 24 bool verify();
rba90 0:bd0c4fdc6833 25
rba90 0:bd0c4fdc6833 26 uint8_t serialize(uint8_t *buffer);
rba90 0:bd0c4fdc6833 27
rba90 0:bd0c4fdc6833 28 public:
rba90 0:bd0c4fdc6833 29 void setType(uint8_t type);
rba90 0:bd0c4fdc6833 30 void setPayloadLength(uint8_t length);
rba90 0:bd0c4fdc6833 31 void setSourceAddress(uint8_t sa);
rba90 0:bd0c4fdc6833 32 void setDestinationAddress(uint8_t da);
rba90 0:bd0c4fdc6833 33 void setFullMessageFlag(uint8_t fmf);
rba90 0:bd0c4fdc6833 34 void setSequenceID(uint8_t seqid);
rba90 0:bd0c4fdc6833 35 void setPayload(uint8_t payload, uint8_t idx);
rba90 0:bd0c4fdc6833 36
rba90 0:bd0c4fdc6833 37 uint8_t getType();
rba90 0:bd0c4fdc6833 38 uint8_t getPayloadLength();
rba90 0:bd0c4fdc6833 39 uint8_t getSourceAddress();
rba90 0:bd0c4fdc6833 40 uint8_t getDestinationAddress();
rba90 0:bd0c4fdc6833 41 uint8_t getFullMessageFlag();
rba90 0:bd0c4fdc6833 42 uint8_t getSequenceID();
rba90 0:bd0c4fdc6833 43 uint8_t getPayload(uint8_t idx);
rba90 0:bd0c4fdc6833 44 uint8_t getCrc();
rba90 0:bd0c4fdc6833 45
rba90 0:bd0c4fdc6833 46 #ifdef _DEBUG
rba90 0:bd0c4fdc6833 47 public:
rba90 0:bd0c4fdc6833 48 void unit_test();
rba90 0:bd0c4fdc6833 49 #endif
rba90 0:bd0c4fdc6833 50 };
rba90 0:bd0c4fdc6833 51
rba90 0:bd0c4fdc6833 52 #endif