tinyproto
Public Member Functions | Protected Member Functions | List of all members
tinyproto::IHdlcLinkLayer Class Reference
Inheritance diagram for tinyproto::IHdlcLinkLayer:
Inheritance graph
[legend]
Collaboration diagram for tinyproto::IHdlcLinkLayer:
Collaboration graph
[legend]

Public Member Functions

 IHdlcLinkLayer (void *buffer, int size)
 
bool begin (on_frame_read_cb_t onReadCb, on_frame_send_cb_t onSendCb, void *udata) override
 The method initializes the link layer protocol, and connects custom callbacks to link layer. More...
 
void end () override
 Stops link layer protocol.
 
bool put (void *buf, int size, uint32_t timeout) override
 Puts new data for sending over the link layer. More...
 
void flushTx () override
 Flush tx operation if possible.
 
hdlc_crc_t getCrc ()
 
void setCrc (hdlc_crc_t crc)
 
void setBuffer (void *buffer, int size)
 
- Public Member Functions inherited from tinyproto::ILinkLayer
virtual void runRx ()=0
 Runs rx part of the protocol. More...
 
virtual void runTx ()=0
 Runs tx part of the protocol. More...
 
void setTimeout (uint32_t timeout)
 Sets timeout of Rx/Tx operations in milliseconds for the link layer protocol. More...
 
uint32_t getTimeout ()
 Returns current timeout of Rx/Tx operations.
 
int getMtu ()
 Returns current mtu for the link layer protocol in bytes.
 
void setMtu (int mtu)
 Set protocol mtu (maximum transmission unit) payload. More...
 
virtual ~ILinkLayer ()=default
 Default virtual destructor.
 

Protected Member Functions

int parseData (const uint8_t *data, int size)
 
int getData (uint8_t *data, int size)
 

Member Function Documentation

◆ begin()

bool tinyproto::IHdlcLinkLayer::begin ( on_frame_read_cb_t  onReadCb,
on_frame_send_cb_t  onSendCb,
void *  udata 
)
overridevirtual

The method initializes the link layer protocol, and connects custom callbacks to link layer.

Once the new frame is received, onReadCb will be called, once frame is sent onSendCb will be called.

Parameters
onReadCbcallback to call when a frame is received. Remember that processing must be as quick as possible
onSendCbcallback to call when a frame is sent.
udatauser defined data, will be passed to callbacks
Returns
true if successful, false is initialization error happened.

Implements tinyproto::ILinkLayer.

Reimplemented in tinyproto::SerialHdlcLink.

◆ put()

bool tinyproto::IHdlcLinkLayer::put ( void *  buf,
int  size,
uint32_t  timeout 
)
overridevirtual

Puts new data for sending over the link layer.

Parameters
bufpointer to the buffer with the data
sizesize of the data in the buffer
timeouttimeout in milliseconds to wait for operation to complete
Returns
true if the data is successfully put to the queue, false if timeout happened or error

Implements tinyproto::ILinkLayer.


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