MQTT data exchange
19.09.18 12:42

Hey everyone,

I have the following problem. I am receiving messages in the MQTT callback function. Depending on the message I want to set an integer to diverent numbers. This interger I want to use in the xdk fire loop.

I think I have to secure this acces from different threads with an mutex. My problem is that the normal C implementation of a mutex did not work. Do you have any idea whats my problem or is there an other approach to solve my problem?


0 (0 Stimmen)
RE: MQTT data exchange
20.09.18 07:45 als Antwort auf Lukas Dörr.
Hello Lukas,

To be sure I look into the same scenario:
You are going to implement a data exchange between the MQTT callback and the AppControllerFire task?

If this is the case, please note that you are only using two threads:
  • AppControllerFire, which is an operating task
  • AppCommandProcessor, which is an event queue, running in an additional task.
The implementation of a queue, which sends data between both tasks should be sufficient, instead of using a mutex.
For more information and a guideline about implementation of queues, I recommend to take a deeper view at the queue article in the XDK Knowledgebase .

Otherwise, if you depend on a mutex, there also might be a solution available within the interface BCDS_HAL_Mutex.h .
In the first attempt, this interface is designed for the use of HAL and BSP, but it should suit for your usecase, too.

You can find this interface by navigating through the following folder path:

SDK > xdk110 > Platform > Essentials > include

Please let me know if that was helpful and feel free to ask if you have further questions.

Kind regards,
0 (0 Stimmen)