Tiny protocol
0.9.0
Tiny communication protocol for microcontrollers
|
#include <TinyPacket.h>
Public Member Functions | |
IPacket (char *buf, size_t size) | |
virtual | ~IPacket ()=default |
void | clear () |
void | put (uint8_t byte) |
void | put (char chr) |
void | put (uint16_t data) |
void | put (uint32_t data) |
void | put (int16_t data) |
void | put (const char *str) |
void | put (const IPacket &pkt) |
uint8_t | getByte () |
char | getChar () |
uint16_t | getUint16 () |
int16_t | getInt16 () |
uint32_t | getUint32 () |
char * | getString () |
size_t | size () const |
size_t | maxSize () const |
char * | data () |
uint8_t & | operator[] (size_t idx) |
IPacket & | operator= (char chr) |
Friends | |
class | ProtoHd |
class | IProtoFd |
class | ProtoLight |
Describes packet entity and provides API methods to manipulate the packet.
|
inline |
Creates packet object.
buf | - pointer to the buffer to store packet data |
size | - size of the buffer to hold packet data |
|
virtualdefault |
Destroys the object
|
inline |
Clears Packet state. Buffer and its size are preserved.
|
inline |
Returns size of payload data in the received packet.
|
inline |
Reads next byte from the packet.
|
inline |
Reads next character from the packet.
|
inline |
Reads next signed 16-bit integer from the packet.
|
inline |
Reads zero-terminated string from the packet.
|
inline |
Reads next unsigned 16-bit integer from the packet.
|
inline |
Reads next unsigned 32-bit integer from the packet.
|
inline |
Returns maximum size of packet buffer.
|
inline |
Assign operator = puts next char to the packet. Several assign operators put one by one several chars.
|
inline |
You may refer to Packet payload data directly by using operator []
|
inline |
Puts next byte to the packet. For example, after calling this method twice: put(5), put(10), - the Packet will contain 5,10.
byte | - data byte to put. |
|
inline |
Puts next char to the packet. For example, after calling this method twice: put('a'), put('c'), - the Packet will contain 'ac'.
chr | - character to put. |
|
inline |
Puts next 16-bit unsigned integer to the packet.
data | - data to put. |
|
inline |
Puts next 32-bit unsigned integer to the packet.
data | - data to put. |
|
inline |
Puts next 16-bit signed integer to the packet.
data | - data to put. |
|
inline |
Puts next null-terminated string to the packet.
str | - string to put. |
|
inline |
Adds data from packet to the new packet being built.
pkt | - reference to the Packet to add. |
|
inline |
Returns size of payload data in the received packet.