37 #ifndef MESH_CONFIG_ENTRY_H__ 38 #define MESH_CONFIG_ENTRY_H__ 43 #include "nrf_mesh_assert.h" 44 #include "nrf_mesh_section.h" 45 #include "nrf_error.h" 46 #include "mesh_config_backend_file.h" 47 #include "nordic_common.h" 65 #define MESH_CONFIG_ENTRY_ID(FILE, RECORD) (const mesh_config_entry_id_t) {(FILE), (RECORD)} 67 #define MESH_CONFIG_ENTRY_MAX_SIZE 64 80 #define MESH_CONFIG_FILE(NAME, FILE_ID, STRATEGY) \ 81 static mesh_config_backend_file_t CONCAT_2(NAME, _backend_data); \ 82 NRF_MESH_SECTION_ITEM_REGISTER_FLASH(mesh_config_files, const mesh_config_file_params_t NAME) = \ 83 {.id = FILE_ID, .strategy = STRATEGY, .p_backend_data = &CONCAT_2(NAME, _backend_data)} 103 #define MESH_CONFIG_ENTRY(NAME, ID, MAX_COUNT, ENTRY_SIZE, SET_CB, GET_CB, DELETE_CB, HAS_DEFAULT_VALUE) \ 104 NRF_MESH_STATIC_ASSERT((ENTRY_SIZE) <= MESH_CONFIG_ENTRY_MAX_SIZE); \ 105 NRF_MESH_STATIC_ASSERT((MAX_COUNT) > 0); \ 106 static mesh_config_entry_flags_t m_##NAME##_state[MAX_COUNT]; \ 107 NRF_MESH_SECTION_ITEM_REGISTER_FLASH(mesh_config_entries, \ 108 const mesh_config_entry_params_t m_##NAME##_params) = \ 110 .entry_size = ENTRY_SIZE, \ 111 .has_default = HAS_DEFAULT_VALUE, \ 112 .max_count = MAX_COUNT, \ 113 .callbacks = {SET_CB, GET_CB, DELETE_CB}, \ 114 .p_state = m_##NAME##_state} 123 #define MESH_CONFIG_ENTRY_API_DEFINE(NAME, ID, DATA_TYPE) \ 124 uint32_t NAME##_set(const DATA_TYPE * p_entry) \ 126 return mesh_config_entry_set((ID), p_entry); \ 128 uint32_t NAME##_get(DATA_TYPE * p_entry) \ 130 return mesh_config_entry_get((ID), p_entry); \ 132 uint32_t NAME##_delete(void) \ 134 return mesh_config_entry_delete((ID)); \ 147 #define MESH_CONFIG_ENTRY_ARRAY_WRAPPER_DECLARE(NAME, ID, DATA_TYPE, INDEX_TYPE, MAX_COUNT) \ 148 uint32_t NAME##_set(INDEX_TYPE index, const DATA_TYPE * p_entry) \ 150 if (index >= (MAX_COUNT)) return NRF_ERROR_INVALID_PARAM; \ 151 mesh_config_entry_id_t id = ID; \ 152 id.record += (uint16_t) index; \ 153 return mesh_config_entry_set(id, p_entry); \ 155 uint32_t NAME##_get(INDEX_TYPE index, DATA_TYPE * p_entry) \ 157 if (index >= (MAX_COUNT)) return NRF_ERROR_INVALID_PARAM; \ 158 mesh_config_entry_id_t id = ID; \ 159 id.record += (uint16_t) index; \ 160 return mesh_config_entry_get(id, p_entry); \ 162 uint32_t NAME##_delete(INDEX_TYPE index) \ 164 if (index >= (MAX_COUNT)) return NRF_ERROR_INVALID_PARAM; \ 165 mesh_config_entry_id_t id = ID; \ 166 id.record += (uint16_t) index; \ 167 return mesh_config_entry_delete(id); \ mesh_config_entry_flags_t * p_state
Array of states for each entry.
mesh_config_strategy_t strategy
Storage strategy.
void(* mesh_config_entry_delete_t)(mesh_config_entry_id_t id)
State owner entry delete callback.
bool has_default
Whether the entry has a default value or not.
Mesh config entry identifier.
mesh_config_backend_file_t * p_backend_data
Pointer to backend data associated with the file.
Mesh config entry parameters.
The entry is set to a valid value.
uint32_t(* mesh_config_entry_set_t)(mesh_config_entry_id_t id, const void *p_entry)
State owner entry setter callback.
uint16_t entry_size
Size of each entry.
mesh_config_entry_flags_t
Entry state.
uint16_t max_count
Max number of entries in the set.
File parameters for a mesh config file.
Stored as soon as possible after each change.
The backend is currently processing the entry.
mesh_config_strategy_t
Mesh config entry storage strategy.
Stored when device is about to power down.
void(* mesh_config_entry_get_t)(mesh_config_entry_id_t id, void *p_entry)
State owner entry getter callback.
const mesh_config_entry_id_t * p_id
Base-ID for this entry set.
The backend and frontend representation of the entry is not in sync.