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
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:
-
Interface A 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] interface The network interface to use
Definition at line 36 of file MQTTNetwork.h.
MQTTNetwork | ( | Interface & | interface ) |
Construct the network interface.
- Parameters:
-
[in] interface The 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] hostname Host for connection [in] port Port for connection [in] timeout_ms Timeout 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] hostname Host for connection [in] port Port for connection [in] timeout_ms Timeout 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] buffer Buffer that receives the data [in] len Buffer length [in] timeout_ms Timeout 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] buffer Buffer that receives the data [in] len Buffer length [in] timeout_ms Timeout 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] buffer Buffer that contains data to write [in] len Number of bytes to write [in] timeout_ms Timeout 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] buffer Buffer that contains data to write [in] len Number of bytes to write [in] timeout_ms Timeout 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.
Generated on Wed Jul 13 2022 15:49:28 by 1.7.2