NCS 2.4.1
nRF52840
My project is a battery powered SED based on the coap_client example. It is configured to autojoin using a hard coded pksd. I see on Wireshark that my device sends one Discovery Request when it starts up (if it is not already commissioned). I am testing a situation where there is no commissioner. The device should try to join, but then go to sleep after 5 minutes until awakened by the user which will cause a reboot.
I need it to go into a low power mode once the joiner times out. It does not. I see on the Power Profiler that the current is ~6mA after 5 minutes. I tried to change the link mode to set mRxOnWhenIdle to false, but the current remained high.
What is the timeout for joining when using autojoin?
Is it possible to re-try joining multiple times before giving up?
How can I force it to go into a low power sleep? Disable Thread?
prj.conf
# Thread Joiner CONFIG_OPENTHREAD_JOINER=y CONFIG_OPENTHREAD_JOINER_AUTOSTART=y CONFIG_OPENTHREAD_JOINER_PSKD="J01NUS" CONFIG_OPENTHREAD_MANUAL_START=n
main.c
int wait = 0; while(otDatasetGetActive(instance, &dataset) != OT_ERROR_NONE) { wait++; if (wait < 60) // 5 sec x 60 = 5 min { // wait for joining to complete, blink LED up to 5 minutes set_led(COLOR_PURPLE); // blink purple, 5 sec k_msleep(100); set_led(COLOR_OFF); k_msleep(4900); } else if (wait > (12 * 60)) // 5 sec x 12 x 60 = 60 min, reboot in an hour { LOG_INF("Active Dataset not found. Rebooting\r\n"); g_reboot = true; } else { otError error; otLinkModeConfig mode; struct openthread_context *context = openthread_get_default_context(); __ASSERT_NO_MSG(context != NULL); openthread_api_mutex_lock(context); mode = otThreadGetLinkMode(context->instance); if (mode.mRxOnWhenIdle) // disable receiver { mode.mRxOnWhenIdle = false; error = otThreadSetLinkMode(context->instance, mode); } openthread_api_mutex_unlock(context); k_msleep(5000); } if (g_reboot) k_work_submit(&reboot_work); }
Thanks,
Mary