Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Including µC/MQTT-client Stack Source Code

...

\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
languagecpp
titleuC/MQTT-client Sample Application Code
linenumberstrue
#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(;);
    }
}