# Porting code that uses coreMQTT to one that uses coreMQTT-Agent or vice versa?

**URL:** <https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864>\
**Category:** Libraries\
**Created:** [January 5, 2024, 8:01pm UTC](https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864 "2024-01-05T20:01:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IoT4Me](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@IoT4Me](https://forums.freertos.org/u/IoT4Me)\
**Post date:** [January 5, 2024, 8:01pm UTC](https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864/1 "2024-01-05T20:01:38Z")

</div>

I have example code that currently uses coreMQTT to connect to the AWS IoT shadow service. I want to add OTA code to it but the OTA library that the chip vendor provides uses coreMQTT-Agent instead. It seems I have to alter one or the other since I don’t have enough memory for 2 simultaneous TLS/MQTT connections. Do you have any advice about doing such a change (ease of which way, pitfalls, etc.)?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [January 8, 2024, 5:07am UTC](https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864/2 "2024-01-08T05:07:06Z")

</div>

In theory, it should be possible to do either. IMO, you can update your application first to use coreMQTT-Agent. That way you will be able to debug and test your changes without OTA. Once it works, you can then add OTA. Let us know if you face any problem along the way.

---

<div class="post-metadata">

**Author:** ![IoT4Me](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@IoT4Me](https://forums.freertos.org/u/IoT4Me)\
**Post date:** [January 8, 2024, 2:51pm UTC](https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864/3 "2024-01-08T14:51:34Z")

</div>

Thank you for the reply. Yes, I know it’s possible, I just wanted to know what’s involved (mutexes, contexts, etc.); but I understand this is deep stuff so not many people know about the differences between the two. I guess I’ll just dig into it.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [January 9, 2024, 5:44am UTC](https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864/4 "2024-01-09T05:44:24Z")

</div>

> [@IoT4Me](#):
>
> I just wanted to know what’s involved (mutexes, contexts, etc.);

You can refer these coreMQTT-Agent examples - [GitHub - FreeRTOS/coreMQTT-Agent-Demos: Demonstrates use of coreMQTT-Agent for simple MQTT connection sharing among different threads of execution.](https://github.com/FreeRTOS/coreMQTT-Agent-Demos). Feel free to create a post here if you face any problem.

---

<div class="post-metadata">

**Author:** ![IoT4Me](https://avatars.discourse-cdn.com/v4/letter/i/b9e5f3/32.png) [@IoT4Me](https://forums.freertos.org/u/IoT4Me)\
**Post date:** [January 9, 2024, 1:57pm UTC](https://forums.freertos.org/t/porting-code-that-uses-coremqtt-to-one-that-uses-coremqtt-agent-or-vice-versa/18864/5 "2024-01-09T13:57:34Z")

</div>

Thank you; I’m already exploring that.
