This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Openthread with FreeRTOS

Hi!
I've successfully set op an OpenThread MQTT broker using a Rasperry Pi and nrf52 dongle and I am able to publish and subscribe to and from my computer by flashing the mqttsn_client_subscriber and mqttsn_client_publisher examples to my nrf52840 DK.

I want to incorporate thread communication into a larger project on the nrf52840 DK using FreeRTOS. My first step has been trying to modify the mqttsn_client_subscriber example to incorporate FreeRTOS. However I have not had much success.

Does the SDK provide examples of OpenThread with FreeRTOS or are there other sources I can consult?






Parents
  • Hello,

    There is one example that uses the openthread stack and FreeRTOS:

    SDK_for_Thread_and_Zigbee_4.1.0\examples\thread\freertos_coap_server

    Perhaps you can use this example for reference.

    Best regards,

    Edvin

  • Hi!
    I've tried this unsuccessfully.

    I modified the mqttsn_client_subscriber example some, making it connect to the broker and subscribe to topic automatically, not using the buttons.
    This solution works well. 



    However when i try to implement the same solution in FreeRTOS, using the freertos_coap_server as a reference, it doesn't work. The program does not connect to the gateway etc. 


    There seems to be an issue with running the mqttsn_evt_handler, perhaps this is related to using the app_scheduler in the program? I am not sure, but the events are not triggered. 

    Here is my code: https://github.com/hunshamar/freertos_openthread

    Do you have any suggestions for making this work? I am not too experienced with FreeRTOS or the nordic SDK, so any help would be appreciated. 

    -Asgeir


  • I gave this a try, but unfortunately it did not work. I even tried a brand new nrf52 dongle.
    The problem seems to be with the FreeRTOS program. I tried adding another task that only toggles an LED on the board, and this one freezes as well. The problem seems to be with the mqqtsn_client_search_gateway() function that is run at the start of the program.

    When i exclude this piece of code at least the led blinking tasks runs normally. But if I run this function the program seems to halt. 

    Also if I just comment out all the FreeRTOS -stuff and run the openthread-task as a while-loop it works. So there seems to be some conflict with FreeRTOS and the mqtt event handler or something similar.  

  • Ok. Thank you for checking. Can you please zip your project (preferably the one that also toggles the led, which also freezes) here, so that I can try to recreate it on my DK.

    Best regards,

    Edvin

  • I uploaded it to github,  https://github.com/hunshamar/freertos_openthread, which can also be downloaded as a zip. But do you want the full SDK folder with the project zipped? 

    -Asgeir

  • I saw that repo, but which of the projects is it? And what IDE did you use to set up the project? I tried the freertos_coap_server\pca10056\blank\ses and armgcc, but none of them compiled in an unmodified SDK2.0.0. Where should I place the project file, and what IDE do you use? Please make sure that it compiles in an unmodified SDK.

    SDK2.0.0 is a bit old, so you can consider to move to SDK4.1.0, but we can look into it in the SDK2.0.0 first.

    BR,

    Edvin

  • The projects are explained in the readme. The "freertos_coap_server" is the freertos openthread mqtt program. 

    I am able to compile it in an unmodified SDK2.0.0. I tried downloading a new SDK now and tested it. I copied the files from the github repo into SDK/examples-folder. I used VS code to modify the code, but to compile it i ran the makefile in pca/10056/blank/armgcc using a terminal. You can see where i placed the project files in the picture. Does this not work for you?

    Kind regards, Asgeir. 





Reply
  • The projects are explained in the readme. The "freertos_coap_server" is the freertos openthread mqtt program. 

    I am able to compile it in an unmodified SDK2.0.0. I tried downloading a new SDK now and tested it. I copied the files from the github repo into SDK/examples-folder. I used VS code to modify the code, but to compile it i ran the makefile in pca/10056/blank/armgcc using a terminal. You can see where i placed the project files in the picture. Does this not work for you?

    Kind regards, Asgeir. 





Children
Related