<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83505/ncs-caf-leds-modules-can-not-receive-power-down-event</link><description>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. 
 
 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Nov 2023 09:58:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83505/ncs-caf-leds-modules-can-not-receive-power-down-event" /><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/453651?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 09:58:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac84b9d9-b8dd-4d88-b25e-30f894b65662</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Tasos: Please create a new ticket for your question.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/453637?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 08:49:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4b63787-557f-4ba4-b381-79401026fd94</guid><dc:creator>Tasos</dc:creator><description>&lt;p&gt;Which is the module that controls the power managment? How can I make a module to control the power managment?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/348030?ContentTypeID=1</link><pubDate>Mon, 17 Jan 2022 12:29:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b711bcb-b5a5-4cef-8f11-5bcd33a0de03</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Magdalena,&amp;nbsp;&lt;br /&gt;I got the feedback from the developer, it seems that&amp;nbsp;new_force_power_down_event() is needed, instead of the&amp;nbsp;new_power_down_event(). If you have a look &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/include/caf/events/power_event.h#L44"&gt;here&lt;/a&gt;&amp;nbsp;you can find that power_down_event should not be used in a module that not controls the power management and it&amp;#39;s the final subscriber to the power down event.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;* Only the module that controls the power management in the application can submit the power down&lt;/em&gt;&lt;em&gt;&amp;nbsp;event. It is also the final subscriber for the power down event. When it receives the power down&lt;/em&gt;&lt;em&gt;&amp;nbsp;event, it&amp;#39;s ensured that all other application modules that handle power down event are already&lt;/em&gt;&lt;em&gt;&amp;nbsp;suspended. Then it can continue the power down procedure.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I tried with the&amp;nbsp;&lt;span&gt;new_force_power_down_event() for CLICK_LONG and it seems to work. You need to include :&amp;nbsp;&lt;br /&gt;CONFIG_PM_POLICY_APP=y&lt;br /&gt;CONFIG_CAF_POWER_MANAGER=y&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347582?ContentTypeID=1</link><pubDate>Thu, 13 Jan 2022 12:48:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2dbbca99-96a5-4090-b489-c74686fb2ac1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Thanks Magadalena,&amp;nbsp;&lt;br /&gt;I have reproduced the issue here. Looks like a bug to me. The team has started looking into this. Will keep you updated.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347477?ContentTypeID=1</link><pubDate>Thu, 13 Jan 2022 01:13:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f971d37-4791-473d-81d5-318386f2e867</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This is my click_dector_def.h file.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2019 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include &amp;lt;caf/click_detector.h&amp;gt;

/* 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,
	},
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347449?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 16:40:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6dd43c3-2bc9-4b93-b762-d7b75d7d65c9</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Magadalena,&amp;nbsp;&lt;br /&gt;Could you help sending your click_dector_def.h file so we can compile here ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have investigate a little bit and can see similar issue when testing with the button press.&amp;nbsp;&lt;br /&gt;But it would be nice to have the exact code as you so it&amp;#39;s easier to debug and report to the team.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347289?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 02:56:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f36169c0-8000-421f-8f4a-8bea39aff515</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1641956029146v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1641956062612v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;These are log information of&amp;nbsp;short click&amp;nbsp;and long click respectively.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347286?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 02:49:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78825331-e1f7-4cc1-b301-10d7501f0d87</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;&lt;span&gt;My project is based on&amp;nbsp;sample/caf :&amp;nbsp;&lt;/span&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/v1.8.0/samples/caf"&gt;https://github.com/nrfconnect/sdk-nrf/tree/v1.8.0/samples/caf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It will also appear on 52840 DK. I add click event in sample/caf, t&lt;/span&gt;his is the modified led_state.c file and prj.conf.&amp;nbsp;&lt;span&gt;You can replace them in sample/caf.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;zephyr.h&amp;gt;

#define MODULE led_state
#include &amp;lt;caf/events/module_state_event.h&amp;gt;
#include &amp;lt;caf/events/led_event.h&amp;gt;
#include &amp;lt;caf/events/button_event.h&amp;gt;
#include &amp;lt;caf/events/click_event.h&amp;gt;
#include &amp;lt;caf/events/power_event.h&amp;gt;

#include &amp;lt;logging/log.h&amp;gt;
LOG_MODULE_REGISTER(MODULE, CONFIG_CAF_SAMPLE_LED_STATE_LOG_LEVEL);

#include &amp;quot;led_state_def.h&amp;quot;


enum button_id {
	BUTTON_ID_NEXT_EFFECT,
	BUTTON_ID_NEXT_LED,

	BUTTON_ID_COUNT
};

static enum led_effect_id curr_led_effect_id[LED_ID_COUNT];
static enum led_id curr_led_id;


static void send_led_event(enum led_id led_id, const struct led_effect *led_effect)
{
	__ASSERT_NO_MSG(led_effect);
	__ASSERT_NO_MSG(led_id &amp;lt; LED_ID_COUNT);

	struct led_event *event = new_led_event();

	event-&amp;gt;led_id = led_id;
	event-&amp;gt;led_effect = led_effect;
	EVENT_SUBMIT(event);
}

static bool handle_click_event(const struct click_event *evt) {
    if (evt-&amp;gt;key_id == 0) {
        if (evt-&amp;gt;click == CLICK_LONG) {
            struct power_down_event *event = new_power_down_event();

            event-&amp;gt;error = false;
            EVENT_SUBMIT(event);
        } else if (evt-&amp;gt;click == CLICK_SHORT) {
            struct power_down_event *event = new_power_down_event();

            event-&amp;gt;error = false;
            EVENT_SUBMIT(event);
        }
    }

    return false;
}

static bool event_handler(const struct event_header *eh)
{
    if (is_click_event(eh)) {
        return handle_click_event(cast_click_event(eh));
    }

	if (is_module_state_event(eh)) {
		const struct module_state_event *event = cast_module_state_event(eh);

		if (check_state(event, MODULE_ID(leds), MODULE_STATE_READY)) {
			/* Turn on the first LED */
			send_led_event(LED_ID_0, &amp;amp;led_effect_on);
		}

		return false;
	}

	/* Event not handled but subscribed. */
	__ASSERT_NO_MSG(false);

	return false;
}

