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 and
48 : * #SETTINGS_ACCESS_DELETE). Note that this can be changed by handlers to redirect settings
49 : * access if needed (as long as it does not exceed the maximum setting string size) if
50 : * CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_STACK is selected, of maximum size
51 : * 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 : /** Data provided by the user (only set for SETTINGS_ACCESS_WRITE) */
62 1 : const uint8_t *val;
63 :
64 : /** Length of data provided by the user (only set for SETTINGS_ACCESS_WRITE) */
65 1 : const size_t *val_length;
66 : };
67 :
68 : /**
69 : * @}
70 : */
71 :
72 : #ifdef __cplusplus
73 : }
74 : #endif
75 :
76 : #endif
|