tinyproto
Public Member Functions | List of all members
tinyproto::HeapPacket Class Reference

Class which allocated buffer for packet dynamically. More...

#include <TinyPacket.h>

Inheritance diagram for tinyproto::HeapPacket:
Inheritance graph
[legend]
Collaboration diagram for tinyproto::HeapPacket:
Collaboration graph
[legend]

Public Member Functions

 HeapPacket (int size)
 Creates packet with dynamically allocated buffer. More...
 
 HeapPacket (const IPacket &src)
 
- Public Member Functions inherited from tinyproto::IPacket
 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 [].
 
IPacketoperator= (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...
 

Detailed Description

Class which allocated buffer for packet dynamically.

Use this class only on powerful microcontrollers.

Constructor & Destructor Documentation

◆ HeapPacket()

tinyproto::HeapPacket::HeapPacket ( int  size)
inlineexplicit

Creates packet with dynamically allocated buffer.

Parameters
sizenumber of bytes to allocate for the packet buffer.

The documentation for this class was generated from the following file: