Import coreMQTT to Tiva

Dear All
I am looking for a MQTT client library to use with TI EK-TM4C1294XL board, I am new to FreeRTOS, anyone can provide some guide to me will be much appreciated, also noticed there is coreMQTT Agent library, not sure which one to use, any demo please?
Thank you in advance!
Ping

Hi @Ping!

The first thing you’re going to want to do is to get a basic demo running on your board. The board you’ve mentioned already has ports (non-MPU port and an MPU port). I’d start by getting a blinky/hello world type-demo working on your device. For more guidance on the CM4F chip you can refer to this page.

Once you have this demo working then expand to MQTT support. For a simple demo (or use case), I’d recommend starting with CoreMQTT. It doesn’t provide built in synchronization mechanisms like the CoreMQTT agent does but it’ll be simpler to work with. For CoreMQTT, you’ll need to implement a few interface functions (see doc) at which point you’ll be able to send MQTT messages to the endpoint of your choosing.

Thanks for reply, Kody

I browsed through, and couldn’t locate the basic demo on my board, is it like a CCS project or just I have to create my own project in CCS and then manually copy some source files in, if so, I probably need more detailed help on while file to use etc. I did try to import the VS demo, unfortunately, it doesn’t compile as my VS is v2022, while the demo requires v2019, the error message says so. Sorry, I am new to all freeRTOS and really need some help to get me started.

Thanks for your patience.
Ping

Do you have a CCS project for your board? I’d suggest to start with a demo from your vendor and then do the following:

  1. Add FreeRTOS and get it working. If your vendor provided project already has FreeRTOS, you do not need this step.
  2. Add the TCP stack (FreeRTOS-Plus-TCP is a good option) and get it working. Again, if the vendor provided project already includes TCP, you do not need this step.
  3. Add coreMQTT and get the plaintext MQTT working. You can refer to this demo.
  4. Add TLS and get the mutually authenticated MQTT working to connect to AWS IoT.
1 Like

Thank you for advice, will try.
Ping

Great. Let us know if you face any problem!

Hi, aggarg:
I have a question regarding FreeRTOS_Plus-TCP library, I am intended to let it work with Tiva1294MCU, does this mean if I use FreeRTOS_Plus_TCP library, I don’t t need to use lwip1.4.1 library provided by TI Tivaware? Do I have to use this when I use freeRTOS? wonder whether there is any demo for use this on Tiva like getting an DHCP IP address etc?

I have been using lwip1.4.1 on bare metal so far, and wat to migrate to freeRTOS.

Regards!
Ping

FreeRTOS-Plus-TCP and LWIP both are TCP stack and you need one of them.

If you want a TCP stack for network connectivity, then you need a TCP stack (either FreeRTOS-Plus-TCP or LWIP). You can use FreeRTOS kernel without a TCP stack too but you wont be able to connect to network without a TCP stack.

Thank you quick reply, Gaurav,
I need to use network connectivity with freeRTOS , as it is the base for coreMQTT, so I might need to use freeRTOS_Plus_TCP library instead of LWIP, is that right?
just wonder whether there is demo for freeRTOS_Plus_TCP with TIva CCS.

Regards!
Ping

As I said before, you can choose to use whichever TCP stack you want to use. coreMQTT does not have a direct dependency on a TCP stack and will work with any TCP stack.

No that I am aware of.

Hello, Gaurav
Started to try with the Windows Simulator Project, followed instructions so far and have got some logs as below - not really sure what is going on, please advise.

Thank you
Ping

Further found it hangs in prvSimulatedPeripheralTimer() function and configASSERT(xPortRunning);, the value of xPortRunning=1.

Regards!
Ping

Hi @Ping

For a DNS lookup, it is important to set the following config items:

#define	ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS    pdMS_TO_TICKS( 2500U )
#define	ipconfigDNS_SEND_BLOCK_TIME_TICKS       pdMS_TO_TICKS( 2500U )

This example puts them to 2.5 seconds, but you may choose a longer period.

If these values are not defined , the default values are :

#define	ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS    pdMS_TO_TICKS( 5000U )
#define	ipconfigDNS_SEND_BLOCK_TIME_TICKS       pdMS_TO_TICKS( 500U )

You can also look at this topic for more reference.

Hi, Rahul
Thanks for reply!
Don’t think I am using DNS lookup, i defined
#define democonfigMQTT_BROKER_ENDPOINT “10.0.1.37”
Anyway, added those two lines in FreeRTOSIPConfig.h, and still not working afterwards, details below:

Regards!
Ping
It seems failed at Assert()

If you can capture network traffic that would be very useful to find out the cause of connection failure.

The TCP connection is failing - is there a server running on “10.0.1.37”? Are you able to connect to it using some other client?

Hey @Ping,

The broker that you are using, is it a locally running broker at “10.0.1.37”? Maybe you could try to connect with the public mosquitto broker first and see if that works. This will rule out the possibility of any issue with the configuration of the locally running broker. To connect with the mosquitto broker you just have to use:

#define democonfigMQTT_BROKER_ENDPOINT "test.mosquitto.org"

2 Likes

Hi, All
Thank all for your help, change the broker to public mosquitto works! 10.0.1.37 is my PC, and Mosquitto is running on it - shown on Services, I can connect to it with MQTT Explorer, and able to publish and receives message use command. I don’t quite understand this demo, is it try to connect to itself as a client? is it possible that client and server running on same network interface?

Regards!
Ping

In this demo, the Windows machine running the demo is the client , which uses the coreMQTT library to establish an MQTT connection . It can publish messages to topics and subscribe to receive messages.

The server you are using currently is a cloud-based MQTT broker that manages MQTT message routing. It listens for client connections on port 1883.

The client and server are currently NOT on the same network interface. They can be on the same LAN if using a local broker (e.g., Mosquitto running on a PC or Raspberry Pi).

Try connecting to it from a different machine on the same network. It may be that your firewall is blocking some traffic.