Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 5_Dragonfly_Cayenne_Sprint_IKS01A1
Fork of Cayenne-MQTT-mbed-MTSAS by
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 67 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 79 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 91 of file MQTTNetwork.h.
Generated on Wed Jul 13 2022 08:52:00 by
1.7.2
