The Cayenne MQTT mbed Library provides functions to easily connect to the Cayenne IoT project builder.

Dependents:   Cayenne-ESP8266Interface Cayenne-WIZnet_Library Cayenne-WIZnetInterface Cayenne-X-NUCLEO-IDW01M1 ... more

Embed: (wiki syntax)

« Back to documentation index

MQTTNetwork< Interface > Class Template Reference

MQTTNetwork< Interface > Class Template Reference

Networking class for use with MQTTClient. More...

#include <MQTTNetwork.h>

Public Member Functions

 MQTTNetwork (Interface &interface)
 Construct the network interface.
int connect (char *hostname, int port, int timeout_ms=1000)
 Connect the network interface.
bool disconnect ()
 Disconnect the network interface.
bool connected ()
 Check if connected.
int read (unsigned char *buffer, int len, int timeout_ms)
 Read data from the network.
int write (unsigned char *buffer, int len, int timeout_ms)
 Write data to the network.
 MQTTNetwork (Interface &interface)
 Construct the network interface.
int connect (char *hostname, int port, int timeout_ms=1000)
 Connect the network interface.
bool disconnect ()
 Disconnect the network interface.
bool connected ()
 Check if connected.
int read (unsigned char *buffer, int len, int timeout_ms)
 Read data from the network.
int write (unsigned char *buffer, int len, int timeout_ms)
 Write data to the network.

Detailed Description

template<class Interface>
class MQTTNetwork< Interface >

Networking class for use with MQTTClient.

Parameters:
InterfaceA network interface class with the methods: init, connect and disconnect.

Definition at line 29 of file MQTTNetwork.h.


Constructor & Destructor Documentation

MQTTNetwork ( Interface &  interface )

Construct the network interface.

Parameters:
[in]interfaceThe network interface to use

Definition at line 36 of file MQTTNetwork.h.

MQTTNetwork ( Interface &  interface )

Construct the network interface.

Parameters:
[in]interfaceThe network interface to use

Definition at line 36 of file MQTTNetworkIDW01M1.h.


Member Function Documentation

int connect ( char *  hostname,
int  port,
int  timeout_ms = 1000 
)

Connect the network interface.

Parameters:
[in]hostnameHost for connection
[in]portPort for connection
[in]timeout_msTimeout for the read operation, in milliseconds
Returns:
0 on success, -1 on failure.

Definition at line 46 of file MQTTNetwork.h.

int connect ( char *  hostname,
int  port,
int  timeout_ms = 1000 
)

Connect the network interface.

Parameters:
[in]hostnameHost for connection
[in]portPort for connection
[in]timeout_msTimeout for the read operation, in milliseconds
Returns:
0 on success, -1 on failure.

Definition at line 47 of file MQTTNetworkIDW01M1.h.

bool connected (  )

Check if connected.

Returns:
true if connected, false otherwise

Definition at line 69 of file MQTTNetworkIDW01M1.h.

bool connected (  )

Check if connected.

Returns:
true if connected, false otherwise

Definition at line 66 of file MQTTNetwork.h.

bool disconnect (  )

Disconnect the network interface.

Returns:
true if disconnect was successful, false otherwise

Definition at line 56 of file MQTTNetwork.h.

bool disconnect (  )

Disconnect the network interface.

Returns:
true if disconnect was successful, false otherwise

Definition at line 59 of file MQTTNetworkIDW01M1.h.

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

Read data from the network.

Parameters:
[out]bufferBuffer that receives the data
[in]lenBuffer length
[in]timeout_msTimeout for the read operation, in milliseconds
Returns:
Number of bytes read, or a negative value if there was an error

Definition at line 78 of file MQTTNetwork.h.

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

Read data from the network.

Parameters:
[out]bufferBuffer that receives the data
[in]lenBuffer length
[in]timeout_msTimeout for the read operation, in milliseconds
Returns:
Number of bytes read, or a negative value if there was an error

Definition at line 81 of file MQTTNetworkIDW01M1.h.

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

Write data to the network.

Parameters:
[in]bufferBuffer that contains data to write
[in]lenNumber of bytes to write
[in]timeout_msTimeout for the write operation, in milliseconds
Returns:
Number of bytes written, or a negative value if there was an error

Definition at line 93 of file MQTTNetworkIDW01M1.h.

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

Write data to the network.

Parameters:
[in]bufferBuffer that contains data to write
[in]lenNumber of bytes to write
[in]timeout_msTimeout for the write operation, in milliseconds
Returns:
Number of bytes written, or a negative value if there was an error

Definition at line 90 of file MQTTNetwork.h.