Thread Joiner cannot find commissioner network

Hi all,

I have one program that starts and sets up a commissioner and another that starts a joiner and tries to join the commissioner's network. However, after starting the commissioner and calling otJoinerStart through Openthread's API, the joiner gives error 23 (not found) indicating that it can't find the network. 

I have set the network key, PAN ID, extPAN ID, and channel so I'm not sure where I went wrong.

Here are some basic logs of this error occurring.

On commissioner: 

<info> app: Device joined the Thread network.
<info> app: Commissioner state: Petitioning
<info> app: Commissioner started successfully.
<info> app: Commissioner state: Active
<info> app: Joiner added successfully, awaiting joiner devices.
<info> app: State changed! Flags: 0x00800201 Current role: 4


On Joiner:

<info> app: State changed! 0
<info> app: Joiner failed to join: 23
<info> app: State changed! Flags: 0x0800000B Current role: 0

Please not that the joiner device is not yet attached to a network and will do so after discovering the existing network started by the commissioner.

Thanks,
Glen

Parents Reply Children
  • Hi Marte,

    Can you also share how you call the commissioner and joiner functions?

     


    For the commissioner I am starting it when the device state changes and when it attaches to a network I call otCommissionerStart:

    void add_joiner(otInstance *aInstance)
    {
        otError error = otCommissionerAddJoiner(aInstance, NULL, JOINER_PSKD, JOINER_TIMEOUT);
        if (error == OT_ERROR_NONE) {
            NRF_LOG_INFO("Joiner added successfully, awaiting joiner devices.");
        }
        else {
            NRF_LOG_INFO("Failed to add joiner: %d", error);
        }
    }
    
    
    void commissionerStateCallback(otCommissionerState aState, void *aContext)
    {
        // Check the state and perform necessary actions
        switch (aState)
        {
        case OT_COMMISSIONER_STATE_DISABLED:
            NRF_LOG_INFO("Commissioner state: Disabled");
            break;
    
        case OT_COMMISSIONER_STATE_PETITION:
            NRF_LOG_INFO("Commissioner state: Petitioning");
            break;
    
        case OT_COMMISSIONER_STATE_ACTIVE:
            NRF_LOG_INFO("Commissioner state: Active");
            // Add joiners again if necessary
            add_joiner(thread_ot_instance_get());
            break;
    
        default:
            break;
        }
    }
    
    static void thread_state_changed_callback(uint32_t flags, void * p_context)
    {
        otDeviceRole role = otThreadGetDeviceRole(p_context);
        NRF_LOG_INFO("State changed! Flags: 0x%08x Current role: %d\r\n",
                     flags, role);
                     
        otInstance *p_instance = (otInstance *)p_context;
    
        // Check the role of the device in the network
        if (role == OT_DEVICE_ROLE_CHILD ||
            role == OT_DEVICE_ROLE_ROUTER ||
            role == OT_DEVICE_ROLE_LEADER)
        {
            NRF_LOG_INFO("Device joined the Thread network.");
    
            // Start the Commissioner if the device has joined the network
            otError error = otCommissionerStart(p_instance, commissionerStateCallback, joinerStateCallback, NULL);
            if (error == OT_ERROR_NONE)
            {
                NRF_LOG_INFO("Commissioner started successfully.");
            }
            else
            {
                NRF_LOG_INFO("Failed to start Commissioner: %d", error);
            }
        }
        else
        {
            NRF_LOG_INFO("Device not yet in a valid role. Waiting...");
        }
    }



    And as for the joiner I do the following call:

    void joiner_callback(otError aError, void *aContext)
    {
        if (aError == OT_ERROR_NONE)
        {
            // Joiner has successfully joined the network
            NRF_LOG_INFO("Joiner successfully joined the network.");
            ///* Start the Thread stack (CLI cmd > thread start) */
            //otThreadSetEnabled(thread_ot_instance_get(), true);
      
        }
        else
        {
            // Joining failed
            NRF_LOG_INFO("Joiner failed to join: %d", aError);
        }
    }
    
    void joiner_start() {
    
       otJoinerStart(thread_ot_instance_get(), my_pskd, NULL, NULL, NULL, NULL, NULL, joiner_callback, NULL);
    
    }


    was able to use wildcard when using the CLI commands, so that should work. Can you collect a sniffer log of when the device tries to join? If you have an additional nRF52840 DK or dongle, you can use our nRF Sniffer for 802.15.4.


    I'll need to get my hands on another DK board and I'll get back to you with the logs.

    Best,
    Glen

  • Hi Glen,

    Thank you for sharing the code. I will look at it and get back to you tomorrow.

    Best regards,
    Marte

  • Hi Glen,

    It seems like the issue is that you are not bringing up the IPv6 interface before starting the joiner. You can bring it up by calling otIp6SetEnabled(). This is the same as the ifconfig up CLI command. Please try calling it before calling otJoinerStart().

    Best regards,
    Marte

  • Hi Marte,

    Sorry I forgot to include that in my code but I do call that in another function when initializing my network. Same goes with the commissioner. This shouldn't be the problem. Additionally the commissioner calls OtThreadSetEnabled() to attach to a thread network before calling otCommissionerStart().

    Best,
    Glen

  • Also here's some logs I manage to get from the nrf sniffer. I'm not sure what data I should be looking at so I just put everything in this file. 

    Commissioner logs..pcapng

Related