1 /* 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_mgmt callback API 16 * @defgroup mcumgr_callback_api_settings_mgmt MCUmgr settings_mgmt callback API 17 * @ingroup mcumgr_callback_api 18 * @{ 19 */ 20 21 enum settings_mgmt_access_types { 22 SETTINGS_ACCESS_READ, 23 SETTINGS_ACCESS_WRITE, 24 SETTINGS_ACCESS_DELETE, 25 SETTINGS_ACCESS_COMMIT, 26 SETTINGS_ACCESS_LOAD, 27 SETTINGS_ACCESS_SAVE, 28 }; 29 30 /** 31 * Structure provided in the #MGMT_EVT_OP_SETTINGS_MGMT_ACCESS notification callback: This 32 * callback function is used to notify the application about a pending setting 33 * read/write/delete/load/save/commit request and to authorise or deny it. Access will be allowed 34 * so long as no handlers return an error, if one returns an error then access will be denied. 35 */ 36 struct settings_mgmt_access { 37 /** Type of access */ 38 enum settings_mgmt_access_types access; 39 40 /** 41 * Key name for accesses (only set for SETTINGS_ACCESS_READ, SETTINGS_ACCESS_WRITE and 42 * SETTINGS_ACCESS_DELETE). Note that this can be changed by handlers to redirect settings 43 * access if needed (as long as it does not exceed the maximum setting string size) if 44 * CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_STACK is selected, of maximum size 45 * CONFIG_MCUMGR_GRP_SETTINGS_NAME_LEN. 46 * 47 * Note: This string *must* be NULL terminated. 48 */ 49 #ifdef CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP 50 const char *name; 51 #else 52 char *name; 53 #endif 54 55 /** Data provided by the user (only set for SETTINGS_ACCESS_WRITE) */ 56 const uint8_t *val; 57 58 /** Length of data provided by the user (only set for SETTINGS_ACCESS_WRITE) */ 59 const size_t *val_length; 60 }; 61 62 /** 63 * @} 64 */ 65 66 #ifdef __cplusplus 67 } 68 #endif 69 70 #endif 71