Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sys Runtime Configuration Registry #19895

Open
wants to merge 118 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
6aa217a
sys: add runtime configuration registry
LasseRosenow Aug 21, 2023
a12ae66
sys/registry: add persistent storage module
LasseRosenow Aug 21, 2023
55be440
sys/registry: add int_path module
LasseRosenow Aug 21, 2023
cc16efb
sys/registry: add string_path module
LasseRosenow Aug 21, 2023
f38a736
sys/registry: add sys namespace
LasseRosenow Aug 21, 2023
cd6cd1b
sys/registry: add tests namespace
LasseRosenow Aug 21, 2023
e04a3c5
sys/registry/storage: add heap based storage
LasseRosenow Aug 21, 2023
23ad414
sys/registry/storage: add vfs based storage
LasseRosenow Aug 21, 2023
8df46ed
examples: add registry example
LasseRosenow Aug 21, 2023
b5ebf73
sys/shell: add registry cli
LasseRosenow Aug 21, 2023
c559924
tests/unittests: add registry tests
LasseRosenow Aug 21, 2023
99aa25f
tests/unittests: add registry_storage tests
LasseRosenow Aug 21, 2023
786f823
tests/unittests: add registry_int_path tests
LasseRosenow Aug 21, 2023
63562cd
tests/unittests: add registry_string_path tests
LasseRosenow Aug 21, 2023
47dd545
tests/unittests: add registry_storage_heap tests
LasseRosenow Aug 21, 2023
54e5f9a
tests/unittests: add registry_storage_vfs tests
LasseRosenow Aug 21, 2023
502e658
sys/registry/namespace: add to pseudomodules
LasseRosenow Aug 21, 2023
d858212
sys/registry: add board_led schema to sys namespace
LasseRosenow Jan 30, 2024
52f0169
examples: rename registry example to registry_cli
LasseRosenow Jan 30, 2024
35abb4a
examples: add registry_core example
LasseRosenow Jan 30, 2024
52d208d
fixup! sys: add runtime configuration registry
LasseRosenow Jan 30, 2024
40a98a7
fixup! examples: add registry_core example
LasseRosenow Jan 30, 2024
3fa904b
fixup! sys: add runtime configuration registry
LasseRosenow Feb 21, 2024
efc7a94
fixup! sys/registry: add sys namespace
LasseRosenow Feb 21, 2024
111d73c
fixup! sys/registry: add tests namespace
LasseRosenow Feb 21, 2024
7b046d0
fixup! tests/unittests: add registry tests
LasseRosenow Feb 21, 2024
0674a1a
fixup! sys: add runtime configuration registry
LasseRosenow Apr 6, 2024
bf1438d
fixup! sys/registry: add persistent storage module
LasseRosenow Apr 6, 2024
2f84e38
fixup! sys/registry/storage: add heap based storage
LasseRosenow Apr 6, 2024
587d504
fixup! sys/registry/storage: add vfs based storage
LasseRosenow Apr 6, 2024
ba1d4c4
fixup! sys/registry: add int_path module
LasseRosenow Apr 6, 2024
a70d725
fixup! sys/registry: add string_path module
LasseRosenow Apr 6, 2024
49be2f9
fixup! examples: add registry_core example
LasseRosenow Apr 6, 2024
8b00112
fixup! sys/shell: add registry cli
LasseRosenow Apr 6, 2024
938b2b8
fixup! tests/unittests: add registry tests
LasseRosenow Apr 6, 2024
7129ca1
fixup! tests/unittests: add registry_int_path tests
LasseRosenow Apr 6, 2024
34a70b4
fixup! tests/unittests: add registry_string_path tests
LasseRosenow Apr 6, 2024
749d51a
fixup! tests/unittests: add registry_storage_heap tests
LasseRosenow Apr 6, 2024
4d40b09
fixup! tests/unittests: add registry_storage_vfs tests
LasseRosenow Apr 6, 2024
75842a4
fixup! tests/unittests: add registry_storage tests
LasseRosenow Apr 6, 2024
7f42945
fixup! examples: add registry example
LasseRosenow Apr 10, 2024
f1cbcf5
fixup! examples: add registry example
LasseRosenow Apr 12, 2024
5675174
fixup! examples: add registry_core example
LasseRosenow Apr 12, 2024
845bf27
fixup! sys: add runtime configuration registry
LasseRosenow Apr 12, 2024
423d209
fixup! sys: add runtime configuration registry
LasseRosenow Apr 12, 2024
bdfc315
fixup! sys/shell: add registry cli
LasseRosenow Apr 12, 2024
9d8da13
fixup! examples: add registry_core example
LasseRosenow Apr 12, 2024
66a8e2b
fixup! sys/registry: add string_path module
LasseRosenow Apr 12, 2024
1828302
fixup! sys/registry: add int_path module
LasseRosenow Apr 12, 2024
2d88670
fixup! sys/registry: add persistent storage module
LasseRosenow Apr 12, 2024
fb8e41e
fixup! sys/registry/storage: add vfs based storage
LasseRosenow Apr 12, 2024
671acff
fixup! sys/registry/storage: add heap based storage
LasseRosenow Apr 12, 2024
f2b82ee
fixup! sys: add runtime configuration registry
LasseRosenow Apr 12, 2024
b668ccb
fixup! tests/unittests: add registry tests
LasseRosenow Apr 12, 2024
06adb07
fixup! tests/unittests: add registry_int_path tests
LasseRosenow Apr 12, 2024
0d91422
fixup! tests/unittests: add registry_storage tests
LasseRosenow Apr 12, 2024
f7e4008
fixup! tests/unittests: add registry_storage_heap tests
LasseRosenow Apr 12, 2024
4a9c124
fixup! tests/unittests: add registry_storage_vfs tests
LasseRosenow Apr 12, 2024
f9d8c3e
fixup! tests/unittests: add registry_string_path tests
LasseRosenow Apr 12, 2024
9444fe8
fixup! sys/registry: add int_path module
LasseRosenow Apr 24, 2024
4f9283c
fixup! sys: add runtime configuration registry
LasseRosenow Apr 24, 2024
3614909
fixup! sys: add runtime configuration registry
LasseRosenow Apr 24, 2024
265043f
fixup! sys/shell: add registry cli
LasseRosenow Apr 24, 2024
491733a
fixup! sys: add runtime configuration registry
LasseRosenow Apr 24, 2024
3b3734f
fixup! sys/registry: add string_path module
LasseRosenow Apr 24, 2024
4e28f6a
fixup! sys/registry: add tests namespace
LasseRosenow Apr 24, 2024
6820c2b
fixup! sys/registry: add sys namespace
LasseRosenow Apr 24, 2024
3dfcd91
fixup! sys/registry: add int_path module
LasseRosenow Apr 24, 2024
e8424e9
fixup! sys/registry: add int_path module
LasseRosenow Apr 24, 2024
74b0a34
fixup! sys/registry: add string_path module
LasseRosenow Apr 24, 2024
c252ad2
fixup! sys: add runtime configuration registry
LasseRosenow Apr 24, 2024
909b2f1
fixup! sys/registry: add persistent storage module
LasseRosenow Apr 24, 2024
2f6eaad
fixup! sys/registry: add tests namespace
LasseRosenow Apr 24, 2024
e58fb66
fixup! sys/registry: add sys namespace
LasseRosenow Apr 24, 2024
57682a1
fixup! sys/registry: add persistent storage module
LasseRosenow Apr 24, 2024
dc430db
sys/registry: add tree traversal utility
LasseRosenow May 3, 2024
8c9bbae
fixup! sys: add runtime configuration registry
LasseRosenow May 3, 2024
d548e02
fixup! sys/registry: add int_path module
LasseRosenow May 3, 2024
130d1b5
fixup! sys/registry: add string_path module
LasseRosenow May 3, 2024
3204ad6
fixup! tests/unittests: add registry_string_path tests
LasseRosenow May 3, 2024
38c6dc1
fixup! sys/registry: add tree traversal utility
LasseRosenow May 6, 2024
95e3ea2
fixup! sys: add runtime configuration registry
LasseRosenow May 6, 2024
b61abb0
fixup! sys/registry: add int_path module
LasseRosenow May 6, 2024
49e643a
fixup! sys/registry: add string_path module
LasseRosenow May 6, 2024
3e638c1
fixup! sys: add runtime configuration registry
LasseRosenow May 6, 2024
f0d6792
fixup! sys/registry: add persistent storage module
LasseRosenow May 6, 2024
50f08d4
fixup! sys/registry: add int_path module
LasseRosenow May 6, 2024
9289095
fixup! tests/unittests: add registry tests
LasseRosenow May 6, 2024
28bad94
fixup! tests/unittests: add registry_storage tests
LasseRosenow May 6, 2024
b57f297
fixup! examples: add registry example
LasseRosenow May 6, 2024
f74ed61
fixup! examples: add registry_core example
LasseRosenow May 6, 2024
77937f8
fixup! sys: add runtime configuration registry
LasseRosenow May 6, 2024
c7d840e
fixup! sys/registry: add persistent storage module
LasseRosenow May 6, 2024
082d89d
fixup! sys/registry/storage: add heap based storage
LasseRosenow May 6, 2024
82b088a
fixup! sys/registry/storage: add vfs based storage
LasseRosenow May 6, 2024
b73f712
fixup! sys/registry: add persistent storage module
LasseRosenow May 6, 2024
64bfdd9
fixup! sys/shell: add registry cli
LasseRosenow May 6, 2024
714e7a3
fixup! tests/unittests: add registry_storage tests
LasseRosenow May 6, 2024
68a0716
fixup! tests/unittests: add registry_storage_heap tests
LasseRosenow May 6, 2024
3bd0c7b
fixup! tests/unittests: add registry_storage_vfs tests
LasseRosenow May 6, 2024
1438aa7
fixup! sys/registry: add string_path module
LasseRosenow May 7, 2024
b0d8b3b
fixup! sys/registry: add int_path module
LasseRosenow May 7, 2024
fc599ed
fixup! sys/registry: add int_path module
LasseRosenow May 7, 2024
2de13de
fixup! sys/registry: add persistent storage module
LasseRosenow May 7, 2024
b7577c6
fixup! sys/registry: add tree traversal utility
LasseRosenow May 7, 2024
0410dbd
fixup! sys/registry/storage: add vfs based storage
LasseRosenow May 7, 2024
ba4533d
fixup! sys/registry/storage: add heap based storage
LasseRosenow May 7, 2024
f233a27
fixup! sys/registry: add sys namespace
LasseRosenow May 7, 2024
8999642
fixup! sys/registry: add tests namespace
LasseRosenow May 7, 2024
958157c
fixup! sys/registry: add tests namespace
LasseRosenow May 7, 2024
305fc97
fixup! sys: add runtime configuration registry
LasseRosenow May 7, 2024
a927ce3
fixup! tests/unittests: add registry tests
LasseRosenow May 7, 2024
500e7ef
fixup! tests/unittests: add registry_int_path tests
LasseRosenow May 7, 2024
91006b6
fixup! tests/unittests: add registry_storage tests
LasseRosenow May 7, 2024
fd87b09
fixup! tests/unittests: add registry_storage_heap tests
LasseRosenow May 7, 2024
d9a7f68
fixup! tests/unittests: add registry_storage_vfs tests
LasseRosenow May 7, 2024
f68fbb1
fixup! tests/unittests: add registry_string_path tests
LasseRosenow May 7, 2024
6102a76
Merge branch 'main' into pr-runtime-configuration-registry
LasseRosenow May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions examples/registry_cli/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# name of the application
APPLICATION = registry_example_cli

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

