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

Feasibility of Running Thread NCP concurrently with other Thread Functions

I am looking for some advice before diving in to what could be a big waste of time.  In my existing Thread implementation, I use nRF52840's in two different configurations:

  • Config 1 - Connected to Raspberry Pi and running Nordic's NCP implementation (a Border Router)
  • Config 2 - End device nodes which form a Thread mesh network, generate data (let's say temperature, for example), and route that data using CoAP to my cloud using the NCP/Border router

I would like to merge the functionality of these two configurations so that my Border Router's nRF52840 continues to operate in NCP mode but can also generate and send its own CoAP messages (say the temperature near the Border Router, for example) to the cloud.  This approach is preferred over having the rPi generate these messages because the board containing the nRF52840 includes the actual sensors I am using (which is more involved than temperature).

Looking at the NCP example code below, it looks like the otNcpInit() function is passed an ot_instance: 

static void thread_ncp_init(void)
{
    PlatformInit(0, NULL);

    m_app.p_ot_instance = otInstanceInitSingle();
    ASSERT(m_app.p_ot_instance);

    otNcpInit(m_app.p_ot_instance);

    otThreadSetRouterSelectionJitter(m_app.p_ot_instance, ROUTER_SELECTION_JITTER);

    uint32_t err_code = bsp_thread_init(m_app.p_ot_instance);
    APP_ERROR_CHECK(err_code);
}

To me, this implies that I could have multiple ot_instances running, and allocate one to NCP and one for CoAP.   I see the function otInstanceInit() which allows initialization of multiple OpenThread instances, but I haven't found any Thread examples that use multiple instances.

Question:  Am I on the right track?  Is there another way for me to approach the problem?  Can the nRF52840 support multiple instances?  Are there any multi-instance Thread examples that I missed?

Assuming multiple instances are the right approach, I'm a little fuzzy on how data sent on the CoAP OpenThread instance will make its way to the NCP OpenThread instance and out to the internet.

Thanks,
Rob

Related