tinyproto
|
Template class to create packet with static allocation of buffer Use this class for microcontrollers with few resources. More...
#include <TinyPacket.h>
Public Member Functions | |
StaticPacket () | |
Creates IPacket instance with statically allocated buffer. | |
![]() | |
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... | |
Template class to create packet with static allocation of buffer Use this class for microcontrollers with few resources.