# required modules
# enable the shell to execute the registry CLI
USEMODULE += shell
USEMODULE += shell_cmds_default

# enable littlefs2 for the persistent storage of the registry
USEMODULE += littlefs2
# enable mtd to use it as the storage location
USEMODULE += mtd

# enable the string_path extension of the registry to
# identify configuration parameters using strings instead of pointers
USEMODULE += registry_string_path
# enable the vfs storage implementation to persistently store configuration
# parameters to a storage device such as the mtd
USEMODULE += registry_storage_vfs
# enable the rgb_led schema (sys/rgb_led) to demonstrate how to configure
# RGB LEDs as an example for the registry CLI
USEMODULE += registry_namespace_sys_rgb_led

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
25 changes: 25 additions & 0 deletions examples/registry_cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
examples/registry_cli
================

This application demonstrates the most basic usage of the RIOT Registry.

Usage
=====

Simply build and flash the application for your target board:

```
BOARD=YOUR_BOARD_NAME_HERE make flash term
```

Now you should have access to the RIOT shell on your board. For interacting
with the RIOT Registry, use the `registry` shell command, e.g.:

```
registry export <- prints the IDs of the whole configuration tree
registry get 0/0/0/0 <- get the value of the red parameter of the instance 0 of the RGB LED Schema inside of the SYS namespace
registry set 0/0/0/0 56 <- set the value of the red parameter to 56
registry commit 0/0/0/0 <- apply new value for the 0/0/0/0 path
registry save <- save configurations to persistent storage
registry load <- load configurations from persistent storage
```
161 changes: 161 additions & 0 deletions examples/registry_cli/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* Copyright (C) 2023 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup examples
* @{
*
* @file
* @brief RIOT registry CLI example application to demonstrate how
* to use the RIOT registry using the CLI.
*
* @author Lasse Rosenow <[email protected]>
*
* @}
*/

