How does the device receive messages from the parent node when it goes into low power?

Hi, the nordic team

I am working on thread protocol using SDK version 2.9.1. 

I use the SED device,My poll is 1000 ms. How can I receive messages from my parent node when my SED device goes into low power?

Here is my code to get into low power:

 int main(void)
 {
        if (IS_ENABLED(CONFIG_RAM_POWER_DOWN_LIBRARY)) {
		power_down_unused_ram();
	}

        int err;

        k_timer_init(&led_timer, on_led_timer_expiry, on_led_timer_stop);
	k_timer_init(&provisioning_timer, on_provisioning_timer_expiry, NULL);

	k_work_queue_init(&coap_server_workq);
	k_work_queue_start(&coap_server_workq, coap_server_workq_stack_area,
					K_THREAD_STACK_SIZEOF(coap_server_workq_stack_area),
					COAP_SERVER_WORKQ_PRIORITY, NULL);
	k_work_init(&provisioning_work, activate_provisioning);

        if (IS_ENABLED(CONFIG_OPENTHREAD_MTD_SED)) {
		k_work_init(&poll_change_work,
                        into_low_power_sleeply);
	}

        err = ot_coap_init(&deactivate_provisionig, &on_light_request);
        if (err) {
		LOG_ERR("Could not initialize OpenThread CoAP");
		goto end;
	}
         
        err = dk_leds_init();
        if (err) {
                LOG_ERR("Cannot init LEDs (err: %d)", err);
                goto end;
        }

        err = dk_buttons_init(button_pressed_callback);
        if (err)
        {
                LOG_ERR("Cannot init buttons (err: %d)", err);
                goto end;
        }
        
            // 点亮 LED1
        dk_set_led_on(OT_CONNECTION_LED);
        err = restore_network_data();
end:
        return 0;
         
 }
 
 //改变poll时间,进入低功耗
static void into_low_power_sleeply(struct k_work *item)
{
        ARG_UNUSED(item);

        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);
	mode.mRxOnWhenIdle = false;
	error = otThreadSetLinkMode(context->instance, mode);
        otLinkSetPollPeriod(context->instance, OT_POLL_PERIOD);
	openthread_api_mutex_unlock(context);

	if (error != OT_ERROR_NONE) {
		LOG_ERR("Failed to set MLE link mode configuration");
	}

#if IS_ENABLED(CONFIG_PM_DEVICE)
	const struct device *cons = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));

	if (!device_is_ready(cons)) {
		return;
	}

        pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
#endif

        dk_set_led_off(OT_CONNECTION_LED);
        dk_set_led_off(PROVISIONING_LED);
        dk_set_led_off(LIGHT_LED);
}

Parents Reply Children
  • Hi!

    Amanda is out of office, so I'm replying instead.

    liisa said:
    "send commands" is the leader send "coap get   + ipv6 address  + /lock/state".the "process" is the SED receive the "send commands" to return the lock's state.I mean, it doesn't feel like the SED device is going to automatically fetch the parent  {"Data Poll" to its parent, and retrieves any buffered frames}.

    It is automatic process - the SED device needs to be configured with given Polling Interval (e.g. 2 seconds). Internally OpenThread stack will wake up every e.g. 2 seconds and fetch the data from the parent. There is no need for application to do specific things. Of course, application needs to register proper application callbacks for CoAP or UDP Sockets to get notification about reception of IPv6 application packet.

    You may try to increase log's verbosity and maybe sniff frames.

    CONFIG_OPENTHREAD_SOURCES=y
    CONFIG_OPENTHREAD_DEBUG=y
    CONFIG_OPENTHREAD_LOG_LEVEL_INFO=y
    CONFIG_OPENTHREAD_SHELL=y

  • Hi,

    Thank you for your reply,I will try.

    this is my config in prj.config:

    #
    # Copyright (c) 2024 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Increase Settings storage size
    CONFIG_PM_PARTITION_SIZE_SETTINGS_STORAGE=0x8000
    
    
    # Enable OpenThread CoAP support API
    CONFIG_OPENTHREAD_COAP=y
    CONFIG_COAP=y
    CONFIG_COAP_UTILS=y
    CONFIG_OPENTHREAD_COAP_OBSERVE=y
    
    # Network sockets
    CONFIG_NET_SOCKETS=y
    CONFIG_POSIX_API=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    
    # Enable OpenThread features set
    CONFIG_NET_L2_OPENTHREAD=y
    
    # Generic networking options
    CONFIG_NETWORKING=y
    
    CONFIG_OPENTHREAD_JOINER=y
    
    CONFIG_LOG=y
    
    CONFIG_DK_LIBRARY=y
    
    # Power Manager
    CONFIG_PM_DEVICE=y
    
    CONFIG_OPENTHREAD_MTD=y
    CONFIG_OPENTHREAD_MTD_SED=y
    
    CONFIG_OPENTHREAD_POLL_PERIOD=5000
    
    CONFIG_RAM_POWER_DOWN_LIBRARY=y
    
    #SHA
    CONFIG_MBEDTLS_SHA1_C=n

Related