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 17 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
31 changes: 31 additions & 0 deletions examples/registry/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# name of the application
APPLICATION = registry_example

# 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
USEMODULE += shell
USEMODULE += shell_cmds_default

USEMODULE += littlefs2
USEMODULE += mtd

USEMODULE += registry_string_path
USEMODULE += registry_storage_vfs
USEMODULE += registry_namespace_sys_rgb_led
USEMODULE += registry_namespace_tests_full
USEMODULE += registry_namespace_tests_nested

# 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
127 changes: 127 additions & 0 deletions examples/registry/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* 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 example application
*
* @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"
#include "registry/namespace/tests.h"
#include "registry/namespace/tests/nested.h"

int 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)scope;
(void)context;
printf("RGB instance commit_cb was executed on ");

if (group_or_parameter_id != NULL) {
printf("param: %d", *group_or_parameter_id);
}
else {
printf("whole instance");
}

printf("\n");

return 0;
}

registry_sys_rgb_led_instance_t rgb_led_instance_0_data = {
.red = 0,
.green = 255,
.blue = 70,
};
registry_instance_t rgb_led_instance_0 = {
.name = "rgb-0",
.data = &rgb_led_instance_0_data,
.commit_cb = &rgb_led_instance_0_commit_cb,
};

registry_sys_rgb_led_instance_t rgb_led_instance_1_data = {
.red = 90,
.green = 4,
.blue = 0,
};
registry_instance_t rgb_led_instance_1 = {
.name = "rgb-1",
.data = &rgb_led_instance_1_data,
.commit_cb = &rgb_led_instance_0_commit_cb,
};

static littlefs2_desc_t fs_desc = {
.lock = MUTEX_INIT,
};

static vfs_mount_t _vfs_mount = {
.fs = &littlefs2_file_system,
.mount_point = "/sda",
.private_data = &fs_desc,
};

static registry_storage_instance_t vfs_instance = {
.storage = &registry_storage_vfs,
.data = &_vfs_mount,
};

REGISTRY_ADD_STORAGE_SOURCE(vfs_instance);
REGISTRY_SET_STORAGE_DESTINATION(vfs_instance);

static registry_tests_nested_instance_t test_nested_instance_data = {
.parameter = 9,
.group_parameter = 5,
};

static registry_instance_t test_nested_instance = {
.name = "instance-1",
.data = &test_nested_instance_data,
.commit_cb = NULL,
};

int main(void)
{
registry_init();

/* init schemas */
registry_add_schema_instance(&registry_sys_rgb_led, &rgb_led_instance_0);
registry_add_schema_instance(&registry_sys_rgb_led, &rgb_led_instance_1);
registry_add_schema_instance(&registry_tests_nested, &test_nested_instance);

/* init storage */
#if IS_USED(MODULE_LITTLEFS2)
fs_desc.dev = MTD_0;
#endif

/* init and run CLI */
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, sizeof(line_buf));
return 0;
}
6 changes: 6 additions & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,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 @@ -485,6 +490,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
1 change: 1 addition & 0 deletions sys/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ rsource "preprocessor/Kconfig"
rsource "progress_bar/Kconfig"
rsource "ps/Kconfig"
rsource "random/Kconfig"
rsource "registry/Kconfig"
rsource "rtc_utils/Kconfig"
rsource "rust_riotmodules/Kconfig"
rsource "saul_reg/Kconfig"
Expand Down
3 changes: 3 additions & 0 deletions sys/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ endif
ifneq (,$(filter netutils,$(USEMODULE)))
DIRS += net/netutils
endif
ifneq (,$(filter registry,$(USEMODULE)))
DIRS += registry
endif
ifneq (,$(filter sema,$(USEMODULE)))
DIRS += sema
endif
Expand Down
4 changes: 4 additions & 0 deletions sys/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,8 @@ ifneq (,$(filter auto_init%,$(USEMODULE)))
USEMODULE += preprocessor_successor
endif

ifneq (,$(filter registry%,$(USEMODULE)))
include $(RIOTBASE)/sys/registry/Makefile.dep
endif

include $(RIOTBASE)/sys/test_utils/Makefile.dep
4 changes: 4 additions & 0 deletions sys/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,7 @@ endif
ifneq (,$(filter gcoap,$(USEMODULE)))
include $(RIOTBASE)/sys/net/application_layer/gcoap/Makefile.include
endif

ifneq (,$(filter registry%,$(USEMODULE)))
include $(RIOTBASE)/sys/registry/Makefile.include
endif
Loading