Internet Middleware API Reference  Rev 1.0
MQTT

Open source MQTT client implementation is part of Paho project aimed at new, existing, and emerging applications for Machine‑to‑Machine (M2M) and Internet of Things (IoT). More...

Overview

Open source MQTT client implementation is part of Paho project aimed at new, existing, and emerging applications for Machine‑to‑Machine (M2M) and Internet of Things (IoT).

For more details, please refer to Paho project . In this release, MediaTek has integrated Paho MQTT protocol with mbed TLS and lwIP. New APIs related to the network connectivity are also introduced in this section. The MQTT add-on APIs follow the original Paho project coding style. A reference example can be found under /project/mt7687_hdk/apps/mqtt_client folder.

Terms and Acronyms

Terms Details
MQTT MQ Telemetry Transport. For more details, please refer to wikipedia MQTT.
TLS Transport Layer Security.
lwIP Lightweight IP is a widely used open source TCP/IP stack designed for embedded systems.
Wi-Fi Wi-Fi is a local area wireless computer networking technology. For more details, please refer to wikipedia Wi-Fi.

Functions

void NewNetwork (Network *n)
 This function initializes the network structure. More...
 
int ConnectNetwork (Network *n, char *addr, char *port)
 This function connects to the MQTT server without TLS, and returns a value that indicates whether the connection is created successfully or not. More...
 
int TLSConnectNetwork (Network *n, const char *addr, const char *port, const char *ca_crt, size_t ca_crt_len, const char *client_crt, size_t client_crt_len, const char *client_key, size_t client_key_len, const char *client_pwd, size_t client_pwd_len)
 This function connects to a MQTT server with TLS, and returns a value that indicates whether the connection is create successfully or not. More...
 

Modules

 Struct
 

Function Documentation

int ConnectNetwork ( Network n,
char *  addr,
char *  port 
)

This function connects to the MQTT server without TLS, and returns a value that indicates whether the connection is created successfully or not.

Call NewNetwork() to initialize network structure before calling this function.

Parameters
[in]nis a pointer to the network structure.
[in]addris the server hostname or IP address.
[in]portis the server port.
See also
NewNetwork();
Returns
If the return value is 0, the connection is created successfully. If the return value is -1, then calling lwIP #socket() has failed. If the return value is -2, then calling lwIP #connect() has failed. Any other value indicates that calling lwIP #getaddrinfo() has failed.
void NewNetwork ( Network n)

This function initializes the network structure.

Parameters
[in]nis the network structure pointer. The user is responsible to allocate memory before calling this function. Call this function before ConnectNetwork() and TLSConnectNetwork().
See also
ConnectNetwork();
Returns
None
int TLSConnectNetwork ( Network n,
const char *  addr,
const char *  port,
const char *  ca_crt,
size_t  ca_crt_len,
const char *  client_crt,
size_t  client_crt_len,
const char *  client_key,
size_t  client_key_len,
const char *  client_pwd,
size_t  client_pwd_len 
)

This function connects to a MQTT server with TLS, and returns a value that indicates whether the connection is create successfully or not.

Call NewNetwork() to initialize network structure before calling this function.

Parameters
[in]nis the the network structure pointer.
[in]addris the Server Host name or IP address.
[in]portis the Server Port.
[in]ca_crtis the Server's CA certification.
[in]ca_crt_lenis the length of Server's CA certification.
[in]client_crtis the client certification.
[in]client_crt_lenis the length of client certification.
[in]client_keyis the client key.
[in]client_key_lenis the length of client key.
[in]client_pwdis the password of client key.
[in]client_pwd_lenis the length of client key's password.
See also
NewNetwork();
Returns
If the return value is 0, the connection is created successfully. If the return value is -1, then calling lwIP #socket() has failed. If the return value is -2, then calling lwIP #connect() has failed. Any other value indicates that calling lwIP #getaddrinfo() has failed.