Commissioner not responding to join request

nrf52840

NCS 1.9.1

We have a Thread project based on the Coap Client and Server example.  The Coap server acts as the Commissioner, and other devices join using a known pskd.  Sometimes this works fine, but after the server has been running a while (overnght) it does not respond to the join request.

A button press on the server allows joining:

static void on_button_changed(uint32_t button_state, uint32_t has_changed)
{
	uint32_t pressed = button_state & has_changed;
	uint32_t released = ~button_state & has_changed;

	// Button 1:  
	if (pressed & DK_BTN1_MSK) 
	{
		k_work_submit(&joining_work);		// calls activate_joining()
	}
}

// Called in workqueue joining_work
static void activate_joining(struct k_work *item)
{
	ARG_UNUSED(item);

	struct openthread_context *ot_context = openthread_get_default_context();
	otError err;

	otInstance *instance = ot_context->instance;

	otCommissionerState state;
	if ((state = otCommissionerGetState(instance)) == OT_COMMISSIONER_STATE_ACTIVE)
	{
		err = otCommissionerAddJoiner(instance, NULL, pskd, JOINER_TIMEOUT); 
		if (err != OT_ERROR_NONE)
		{
			printk("\r\notCommissionerAddJoiner() failed [%d]\r\n", err);
		}
		else
		{
			//k_timer_start(&led_timer, K_MSEC(100), K_MSEC(100));
			g_joining_allowed = true;

			printk("\r\nCommissioner joiner started for %d seconds...\r\n", JOINER_TIMEOUT);
		}
	}
	else
	{
		printk("\r\nCommissioner state = %d. Restarting...", state);

		err = otCommissionerStart(ot_context->instance, commissioner_state_cb, commissioner_joiner_cb, ot_context);
		if (err != OT_ERROR_NONE)
			printk("otCommissionerStart() failed [%d]\r\n", err);
		else
			start_joiner = true;		// trigger AddJoiner when "commissioner active" happens
	}
}

This happens successfully all the time.  I see the message "Commissioner joiner started for 120 seconds..." every time.

The Coap client uses auto joining by setting these configuration parameters.

# Thread Joiner
CONFIG_OPENTHREAD_JOINER=y
CONFIG_OPENTHREAD_JOINER_AUTOSTART=y
CONFIG_OPENTHREAD_JOINER_PSKD="J01NUS"
CONFIG_OPENTHREAD_MANUAL_START=n
On WireShark I can see the Discovery Request with "Joiner Flag: Intending" but there is no response from the Coap Server.  At the same time I have a device that is broadcasting Discovery Requests (without the joining flag set).  The Coap Server responds to these.  And also responds to requests for router information (otThreadGetRouterInfo() ) with this
--- Router fd70:a900:acc1:3d9f:0:ff:fe00:9000 ----

Ext Address: 0xfb58ff0e
Rloc16: 0x9000
IP6 Address List:
- fd70:a900:acc1:3d9f:0:ff:fe00:fc37    Commissioner
- fd70:a900:acc1:3d9f:0:ff:fe00:fc00    Leader
- fd70:a900:acc1:3d9f:0:ff:fe00:9000
- fd70:a900:acc1:3d9f:355e:d60e:5def:e87b    Coap Server
- fe80:0:0:0:cff:58fb:cdf3:6c77

So, the Coap Server is the Commissioner, and joining is allowed.  So, why isn't it responding to the joiner's request?

Why does this work sometimes and but not always?

Where can I look to diagnose this?

Mary

Related