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
BasicPacket/BasicPacket.h@0:f32c0e562e9a, 2016-06-29 (annotated)
- Committer:
- rba90
- Date:
- Wed Jun 29 01:37:59 2016 +0000
- Revision:
- 0:f32c0e562e9a
- Child:
- 2:f4f46b04ab8a
Init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rba90 | 0:f32c0e562e9a | 1 | #ifndef BASICPACKET_H_ |
rba90 | 0:f32c0e562e9a | 2 | #define BASICPACKET_H_ |
rba90 | 0:f32c0e562e9a | 3 | |
rba90 | 0:f32c0e562e9a | 4 | #include <stdint.h> |
rba90 | 0:f32c0e562e9a | 5 | |
rba90 | 0:f32c0e562e9a | 6 | class BasicPacket |
rba90 | 0:f32c0e562e9a | 7 | { |
rba90 | 0:f32c0e562e9a | 8 | private: |
rba90 | 0:f32c0e562e9a | 9 | // keep those private! |
rba90 | 0:f32c0e562e9a | 10 | // inherit class should always use public method to access those private |
rba90 | 0:f32c0e562e9a | 11 | // property |
rba90 | 0:f32c0e562e9a | 12 | uint8_t _buffer[4]; |
rba90 | 0:f32c0e562e9a | 13 | |
rba90 | 0:f32c0e562e9a | 14 | // verify() function will toggle this variable |
rba90 | 0:f32c0e562e9a | 15 | // any other modification to internal properties |
rba90 | 0:f32c0e562e9a | 16 | // will revert this variable to false |
rba90 | 0:f32c0e562e9a | 17 | bool _isVerified; |
rba90 | 0:f32c0e562e9a | 18 | |
rba90 | 0:f32c0e562e9a | 19 | public: |
rba90 | 0:f32c0e562e9a | 20 | BasicPacket(); |
rba90 | 0:f32c0e562e9a | 21 | BasicPacket(uint8_t *data); |
rba90 | 0:f32c0e562e9a | 22 | ~BasicPacket(); |
rba90 | 0:f32c0e562e9a | 23 | |
rba90 | 0:f32c0e562e9a | 24 | public: |
rba90 | 0:f32c0e562e9a | 25 | // calculate CRC value and write it into CRC field |
rba90 | 0:f32c0e562e9a | 26 | void generateCrc(); |
rba90 | 0:f32c0e562e9a | 27 | |
rba90 | 0:f32c0e562e9a | 28 | // calculate CRC value and compare it with that in CRC field |
rba90 | 0:f32c0e562e9a | 29 | bool verify(); |
rba90 | 0:f32c0e562e9a | 30 | |
rba90 | 0:f32c0e562e9a | 31 | // make a copy of internal buffer |
rba90 | 0:f32c0e562e9a | 32 | // the user |
rba90 | 0:f32c0e562e9a | 33 | void serialize(uint8_t *buffer); |
rba90 | 0:f32c0e562e9a | 34 | |
rba90 | 0:f32c0e562e9a | 35 | public: |
rba90 | 0:f32c0e562e9a | 36 | void setFid(uint8_t fid); |
rba90 | 0:f32c0e562e9a | 37 | void setField1(uint8_t field); |
rba90 | 0:f32c0e562e9a | 38 | void setField2(uint8_t field); |
rba90 | 0:f32c0e562e9a | 39 | void setField3(uint8_t field); |
rba90 | 0:f32c0e562e9a | 40 | |
rba90 | 0:f32c0e562e9a | 41 | uint8_t getFid(); |
rba90 | 0:f32c0e562e9a | 42 | uint8_t getField1(); |
rba90 | 0:f32c0e562e9a | 43 | uint8_t getField2(); |
rba90 | 0:f32c0e562e9a | 44 | uint8_t getField3(); |
rba90 | 0:f32c0e562e9a | 45 | uint8_t getCrc(); |
rba90 | 0:f32c0e562e9a | 46 | }; |
rba90 | 0:f32c0e562e9a | 47 | |
rba90 | 0:f32c0e562e9a | 48 | #endif |