Does any message-passing mechanism like mqtt?

I’m doing a project which run a FreeRTOS on a STM32 chip. It includes many components, I have to run many tasks(about 10~20 tasks). Any two of them may have to communicate with each other. So I create a queue for every task. But it makes this project very complicated. I have to create many queues and handle their communications with care. These queues take much RAM, I have to leave enough space for every queue although most of the time these queues are empty. I don’t want to use reference,because so many queues will make me overwhelmed.
So does FreeRTOS has some mechanism like mqtt? It means a task can just publish messages to a messages pool and it can also subscribe some messages it cared from this pool? It will make my job much easier.

Even to implement MQTT inside the program you still need a queue per task to receive the notifications. Then you need to add a MQTT ‘server’ task that takes the messages and distributes them.

You can reduce the memory requirements for the queues by just queuing a pointer to your messages, and have some resource keep track of if the message is still in use, or if it can be recycled.

One thing to look at is if you have partitioned you tasks correctly. Often that is the hardest part if the job, and when done wrong can make things much more difficult.

1 Like

My first thought is you need to simplify your design. Then if any two tasks really need to communicate with each other (I’ve never seen a design where that was the case) then you could implement a publish/subscribe style primitive using an array and an event group.

1 Like

OK, thank you, richard!

I have to admit this design is a mess. Before me , it has serveral developers, so …
While I have no interset in refactoring all the code, bu really intersted in implement something using publish/subscribe like MQTT. Thank you!