-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: cellular: nrf_cloud_rest_device_message: use CAF
Updated the sample to use CAF instead of DK library for led and button events. Added a device-tree overlay for LEDs to work with CAF LEDs module. Added header files for buttons and LEDs definition which are required by CAF. Also, added error message for when the sample fails to send alerts to nRF Cloud. Signed-off-by: Tony Le <tony.le@nordicsemi.no>
- Loading branch information
1 parent
cdf78d8
commit 0c7ae05
Showing
7 changed files
with
197 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
samples/cellular/nrf_cloud_rest_device_message/boards/nrf9160dk_nrf9160_ns.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
/* Define 4 monochromatic LEDs connected directly | ||
* to the GPIO to be used with CAF LEDs module | ||
*/ | ||
led0 { | ||
compatible = "gpio-leds"; | ||
status = "okay"; | ||
|
||
led0_0: led_0 { | ||
gpios = <&gpio0 2 0>; | ||
}; | ||
}; | ||
|
||
led1 { | ||
compatible = "gpio-leds"; | ||
status = "okay"; | ||
|
||
led1_0: led_0 { | ||
gpios = <&gpio0 3 0>; | ||
}; | ||
}; | ||
|
||
led2 { | ||
compatible = "gpio-leds"; | ||
status = "okay"; | ||
|
||
led2_0: led_0 { | ||
gpios = <&gpio0 4 0>; | ||
}; | ||
}; | ||
|
||
led3 { | ||
compatible = "gpio-leds"; | ||
status = "okay"; | ||
|
||
led3_0: led_0 { | ||
gpios = <&gpio0 5 0>; | ||
}; | ||
}; | ||
|
||
/* Disable the original leds node from device-tree | ||
* since it is incompatible with the CAF LEDs module | ||
*/ | ||
leds { | ||
status = "disabled"; | ||
}; | ||
}; |
25 changes: 25 additions & 0 deletions
25
samples/cellular/nrf_cloud_rest_device_message/include/buttons_def.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <caf/gpio_pins.h> | ||
|
||
/* This file is included by the common application framework (CAF) library */ | ||
|
||
/* This configuration file is included only once from buttons module and holds | ||
* information about pins forming the keyboard matrix. | ||
*/ | ||
|
||
/* This structure enforces the header file to be included only once in the build. | ||
* Violating this requirement triggers a multiple definition error at link time. | ||
*/ | ||
const struct {} buttons_def_include_once; | ||
|
||
static const struct gpio_pin col[] = {}; | ||
|
||
static const struct gpio_pin row[] = { | ||
{ .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(button0), gpios) }, | ||
{ .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(button1), gpios) }, | ||
}; |
28 changes: 28 additions & 0 deletions
28
samples/cellular/nrf_cloud_rest_device_message/include/leds_def.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <caf/led_effect.h> | ||
|
||
/* This configuration file is included only once from the main module and holds | ||
* information about LED on and off effects. | ||
*/ | ||
|
||
/* This structure enforces the header file to be included only once in the build. | ||
* Violating this requirement triggers a multiple definition error at link time. | ||
*/ | ||
const struct {} leds_def_include_once; | ||
|
||
enum led_id { | ||
LED_ID_0, | ||
LED_ID_1, | ||
LED_ID_2, | ||
LED_ID_3, | ||
|
||
LED_ID_COUNT | ||
}; | ||
|
||
static const struct led_effect led_effect_on = LED_EFFECT_LED_ON(LED_COLOR(255, 255, 255)); | ||
static const struct led_effect led_effect_off = LED_EFFECT_LED_OFF(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters