Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LoRaBaseStation LoRaTerminal
Diff: BasicPacket/BasicPacket.h
- Revision:
- 0:f32c0e562e9a
- Child:
- 2:f4f46b04ab8a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BasicPacket/BasicPacket.h Wed Jun 29 01:37:59 2016 +0000 @@ -0,0 +1,48 @@ +#ifndef BASICPACKET_H_ +#define BASICPACKET_H_ + +#include <stdint.h> + +class BasicPacket +{ +private: + // keep those private! + // inherit class should always use public method to access those private + // property + uint8_t _buffer[4]; + + // verify() function will toggle this variable + // any other modification to internal properties + // will revert this variable to false + bool _isVerified; + +public: + BasicPacket(); + BasicPacket(uint8_t *data); + ~BasicPacket(); + +public: + // calculate CRC value and write it into CRC field + void generateCrc(); + + // calculate CRC value and compare it with that in CRC field + bool verify(); + + // make a copy of internal buffer + // the user + void serialize(uint8_t *buffer); + +public: + void setFid(uint8_t fid); + void setField1(uint8_t field); + void setField2(uint8_t field); + void setField3(uint8_t field); + + uint8_t getFid(); + uint8_t getField1(); + uint8_t getField2(); + uint8_t getField3(); + uint8_t getCrc(); +}; + +#endif \ No newline at end of file