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


  • using a Rasperry Pi and nrf52 dongle

     But you have an nRF52 dongle connected to your RPi? Can you try to erase this one?

  • The dongle is connected to the MQTT broker, yes. But this works without any problem, the problem is not in the RPi broker. When running the openthread project on nrf52840 DK without freertos everything works. 

    The problem is when i try to implement FreeRTOS in the thread project on the development kit that I'm trying to connect to the thread network running on the RPi. 

    The code i attached to a previous comment explaining the problem, https://github.com/hunshamar/freertos_openthread,  I have two openthread programs that I can flash to the development kit, one using FreeRTOS which is not working, and one not using FreeRTOS that is working with openthread. 


  • Then what will happen if the RPi broker already have network data on the DK, that it assumes that the DK also has? Then the DK starts up without any stored network data. 

    Please give it a go. It is a matter of uploading the hex file from my earlier reply, and re-flashing it. Then let me know if it still behaves the same.

  • 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

Reply Children
Related