#include <string.h>
#include <stdio.h>

#include "msg.h"
#include "shell.h"
#include "board.h"
#include "mtd.h"
#include "vfs.h"
#include "fs/littlefs2_fs.h"
#include "registry.h"
#include "registry/namespace/sys.h"
#include "registry/namespace/sys/rgb_led.h"
#include "registry/storage.h"
#include "registry/string_path.h"

/* this callback is usually implemented drivers such as an RGB LED driver */
static registry_error_t shared_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context)
{
/* since this function is shared by multiple commit_cb functions, we path the instance in the context */
const registry_instance_t *instance = context;
const registry_sys_rgb_led_instance_t *data = instance->data;

printf("RGB instance commit_cb was executed on ");

/* check how much of the registry instance was committed and print the new values */
switch (scope)
{
case REGISTRY_COMMIT_INSTANCE:
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch (scope)
{
case REGISTRY_COMMIT_INSTANCE:
switch (scope) {
case REGISTRY_COMMIT_INSTANCE:

There are a number of deviations from the coding convention regarding code formatting. This is not a big deal and coding style is IMO purely about personal preference, but keeping things consistent within the code base does (at least me) help a lot when reading code.

I won't add further comments on style, since this is best left to uncrustify or clang-format.

/* in this case the whole instance and all parameters inside of it was committed */
printf("the whole instance: ID: %d\n", instance->id);
printf("\tParameter ID: 0, VALUE: %d\n", data->red);
printf("\tParameter ID: 1, VALUE: %d\n", data->green);
printf("\tParameter ID: 2, VALUE: %d\n", data->blue);
break;
case REGISTRY_COMMIT_GROUP:
/* in this case a group and all parameters inside of it was committed */
printf("a group: %d\n", *group_or_parameter_id);
/* this instance does not have groups, so no need to print anything here */
break;
case REGISTRY_COMMIT_PARAMETER:
/* in this case only a single parameter was committed */
printf("a single parameter: ID: %d,", *group_or_parameter_id);
switch (*group_or_parameter_id)
{
case 0: printf(" VALUE: %d\n", data->red); break;
case 1: printf(" VALUE: %d\n", data->green); break;
case 2: printf(" VALUE: %d\n", data->blue); break;
}
}

return REGISTRY_ERROR_NONE;
}

/* create instances of a configuration schema, to expose configuration parameters to the registry */
static registry_error_t rgb_led_instance_0_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context);
static registry_sys_rgb_led_instance_t rgb_led_instance_0_data = {
.red = 0,
.green = 255,
.blue = 70,
};
static registry_instance_t rgb_led_instance_0 = {
.name = "rgb-0",
.data = &rgb_led_instance_0_data,
.commit_cb = &rgb_led_instance_0_commit_cb,
};
static registry_error_t rgb_led_instance_0_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context)
{
(void)context;
return shared_commit_cb(scope, group_or_parameter_id, &rgb_led_instance_0);
}