EVENT_LISTENER(MODULE, event_handler);
EVENT_SUBSCRIBE(MODULE, module_state_event);
EVENT_SUBSCRIBE(MODULE, click_event);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;# Dependencies for EVENT_MANAGER and CAF
CONFIG_LINKER_ORPHAN_SECTION_PLACE=y
CONFIG_HEAP_MEM_POOL_SIZE=2048

# Enable CAF_BUTTONS
CONFIG_CAF=y
CONFIG_CAF_BUTTONS=y
CONFIG_CAF_BUTTONS_POLARITY_INVERSED=y

# Dependencies for CAF_LEDS
CONFIG_LED=y
CONFIG_PWM=y
CONFIG_LED_PWM=y

# Enable CAF_LEDS
CONFIG_CAF_LEDS=y
CONFIG_CAF_LEDS_PWM=y

CONFIG_CAF_CLICK_DETECTOR=y
CONFIG_CAF_PM_EVENTS=y

# Enable logging
CONFIG_LOG=y
# Increase number of internal logging buffers
CONFIG_LOG_STRDUP_BUF_COUNT=32

# Application specific options
CONFIG_CAF_SAMPLE_LED_STATE=y&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347280?ContentTypeID=1</link><pubDate>Wed, 12 Jan 2022 01:49:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd799957-e041-4c60-b4ab-4fc9194db8ff</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;Yeah,&amp;nbsp;&lt;span&gt;CONFIG_CAF_LEDS_PM_EVENTS is set to 1. My project only enable LEDs、BUTTON and CLICK，you can see it work&amp;nbsp;normally when short click or double click.&amp;nbsp;&lt;/span&gt;It doesn&amp;#39;t seem to have anything to do with leds, because t&lt;span class="tran"&gt;his&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class="tran"&gt;kind&lt;/span&gt;&lt;span&gt;&amp;nbsp;of&amp;nbsp;&lt;/span&gt;&lt;span class="tran"&gt;problem&amp;nbsp;&lt;/span&gt;&lt;span&gt;can&amp;nbsp;&lt;/span&gt;&lt;span class="tran highlight"&gt;happen if I submit power down event in click long event.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/347219?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 15:09:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05986c4d-2aab-429e-b0d2-be0b0ac4a0f9</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Magdalena,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you check if&amp;nbsp;CONFIG_CAF_LEDS_PM_EVENTS is set to 1.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you send us the project so we can test on a DK here ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NCS CAF leds modules can not receive power down event?</title><link>https://devzone.nordicsemi.com/thread/346926?ContentTypeID=1</link><pubDate>Mon, 10 Jan 2022 12:08:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6566519-a570-461a-b796-4cedaf6c0e1f</guid><dc:creator>Harvey Zheng</dc:creator><description>&lt;p&gt;&lt;span&gt;Under the same conditions, button modules can receive normally.&amp;nbsp;&lt;/span&gt;In addition,&amp;nbsp;led use GPIO mode.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>