This patch reworks routines used to store and read the settings data. Provide stream-style encoding and decoding to/from flash, so the the API only requires a pointer to binary data, and the settings implementation takes care of encoding/decoding to/from base64 and writing/reading to/from flash on the fly. This would eliminate the need of a separate base64 value buffer on the application-side, thereby further contributing to the stack footprint reduction. Above changes allows to remove: 256-byte value length limitation. removing enum settings_type usage so all settings data are treated now as a byte array (i.e. what's previously SETTINGS_BYTES) Introduced routine settings_val_read_cb for read and decode the settings data from storage inside h_set handler implementations. h_set settings handler now provide persistent value's context used along with read routine instead of immediately value. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
39 lines
816 B
C
39 lines
816 B
C
/*
|
|
* Copyright (c) 2018 Nordic Semiconductor ASA
|
|
* Copyright (c) 2015 Runtime Inc
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#ifndef __SETTINGS_FILE_H_
|
|
#define __SETTINGS_FILE_H_
|
|
|
|
#include "settings/settings.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define SETTINGS_FILE_NAME_MAX 32 /* max length for settings filename */
|
|
|
|
struct settings_file {
|
|
struct settings_store cf_store;
|
|
const char *cf_name; /* filename */
|
|
int cf_maxlines; /* max # of lines before compressing */
|
|
int cf_lines; /* private */
|
|
};
|
|
|
|
/* register file to be source of settings */
|
|
int settings_file_src(struct settings_file *cf);
|
|
|
|
/* settings saves go to a file */
|
|
int settings_file_dst(struct settings_file *cf);
|
|
|
|
void settings_mount_fs_backend(struct settings_file *cf);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __SETTINGS_FILE_H_ */
|