/* create an instance for a second RGB LED */
static registry_error_t rgb_led_instance_1_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context);
static registry_sys_rgb_led_instance_t rgb_led_instance_1_data = {
.red = 90,
.green = 4,
.blue = 0,
};
static registry_instance_t rgb_led_instance_1 = {
.name = "rgb-1",
.data = &rgb_led_instance_1_data,
.commit_cb = &rgb_led_instance_1_commit_cb,
};
static registry_error_t rgb_led_instance_1_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context)
{
(void)context;
return shared_commit_cb(scope, group_or_parameter_id, &rgb_led_instance_1);
}

/* configure the registry storage to use littlefs2 */
static littlefs2_desc_t fs_desc = {
.lock = MUTEX_INIT,
};

/* set the mount point for the registry storage to /sda for this example */
static vfs_mount_t _vfs_mount = {
.fs = &littlefs2_file_system,
.mount_point = "/sda",
.private_data = &fs_desc,
};

/* create a storage instance to register the storage at the RIOT registry */
static registry_storage_instance_t vfs_instance = {
.storage = &registry_storage_vfs,
.data = &_vfs_mount,
};

int main(void)
{
/* initialize the riot registry storage for persistent configuration parameters */
#if IS_USED(MODULE_LITTLEFS2)
fs_desc.dev = MTD_0;
#endif

/* initialize the riot registry */
registry_init();

/* set storage instances so that the CLI can find them */
const registry_storage_instance_t* storage_instances[] = {&vfs_instance};
registry_storage_set_instances(storage_instances);

/* add configuration schemas to the registry */
registry_add_schema_instance(&registry_sys_rgb_led, &rgb_led_instance_0);
registry_add_schema_instance(&registry_sys_rgb_led, &rgb_led_instance_1);

/* initialize and run the RIOT shell */
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, sizeof(line_buf));
return 0;
}
24 changes: 24 additions & 0 deletions examples/registry_core/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# name of the application
APPLICATION = registry_example_core

