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

openThread and MQTT communication on a nrf52840DK

I would like to figure our how i can send MQTT packages over a Thread network using a nrf52840DK. And to begin with only between two nrf52840 devices.

I am using the nrf connect sdk and have been looking at the MQTT example for nrf9160 to see how MQTT is setup and i have been looking at the Thread coApp example but cannot figure out how the radio communication works.

I have not been able to find an example where MQTT is implemented ontop of a openThread network, is there any?

I thought i could take the MQTT example for nrf9160 and replace the LTE communication with openThread that the coApp example uses.

Parents
  • Hi.

     

    I have not been able to find an example where MQTT is implemented ontop of a openThread network, is there any?

     Unfortunatly not.

     

    I thought i could take the MQTT example for nrf9160 and replace the LTE communication with openThread that the coApp example uses.

     I work mostly with the nRF9160, so I am not very familiar with Thread, but I'll try to answer this as best I can.

    First, the mqtt_simple sample was built for the nRF9160, so you will find some nRF91-specific code there. But, it should not be a big problem to remove it, and replace it with the corresponding Thread code. In particular, the modem_configure() function must be replaced with the Thread code for setting up a connection.

    As far as I can see, there should not be any huge issues with replacing the LTE stack with the Thread stack. The MQTT library is built on a POSIX socket interface, which the Thread stack also seems to expose.

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/ug_thread_stack_architecture.html

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/ug_thread_ot_integration.html#overview

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/zephyr/reference/networking/sockets.html#bsd-sockets-interface

    So, as far as I can tell, except for the code responsible for establishing a connection (LTE or Thread), the sample should otherwise only need changes to prj.conf. A good place to start is probably to look at the coap_client Thread sample, and compare what options are set there versus in the mqtt_simple and coap_client samples for the nRF9160. You can remove the LTE link control, BSD library and AT Host related configuration options, as they are specific to the nRF91. The other big option you need to remove is the CONFIG_NET_SOCKETS_OFFLOAD, and set CONFIG_NET_NATIVE, as you want to use Zephyr's network stack.

    From there, you can start figuring out what options you need to bring over from the coap_client Thread sample.

    Best regards,

    Didrik

Reply
  • Hi.

     

    I have not been able to find an example where MQTT is implemented ontop of a openThread network, is there any?

     Unfortunatly not.

     

    I thought i could take the MQTT example for nrf9160 and replace the LTE communication with openThread that the coApp example uses.

     I work mostly with the nRF9160, so I am not very familiar with Thread, but I'll try to answer this as best I can.

    First, the mqtt_simple sample was built for the nRF9160, so you will find some nRF91-specific code there. But, it should not be a big problem to remove it, and replace it with the corresponding Thread code. In particular, the modem_configure() function must be replaced with the Thread code for setting up a connection.

    As far as I can see, there should not be any huge issues with replacing the LTE stack with the Thread stack. The MQTT library is built on a POSIX socket interface, which the Thread stack also seems to expose.

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/ug_thread_stack_architecture.html

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/nrf/ug_thread_ot_integration.html#overview

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.3.0/zephyr/reference/networking/sockets.html#bsd-sockets-interface

    So, as far as I can tell, except for the code responsible for establishing a connection (LTE or Thread), the sample should otherwise only need changes to prj.conf. A good place to start is probably to look at the coap_client Thread sample, and compare what options are set there versus in the mqtt_simple and coap_client samples for the nRF9160. You can remove the LTE link control, BSD library and AT Host related configuration options, as they are specific to the nRF91. The other big option you need to remove is the CONFIG_NET_SOCKETS_OFFLOAD, and set CONFIG_NET_NATIVE, as you want to use Zephyr's network stack.

    From there, you can start figuring out what options you need to bring over from the coap_client Thread sample.

    Best regards,

    Didrik

Children
No Data
Related