Tiny protocol  0.7.0
Tiny communication protocol for microcontrollers
Public Member Functions | List of all members
Tiny::ProtoLight Class Reference

#include <TinyLightProtocol.h>

Public Member Functions

void begin (write_block_cb_t writecb, read_block_cb_t readcb)
 
void beginToSerial ()
 
void end ()
 
int write (char *buf, int size)
 
int read (char *buf, int size)
 
int write (Packet &pkt)
 
int read (Packet &pkt)
 

Detailed Description

ProtoLight class incapsulates Protocol functionality. Remember that you may use always C-style API functions instead C++. Please refer to documentation.

Member Function Documentation

◆ begin()

void Tiny::ProtoLight::begin ( write_block_cb_t  writecb,
read_block_cb_t  readcb 
)

Initializes protocol internal variables. If you need to switch communication with other destination point, you can call this method one again after calling end().

Parameters
writecb- write function to some physical channel
readcb- read function from some physical channel
Returns
None

◆ beginToSerial()

void Tiny::ProtoLight::beginToSerial ( )

Initializes protocol internal variables and redirects communication through Arduino Serial connection (Serial).

Returns
None

◆ end()

void Tiny::ProtoLight::end ( )

Resets protocol state.

◆ read() [1/2]

int Tiny::ProtoLight::read ( char *  buf,
int  size 
)

Reads data block from communication channel.

Parameters
buf- buffer to place data read from communication channel
size- maximum size of the buffer in bytes.
Returns
negative value in case of error zero if nothing is read positive - number of bytes read from the channel

◆ read() [2/2]

int Tiny::ProtoLight::read ( Packet pkt)

Reads packet from communication channel.

Parameters
pkt- Packet object to put data to
See also
Packet
Returns
negative value in case of error zero if nothing is read positive - Packet is successfully received

◆ write() [1/2]

int Tiny::ProtoLight::write ( char *  buf,
int  size 
)

Sends data block over communication channel.

Parameters
buf- data to send
size- length of the data in bytes
Returns
negative value in case of error zero if nothing is sent positive - should be equal to size parameter

◆ write() [2/2]

int Tiny::ProtoLight::write ( Packet pkt)

Sends packet over communication channel.

Parameters
pkt- Packet to send
See also
Packet
Returns
negative value in case of error zero if nothing is sent positive - Packet is successfully sent

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