MQTT Lightweight

Hello,

I am able to successfully run the lightweight example.

However, I am trying to understand MQTT and I wanted to know that is it possible for us to separate out the MQTT functionality and the Network Interface, I understand functions such as FREERTOS_Socket is used to create a socket and so on but…what actually goes on behind the scenes for this function?

I specifically want to see how the Transport Layer comes into play in the code?

I did try using the code graph extension of Visual Studio but I did not understand much

Any suggestions where I can start?

Hi,

Thank you for trying out the demo! You are definitely on the right track - FreeRTOS_socket returns a descriptor to a TCP socket. The descriptor is then passed as a parameter to FreeRTOS_connect in order to establish the connection. The Transport Layer comes into play through the FreeRTOS+TCP stack that defines this set of functions.

If you would like more insight into how these API functions work behind the scenes, please see the FreeRTOS+TCP API Reference.

1 Like

Just to add to the above, the transport layer decouples the MQTT from the underlying network. The first transport layer published uses the FreeRTOS+TCP stack, so is making FreeRTOS+TCP API calls, which are based on Berkeley sockets calls.

2 Likes

Suppose I want to separate out the Network Abstraction and under this abstraction I want to run my HTTP as well as MQTT. Since HTTP does not have a lightweight example, it looks much more complicated to separate out the networking part as compared to MQTT Lightweight.

What would be a right way to proceed?

Hello mgb17,

Thanks for reaching out. We are working on the redesigned HTTP library, where you can separate out transport / networking implementation easily. We do have a few working demos and the library currently available in development branch of our embedded C-SDK repository :
Library: https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/development/libraries/standard/http
Demos: https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/development/demos/http
Please remember that although the library is functional , it is still work in progress and therefore it is light on documentation. The API may change, although I don’t anticipate any major changes at this time.
Please let us know if you have any more questions.
Thanks !
Note: This library will be eventually available on FreeRTOS website, but for now, you should able easily replace networking implementation to use FreeRTOS+TCP just like MQTT. Thanks.

1 Like

I also want to add that there is an MQTT LTS rc1 demo with a Managed API that separates out the Network Abstraction.

1 Like

Yes, I saw the mqtt lightweight and how it separates the Network Abstraction and was able to run it, so can we use the same network abstraction for HTTP? since both of them are working on TCP?

That is the intent.

[need to write more characters to be able to post my reply - ignore this]