RadioLib
Universal wireless communication library for Arduino
TransportLayer Class Referenceabstract

Provides common interface for protocols that run on modules with Internet connectivity, such as HTTP or MQTT. Because this class is used mainly as interface, all of its virtual members must be implemented in the module class. More...

#include <TransportLayer.h>

Inheritance diagram for TransportLayer:
ESP8266

Public Member Functions

virtual int16_t openTransportConnection (const char *host, const char *protocol, uint16_t port, uint16_t tcpKeepAlive=0)=0
 Open transport layer connection. More...
 
virtual int16_t closeTransportConnection ()=0
 Close transport layer connection. More...
 
virtual int16_t send (const char *data)=0
 Send string-based data. More...
 
virtual int16_t send (uint8_t *data, size_t len)=0
 Send arbitrary binary data. More...
 
virtual size_t receive (uint8_t *data, size_t len, uint32_t timeout=10000)=0
 Receive data. More...
 
virtual size_t getNumBytes (uint32_t timeout=10000, size_t minBytes=10)=0
 Get number of received bytes. More...
 

Detailed Description

Provides common interface for protocols that run on modules with Internet connectivity, such as HTTP or MQTT. Because this class is used mainly as interface, all of its virtual members must be implemented in the module class.

Member Function Documentation

◆ closeTransportConnection()

virtual int16_t TransportLayer::closeTransportConnection ( )
pure virtual

Close transport layer connection.

Returns
Status Codes

Implemented in ESP8266.

◆ getNumBytes()

virtual size_t TransportLayer::getNumBytes ( uint32_t  timeout = 10000,
size_t  minBytes = 10 
)
pure virtual

Get number of received bytes.

Parameters
timeoutReception timeout in ms. Defaults to 10000.
minBytesMinimum required number of bytes that must be received.
Returns
Number of received bytes, or 0 on timeout.

Implemented in ESP8266.

◆ openTransportConnection()

virtual int16_t TransportLayer::openTransportConnection ( const char *  host,
const char *  protocol,
uint16_t  port,
uint16_t  tcpKeepAlive = 0 
)
pure virtual

Open transport layer connection.

Parameters
hostHost to connect to.
protocolTransport protocol to use. Usually "TCP" or "UDP".
portto be used for the connection.
tcpKeepAliveTCP keep alive interval. Defaults to 0.
Returns
Status Codes

Implemented in ESP8266.

◆ receive()

virtual size_t TransportLayer::receive ( uint8_t *  data,
size_t  len,
uint32_t  timeout = 10000 
)
pure virtual

Receive data.

Parameters
dataPointer to array to save the received data.
lenNumber of bytes to read.
timeoutReception timeout in ms. Defaults to 10000.
Returns
Status Codes

Implemented in ESP8266.

◆ send() [1/2]

virtual int16_t TransportLayer::send ( const char *  data)
pure virtual

Send string-based data.

Parameters
stringString data to be sent.
Returns
Status Codes

Implemented in ESP8266.

◆ send() [2/2]

virtual int16_t TransportLayer::send ( uint8_t *  data,
size_t  len 
)
pure virtual

Send arbitrary binary data.

Parameters
dataData to be sent.
lenNumber of bytes to send.
Returns
Status Codes

Implemented in ESP8266.


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