# If no BOARD is found in the environment, use this default:
BOARD ?= native

# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

# required modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an example it doesn't hurt to say what is the reason for enabling a specific module. That it is required for the example is obvious, but what is the exact effect related to enabling this module? I.e., "Activate the namespace /sys/board/led/", "Enable the default registry configurations for the board led" or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# enable board_led schema (sys/board_led) of the riot registry
USEMODULE += registry_namespace_sys_board_led
# enable the ztimer to turn the led on and off every second
USEMODULE += ztimer_msec

# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 1

# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

include $(RIOTBASE)/Makefile.include
16 changes: 16 additions & 0 deletions examples/registry_core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
examples/registry_core
================

This application demonstrates the most basic usage of the RIOT Registry.
It implements a RGB LED schema and continuously changes its value every second.

Usage
=====

Simply build and flash the application for your target board:

```
BOARD=YOUR_BOARD_NAME_HERE make flash term
```

Now you should see the terminal continuously print out different LED states.
108 changes: 108 additions & 0 deletions examples/registry_core/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* Copyright (C) 2023 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup examples
* @{
*
* @file
* @brief RIOT registry core minimal example application to demonstrate
* how to use the riot registry without any of its extensions.
*
* @author Lasse Rosenow <[email protected]>
*
* @}
*/

