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