Andrew Reed / Mbed OS CITY1082-i2c_master_wifi_mqtt
Embed: (wiki syntax)

« Back to documentation index

MQTTNetworkMbedOs Class Reference

MQTTNetworkMbedOs Class Reference

Implementation of the Network class template parameter of MQTTClient. More...

#include <MQTTClientMbedOs.h>

Public Member Functions

 MQTTNetworkMbedOs (Socket *_socket)
 Construct the network implementation.
int read (unsigned char *buffer, int len, int timeout)
 Read data from the socket.
int write (unsigned char *buffer, int len, int timeout)
 Write data to the socket.
int connect (const char *hostname, int port)
 Connect the socket to the hostname at a given port.
int disconnect ()
 Disconnect from the hostname.

Detailed Description

Implementation of the Network class template parameter of MQTTClient.

Definition at line 39 of file MQTTClientMbedOs.h.


Constructor & Destructor Documentation

MQTTNetworkMbedOs ( Socket *  _socket )

Construct the network implementation.

If TCPSocket or TLSSocket are provided, the MQTT protocol will be used. If UDPSocket or DTLSSocket are provided, the MQTT-SN protocol will be used.

Parameters:
_socketsocket to be used for MQTT communication.

Definition at line 49 of file MQTTClientMbedOs.h.


Member Function Documentation

int connect ( const char *  hostname,
int  port 
)

Connect the socket to the hostname at a given port.

The socket must have the network interface set up and connected before. This connect() is different from MQTTClient::connect, which performs the connection to a broker, over the connected socket.

Parameters:
hostnameHostname to connect to. This can be a string containing IP address like "192.168.52.10" or domain address, like "mqtt.flespi.io"
portport number to be used for connection

Definition at line 55 of file MQTTClientMbedOs.cpp.

int disconnect (  )

Disconnect from the hostname.

Definition at line 61 of file MQTTClientMbedOs.cpp.

int read ( unsigned char *  buffer,
int  len,
int  timeout 
)

Read data from the socket.

Parameters:
bufferbuffer to store the data
lenexpected amount of bytes
timeouttimeout for the operation

Definition at line 20 of file MQTTClientMbedOs.cpp.

int write ( unsigned char *  buffer,
int  len,
int  timeout 
)

Write data to the socket.

Parameters:
bufferbuffer that contains data to be written
lenamount of bytes to write
timeouttimeout for the operation

Definition at line 38 of file MQTTClientMbedOs.cpp.