Joiner callback never being executed

Hi all,

I'm trying to integrate joiner into my project, here's my goal:

We will start a device as our commissioner, and while it is active, we will start the other devices as joiners such that they will handshake with the active commissioner and obtain the network parameters. Then we can enable them in the joiner callback function on success (currently not added in the code below, as I simply only want to see the outputs of the joiner callback function).

Currently, the workflow in my main.c goes like: otInstanceInitSingle -> otIp6SetEnabled -> start_joiner.

The problem is, I don't think the callback function was ever executed, as no outputs are shown, and the joiner is always stuck in the Discover state. 

When I simply flash the CLI sample into 2 devices, commissioning works via the command line inputs:

  • Start device A with new dataset, wait until it is leader, then start commissioner and add joiner (wildcard) with PSKd J01NME
  • Start device B, factory reset, ot ifconfig up, ot joiner start J01NME
  • Then the join is successful and I get the command line outputs. 

However, using my current program approach:

  • Flash CLI sample into device A, start it as usual, start as commissioner (same as the CLI approach) 
  • Flash a modified CLI sample code (shown below, implemented callback and start_joiner) onto device B
  • Check commissioner state of device A, verify that it is active
  • ot factoryreset on device B to reboot it, and it should start joiner with the defined PSKd.
  • No further logs are displayed, after time limit reaches for commissioner, it will output Commissioner: Joiner remove.

The logs and implementation of start_joiner and joiner_callback are shown below, the left terminal is the commissioner, and the right terminal is the joiner. 

How could it be that the joiner_callback was never called? The joiner is also stuck in the Discover state forever, even after the commissioner has expired. No errors were given.

I am experimenting on two 54L15DKs, with SDK v2.9.1. I would appreciate any help on this, thanks. 

Best regards,

Allan 

Parents Reply Children
  • Hi Maria,

    My device A acts as the commissioner, and it is controlled through the command line. The CLI sample code was flashed, and I have only modified its prj.conf file (full file below, the bottom parts were added on by me). 

    # Network shell
    CONFIG_SHELL=y
    CONFIG_OPENTHREAD_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    # Increase Settings storage size
    CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x8000
    
    # Enable OpenThread features set
    CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y
    
    CONFIG_NET_L2_OPENTHREAD=y
    
    # Generic networking options
    CONFIG_NETWORKING=y
    
    CONFIG_GPIO_SHELL=y
    
    
    CONFIG_SETTINGS_ZMS=y
    CONFIG_ZMS=y
    CONFIG_NVS=n
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_SPI_NOR=n
    
    CONFIG_NRFX_POWER=y
    CONFIG_SOC_NRF_FORCE_CONSTLAT=y

    My device B acts as the joiner, here is main.c and its prj.conf file. This was also built on top of the CLI sample code.

    /*
     * Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
     #include <zephyr/kernel.h>
     #include <zephyr/logging/log.h>
     #include <openthread/thread.h>
     #include <openthread/joiner.h>
     #include <openthread/instance.h>
     #include <openthread/ip6.h>
     
     #include <zephyr/drivers/uart.h>
     #include <zephyr/usb/usb_device.h>
     
     #include "main.h"
     
     LOG_MODULE_REGISTER(cli_sample, CONFIG_OT_COMMAND_LINE_INTERFACE_LOG_LEVEL);
     
     
     #define JOINER_RETRY_DELAY_MS 5000
     #define JOINER_PSKD "J01NME"
     
     static otInstance *ot_instance;
     
     // Callback for joiner completion
     void joiner_callback(otError error, void *context)
     {
         if (error == OT_ERROR_NONE) {
             printk("Joiner successfully joined the network.\n");
         } else {
             printk("Joiner failed to join the network: %d\n", error);
         }
     }
     
     // Start the joiner process
     void start_joiner(void)
     {
         otError error = otJoinerStart(ot_instance, JOINER_PSKD, NULL, NULL, NULL, NULL, NULL, joiner_callback, NULL);
         if (error == OT_ERROR_NONE) {
             printk("Joiner started successfully.\n");
         } else {
             printk("Failed to start joiner, retrying in %d ms...\n", JOINER_RETRY_DELAY_MS);
             // Retry after a delay if joiner fails to start
             k_sleep(K_MSEC(JOINER_RETRY_DELAY_MS));
             start_joiner();
         }
     }
     
     int main(void)
     {
         ot_instance = otInstanceInitSingle();
         if (ot_instance == NULL) {
             printk("Failed to initialize OpenThread instance.\n");
             return 0;
         }
     
         otError error = otIp6SetEnabled(ot_instance, true);
         if (error != OT_ERROR_NONE) {
             printk("Failed to enable IPv6: %d\n", error);
             return 0;
         }
     
         // Start the joiner process
         start_joiner();
     
         while (1) {
             k_sleep(K_MSEC(1000));
         }
     
     
         return 0;
     }
     

    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Network shell
    CONFIG_SHELL=y
    CONFIG_OPENTHREAD_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    # Enable OpenThread features set
    CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y
    
    CONFIG_NET_L2_OPENTHREAD=y
    
    # Generic networking options
    CONFIG_NETWORKING=y
    
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y
    
    CONFIG_GPIO_SHELL=y
    
    #THREAD CONFIGS
    CONFIG_OPENTHREAD_COMMISSIONER=n
    CONFIG_OPENTHREAD_JOINER=y
    CONFIG_OPENTHREAD_FTD=y
    
    #RTT CONFIG (Turn off if uart is on)
    CONFIG_LOG=y
    # CONFIG_USE_SEGGER_RTT=y
    # CONFIG_RTT_CONSOLE=y
    # CONFIG_SHELL_BACKEND_RTT=y
    
    #UART CONFIGS FOR RECEIVING COMMANDS (Turn off if rtt is on)
    # CONFIG_LOG=y
    # CONFIG_SERIAL=y
    # CONFIG_UART_CONSOLE=y
    # CONFIG_SHELL=y
    # CONFIG_SHELL_BACKEND_SERIAL=y
    
    CONFIG_OPENTHREAD_OPERATIONAL_DATASET_AUTO_INIT=n
    

    I hope this helps with your reconstruction, was using two nRF54L15 dks for this job. 

    Best regards,

    Allan Wang

Related