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

Thread device to automatically start commissioning when it starts

Hi All, 

  If I want a Thread device to automatically start commissioning when it starts, is there a code example in Nordic SDK?
  Now I just found the API interface, called otJoinerStart, which also returned OK, but never got to the callback function.
  Really appreciate any help you can provide. 
  Best, 
  Tao
  • Hello Tao,

    What SDK version do you use?

    Regardless you can check out the simple_coap_server and simple_coap_client examples, which will form a network. In the nRF5 SDK for Thread and Zigbee, it uses thread_instance_init() in main.c with .autocommissioning = true.

    If that is not what you are looking for, please let me know.

    Best regards,

    Edvin

  • Hello Edvin,

    The SDK version is "nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8".

    I am going to use OTBR to form a Thread network with the Thread device by commssioning. So if I use the method thread_instance_init() in main.c with .autocommissioning = true on the Thread device, where should I set pskd?

    The process I want to implement is that I run the command on the OTBR.
    ot-ctl commissioner start
    ot-ctl commissioner joiner add eui64 pskd.
    Then let the Thread device boot up and commissioning will be done automatically.

    Best,
    Tao

  • Try using otThreadSetPskc(). Description from thread_ftd.h:

    /**
     * Set the Thread PSKc
     *
     * This function will only succeed when Thread protocols are disabled.  A successful
     * call to this function will also invalidate the Active and Pending Operational Datasets in
     * non-volatile memory.
     *
     * @param[in]  aInstance   A pointer to an OpenThread instance.
     * @param[in]  aPskc       A pointer to the new Thread PSKc.
     *
     * @retval OT_ERROR_NONE           Successfully set the Thread PSKc.
     * @retval OT_ERROR_INVALID_STATE  Thread protocols are enabled.
     *
     * @sa otThreadGetPskc
     *
     */
    otError otThreadSetPskc(otInstance *aInstance, const otPskc *aPskc);

    Does it work if you don't add the pre shared key?

    Try checking the OpenThread Border Router test description.

    BR,

    Edvin

Related