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
  • Hi Glen,

    Have you added the Joiner entry with the device-specific pre-shared key (PSKd) on the commissioner? You can do so using otCommissionerAddJoiner() or otCommissionerAddJoinerWithDiscerner().
    OpenThread CLI - Commissioning shows how to commission using joiner with CLI commands. You can find implementations of the CLI commands and, therefore, which functions are used and how they are used in modules/lib/openthread/src/cli/cli_commissioner.cpp and modules/lib/openthread/src/cli/cli_joiner.cpp. You can also find more information about the commissioning process in our documentation OpenThread commissioning.

    Best regards,
    Marte

  • Hi Marte,

    Yes I have assigned the same PSKd for both devices when starting the commissioner and starting the Joiner device. I must add that I am not using the eui64 of the joiner devices when starting the commissioner and that I allow any joiner device to join by using the wildcard.

    Thanks,
    Glen

  • Hi Glen,

    I 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.

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

    Best regards,
    Marte

  • 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

Reply Children
Related