NCS CAF leds modules can not receive power down event?

Hi,

    I use CAF leds modules in NCS. After click the button and led lights for 3.6 seconds, I submit power down event when double click button. As show in the following figure, led modules can receive power down event and set leds state to off.

case CLICK_SHORT:
    send_led_event(LED_ID_BLUE, &m_led_effect[LED_EFFECT_ID_DEVICE_ON]);
    break;

case CLICK_DOUBLE: {
    struct power_down_event *event = new_power_down_event();

    event->error = false;
    EVENT_SUBMIT(event);
}
break;

    Another situation, I submit led event and power dowen event after long press the button, I find led modules can't receive power down event.

case CLICK_LONG: {
    send_led_event(LED_ID_RED, &m_led_effect[LED_EFFECT_ID_DEVICE_ON]);

    struct power_down_event *event = new_power_down_event();
    event->error = false;
    EVENT_SUBMIT(event);
}
break;

  • Hi Magadalena, 
    Could you help sending your click_dector_def.h file so we can compile here ? 

    I have investigate a little bit and can see similar issue when testing with the button press. 
    But it would be nice to have the exact code as you so it's easier to debug and report to the team. 

  • Hi,

    This is my click_dector_def.h file.

    /*
     * Copyright (c) 2019 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    #include <caf/click_detector.h>
    
    /* This configuration file is included only once from click_detector module
     * and holds information about click detector configuration.
     */
    
    /* This structure enforces the header file is included only once in the build.
     * Violating this requirement triggers a multiple definition error at link time.
     */
    const struct {} click_detector_def_include_once;
    
    static const struct click_detector_config click_detector_config[] = {
    	{
    		.key_id = 0,
    		.consume_button_event = false,
    	},
    };
    

  • Thanks Magadalena, 
    I have reproduced the issue here. Looks like a bug to me. The team has started looking into this. Will keep you updated. 

  • Hi Magdalena, 
    I got the feedback from the developer, it seems that new_force_power_down_event() is needed, instead of the new_power_down_event(). If you have a look here you can find that power_down_event should not be used in a module that not controls the power management and it's the final subscriber to the power down event. 

    * Only the module that controls the power management in the application can submit the power down event. It is also the final subscriber for the power down event. When it receives the power down event, it's ensured that all other application modules that handle power down event are already suspended. Then it can continue the power down procedure.

    I tried with the new_force_power_down_event() for CLICK_LONG and it seems to work. You need to include : 
    CONFIG_PM_POLICY_APP=y
    CONFIG_CAF_POWER_MANAGER=y

  • Which is the module that controls the power managment? How can I make a module to control the power managment?

Related