Describes packet entity and provides API methods to manipulate the packet.
More...
#include <TinyPacket.h>
|
| | IPacket (char *buf, int size) |
| | Creates packet object. More...
|
| |
|
| IPacket (const IPacket &packet) |
| |
|
virtual | ~IPacket ()=default |
| | Destroys the object.
|
| |
| void | clear () |
| | Clears Packet state. More...
|
| |
| void | put (uint8_t byte) |
| | Puts next byte to the packet. More...
|
| |
| void | put (char chr) |
| | Puts next char to the packet. More...
|
| |
| void | put (uint16_t data) |
| | Puts next 16-bit unsigned integer to the packet. More...
|
| |
| void | put (uint32_t data) |
| | Puts next 32-bit unsigned integer to the packet. More...
|
| |
| void | put (int16_t data) |
| | Puts next 16-bit signed integer to the packet. More...
|
| |
| void | put (const char *str) |
| | Puts next null-terminated string to the packet. More...
|
| |
| void | put (const IPacket &pkt) |
| | Adds data from packet to the new packet being built. More...
|
| |
| uint8_t | getByte () |
| | Reads next byte from the packet. More...
|
| |
| char | getChar () |
| | Reads next character from the packet. More...
|
| |
| uint16_t | getUint16 () |
| | Reads next unsigned 16-bit integer from the packet. More...
|
| |
| int16_t | getInt16 () |
| | Reads next signed 16-bit integer from the packet. More...
|
| |
| uint32_t | getUint32 () |
| | Reads next unsigned 32-bit integer from the packet. More...
|
| |
| char * | getString () |
| | Reads zero-terminated string from the packet. More...
|
| |
| int | size () const |
| | Returns size of payload data in the received packet. More...
|
| |
| int | maxSize () const |
| | Returns maximum size of packet buffer. More...
|
| |
| char * | data () const |
| | Returns pointer to payload data in the received packet. More...
|
| |
| size_t | availableBytes () |
| | Returns size of remaining bytes (not yet accessed through get*()) in the received packet. More...
|
| |
|
uint8_t & | operator[] (int idx) |
| | You may refer to Packet payload data directly by using operator [].
|
| |
|
IPacket & | operator= (const IPacket &source) |
| | Assign operator doesn't copy the data from the source packet, but it copies only pointers.
|
| |
| void | allocate (int bytes) |
| | Allocates space inside the packet buffer, the next data will be written after allocated block. More...
|
| |
|
|
class | Hdlc |
| |
|
class | IFd |
| |
|
class | Light |
| |
|
class | Proto |
| |
Describes packet entity and provides API methods to manipulate the packet.
◆ IPacket()
| tinyproto::IPacket::IPacket |
( |
char * |
buf, |
|
|
int |
size |
|
) |
| |
|
inline |
Creates packet object.
- Parameters
-
| buf | - pointer to the buffer to store packet data |
| size | - size of the buffer to hold packet data |
- Note
- passed buffer must exist all lifecycle of the Packet object.
◆ allocate()
| void tinyproto::IPacket::allocate |
( |
int |
bytes | ) |
|
|
inline |
Allocates space inside the packet buffer, the next data will be written after allocated block.
Allocate operation doesn't changes the data inside the buffer
◆ availableBytes()
| size_t tinyproto::IPacket::availableBytes |
( |
| ) |
|
|
inline |
Returns size of remaining bytes (not yet accessed through get*()) in the received packet.
- Returns
- size of remaining payload data.
◆ clear()
| void tinyproto::IPacket::clear |
( |
| ) |
|
|
inline |
Clears Packet state.
Buffer and its size are preserved.
◆ data()
| char* tinyproto::IPacket::data |
( |
| ) |
const |
|
inline |
Returns pointer to payload data in the received packet.
- Returns
- pointer to payload data.
◆ getByte()
| uint8_t tinyproto::IPacket::getByte |
( |
| ) |
|
|
inline |
Reads next byte from the packet.
- Returns
- byte from the packet.
◆ getChar()
| char tinyproto::IPacket::getChar |
( |
| ) |
|
|
inline |
Reads next character from the packet.
- Returns
- character from the packet.
◆ getInt16()
| int16_t tinyproto::IPacket::getInt16 |
( |
| ) |
|
|
inline |
Reads next signed 16-bit integer from the packet.
- Returns
- signed 16-bit integer.
◆ getString()
| char* tinyproto::IPacket::getString |
( |
| ) |
|
|
inline |
Reads zero-terminated string from the packet.
- Returns
- zero-terminated string.
◆ getUint16()
| uint16_t tinyproto::IPacket::getUint16 |
( |
| ) |
|
|
inline |
Reads next unsigned 16-bit integer from the packet.
- Returns
- unsigned 16-bit integer.
◆ getUint32()
| uint32_t tinyproto::IPacket::getUint32 |
( |
| ) |
|
|
inline |
Reads next unsigned 32-bit integer from the packet.
- Returns
- unsigned 32-bit integer.
◆ maxSize()
| int tinyproto::IPacket::maxSize |
( |
| ) |
const |
|
inline |
Returns maximum size of packet buffer.
- Returns
- max size of packet buffer.
◆ put() [1/7]
| void tinyproto::IPacket::put |
( |
uint8_t |
byte | ) |
|
|
inline |
Puts next byte to the packet.
For example, after calling this method twice: put(5), put(10), - the Packet will contain 5,10.
- Parameters
-
◆ put() [2/7]
| void tinyproto::IPacket::put |
( |
char |
chr | ) |
|
|
inline |
Puts next char to the packet.
For example, after calling this method twice: put('a'), put('c'), - the Packet will contain 'ac'.
- Parameters
-
◆ put() [3/7]
| void tinyproto::IPacket::put |
( |
uint16_t |
data | ) |
|
|
inline |
Puts next 16-bit unsigned integer to the packet.
- Parameters
-
◆ put() [4/7]
| void tinyproto::IPacket::put |
( |
uint32_t |
data | ) |
|
|
inline |
Puts next 32-bit unsigned integer to the packet.
- Parameters
-
◆ put() [5/7]
| void tinyproto::IPacket::put |
( |
int16_t |
data | ) |
|
|
inline |
Puts next 16-bit signed integer to the packet.
- Parameters
-
◆ put() [6/7]
| void tinyproto::IPacket::put |
( |
const char * |
str | ) |
|
|
inline |
Puts next null-terminated string to the packet.
- Parameters
-
◆ put() [7/7]
| void tinyproto::IPacket::put |
( |
const IPacket & |
pkt | ) |
|
|
inline |
Adds data from packet to the new packet being built.
- Parameters
-
| pkt | - reference to the Packet to add. |
◆ size()
| int tinyproto::IPacket::size |
( |
| ) |
const |
|
inline |
Returns size of payload data in the received packet.
- Returns
- size of payload data.
The documentation for this class was generated from the following file: