...
Including µC/MQTT-client Stack Source Code
As indicated in the , all All the files in the "Source" folder of the "Client" directory must be added to your project tree.
...
\Micrium\Software\uC-MQTT
...
Copy the files from the uC-MQTT-client configuration folder (uC-MQTT/Client/Cfg
) into your application as illustrated belowfolder.
Adding µC/MQTT-client Example Application Code
The code below presents a simple MQTT client application where the µC/MQTT-client suite is initialized before one connection is opened and one PUBLISH message is sent. Every API function call is non-blocking. Depending on the chosen example, this initialization call will also start publishing on a given topic, subscribe to a topic, do both, etc.
It is also assumed that all prerequisite modules have been initialized before calling the µC/MQTT-client example function.
The functions HTTPcAppfunction AppMQTTc_Init()
and HTTPcApp_ReqSendGet()
are example functions is an example function that can be retrieve in the Examples directory of µC/HTTP-client. Other example functions are present if you wishes to test other functionality as sending forms, open multiple connections are open a persistent connection.
/MQTT-client.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
#include "app_mqtt-c.h"
[...]
static void AppTaskStart (void *p_arg)
{
/* Initialize BSP */
/* Initialize CPU */
/* Initialize Memory */
/* Initialize TCP-IP */
/* Initialize DNSc if necessary */
success = AppMQTTc_Init();
if (success == DEF_FAIL) {
printf("Error with MQTTc Initialization.\n");
CPU_SW_EXCEPTION(;);
}
} |