#include <string.h>
#include <stdio.h>
#include <unistd.h>

#include "periph_cpu.h"
#include "led.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory led.h should be enough to use the LED_ON / OFF macros. Why is board.h and periph_cpu.h required on top of that? Is there a problem with the includes that should be resolved instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did have some problems when building for BOARD=same54-xpro

#include "board.h"
#include "registry.h"
#include "registry/namespace/sys.h"
#include "registry/namespace/sys/board_led.h"
#include "ztimer.h"

registry_error_t board_led_instance_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context);

/* This belongs into the BOARD or Driver for example */
registry_sys_board_led_instance_t board_led_instance_0_data = {
.enabled = 0,
};

registry_instance_t board_led_instance = {
.data = &board_led_instance_0_data,
.commit_cb = &board_led_instance_commit_cb,
};

/* this callback is usually implemented drivers such as an RGB LED driver */
registry_error_t board_led_instance_commit_cb(const registry_commit_cb_scope_t scope,
const registry_group_or_parameter_id_t *group_or_parameter_id,
const void *context)
{
(void)scope;
(void)context;

/* Either commit all parameters of the instance or only the given parameter.
* For a single LED there is no difference as it only has one parameter. */
if ((group_or_parameter_id == NULL) ||
(*group_or_parameter_id == REGISTRY_SYS_BOARD_LED_ENABLED)) {
/* The Driver owns the board_led data instance, so we can just get our value from there */
bool led_state = board_led_instance_0_data.enabled;
/* Turn the LED on or off depending on the led_state */
if (led_state == true) {
/* This is the commit_cb function of instance 0, so we toggle LED 0 as well */
LED_ON(0);
} else {
LED_OFF(0);
}
}

return 0;
}

/* This belongs into our main application */
int main(void)
{
registry_init();

/* init schemas */
registry_add_schema_instance(&registry_sys_board_led, &board_led_instance);

bool board_led_enabled = false;

while (true) {
/* Invert the BOARD LED, to make it turn on and off on each subsequent cycle */
board_led_enabled = !board_led_enabled;

/* Create registry_node_t for the board_led_parameter */
const registry_node_t parameter_node = {
.type = REGISTRY_NODE_PARAMETER,
.value.parameter = {
.instance = &board_led_instance,
.parameter = &registry_sys_board_led_enabled,
},
};

/* Set new registry value */
registry_set(&parameter_node, &board_led_enabled, sizeof(board_led_enabled));

/* Apply the registry value to change the LED state (in this case calls the commit_cb function: "board_led_instance_commit_cb")*/
registry_commit(&parameter_node);

/* Sleep for 1 second and then do it again*/
ztimer_sleep(ZTIMER_MSEC, 1000);
}

return 0;
}
6 changes: 6 additions & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ PSEUDOMODULES += fortuna_reseed
## will be removed after 2023.07 release.
PSEUDOMODULES += random_cmd
## @}
PSEUDOMODULES += registry_%
NO_PSEUDOMODULES += registry_namespace_sys
NO_PSEUDOMODULES += registry_namespace_tests
NO_PSEUDOMODULES += registry_storage

PSEUDOMODULES += riotboot_%
PSEUDOMODULES += rtt_cmd
PSEUDOMODULES += saul_adc
Expand Down Expand Up @@ -497,6 +502,7 @@ PSEUDOMODULES += shell_cmd_openwsn
PSEUDOMODULES += shell_cmd_pm
PSEUDOMODULES += shell_cmd_ps
PSEUDOMODULES += shell_cmd_random
PSEUDOMODULES += shell_cmd_registry
PSEUDOMODULES += shell_cmd_rtc
PSEUDOMODULES += shell_cmd_rtt
PSEUDOMODULES += shell_cmd_saul_reg
Expand Down
Loading
Loading