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>
|
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...
|
|
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.
◆ closeTransportConnection()
virtual int16_t TransportLayer::closeTransportConnection |
( |
| ) |
|
|
pure virtual |
◆ getNumBytes()
virtual size_t TransportLayer::getNumBytes |
( |
uint32_t |
timeout = 10000 , |
|
|
size_t |
minBytes = 10 |
|
) |
| |
|
pure virtual |
Get number of received bytes.
- Parameters
-
timeout | Reception timeout in ms. Defaults to 10000. |
minBytes | Minimum 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
-
host | Host to connect to. |
protocol | Transport protocol to use. Usually "TCP" or "UDP". |
port | to be used for the connection. |
tcpKeepAlive | TCP 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
-
data | Pointer to array to save the received data. |
len | Number of bytes to read. |
timeout | Reception 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
-
string | String 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
-
data | Data to be sent. |
len | Number of bytes to send. |
- Returns
- Status Codes
Implemented in ESP8266.
The documentation for this class was generated from the following file: