3es  0.7
tes::PacketBuffer Class Reference

This class accepts responsibility for collating incoming byte streams. More...

#include <3espacketbuffer.h>

Public Member Functions

 PacketBuffer ()
 Constructors 2Kb buffer.
 
 ~PacketBuffer ()
 Destructor.
 
int addBytes (const uint8_t *bytes, size_t byteCount)
 Adds bytes to the buffer. More...
 
PacketHeaderextractPacket ()
 Extract the first valid packet in the buffer. More...
 
void releasePacket (PacketHeader *packet)
 Releases the memory for the given packet. More...
 

Detailed Description

This class accepts responsibility for collating incoming byte streams.

Data is buffered until full packets have arrived, which must be extracted using extractPacket().

Member Function Documentation

◆ addBytes()

int tes::PacketBuffer::addBytes ( const uint8_t *  bytes,
size_t  byteCount 
)

Adds bytes to the buffer.

Data are rejected if the marker is not present or, if present, data before the marker are rejected.

Returns
the index of the first accepted byte or -1 if all are rejected.

◆ extractPacket()

PacketHeader* tes::PacketBuffer::extractPacket ( )

Extract the first valid packet in the buffer.

Additional packets may be available.

Returns
A valid packet pointer if available, null if none available. The caller must later release the packet calling releasePacket().

◆ releasePacket()

void tes::PacketBuffer::releasePacket ( PacketHeader packet)

Releases the memory for the given packet.

Parameters
packetThe packet to release.

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