Line data Source code
1 0 : /*
2 : * Copyright (c) 2023 Nordic Semiconductor ASA
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : #ifndef H_MCUMGR_SETTINGS_MGMT_CALLBACKS_
8 : #define H_MCUMGR_SETTINGS_MGMT_CALLBACKS_
9 :
10 : #ifdef __cplusplus
11 : extern "C" {
12 : #endif
13 :
14 : /**
15 : * @brief MCUmgr Settings Management Callbacks API
16 : * @defgroup mcumgr_callback_api_settings_mgmt Settings Management Callbacks
17 : * @ingroup mcumgr_settings_mgmt
18 : * @ingroup mcumgr_callback_api
19 : * @{
20 : */
21 :
22 : /**
23 : * @name Settings access types
24 : * @{
25 : */
26 0 : enum settings_mgmt_access_types {
27 : SETTINGS_ACCESS_READ, /**< Setting is being read */
28 : SETTINGS_ACCESS_WRITE, /**< Setting is being written */
29 : SETTINGS_ACCESS_DELETE, /**< Setting is being deleted */
30 : SETTINGS_ACCESS_COMMIT, /**< Setting is being committed */
31 : SETTINGS_ACCESS_LOAD, /**< Setting is being loaded */
32 : SETTINGS_ACCESS_SAVE, /**< Setting is being saved */
33 : };
34 : /** @} */
35 :
36 : /**
37 : * Structure provided in the #MGMT_EVT_OP_SETTINGS_MGMT_ACCESS notification callback.
38 : * This callback function is used to notify the application about a pending setting
39 : * read/write/delete/load/save/commit request and to authorise or deny it. Access will be allowed
40 : * so long as no handlers return an error, if one returns an error then access will be denied.
41 : */
42 1 : struct settings_mgmt_access {
43 : /** Type of access */
44 1 : enum settings_mgmt_access_types access;
45 :
46 : /**
47 : * Key name for accesses (only set for #SETTINGS_ACCESS_READ, #SETTINGS_ACCESS_WRITE,
48 : * #SETTINGS_ACCESS_DELETE and #SETTINGS_ACCESS_SAVE). Note that this can be changed by
49 : * handlers to redirect settings access if needed (as long as it does not exceed the maximum
50 : * setting string size) if CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_STACK is selected, of
51 : * maximum size CONFIG_MCUMGR_GRP_SETTINGS_NAME_LEN.
52 : *
53 : * Note: This string *must* be NULL terminated.
54 : */
55 : #ifdef CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP
56 : const char *name;
57 : #else
58 1 : char *name;
59 : #endif
60 :
61 : /**
62 : * Data provided by the user (only set for SETTINGS_ACCESS_WRITE and SETTINGS_ACCESS_SAVE)
63 : */
64 1 : const uint8_t *val;
65 :
66 : /**
67 : * Length of data provided by the user (only set for SETTINGS_ACCESS_WRITE and
68 : * SETTINGS_ACCESS_SAVE)
69 : */
70 1 : const size_t *val_length;
71 : };
72 :
73 : /**
74 : * @}
75 : */
76 :
77 : #ifdef __cplusplus
78 : }
79 : #endif
80 :
81 : #endif
|