Confing#

Functions

int config_init(struct kvstore *nvs, config_save_cb_t cb, void *cb_ctx)#

Initializes the configuration module.

Parameters:
  • nvs[in] Handle to the non-volatile storage.

  • cb[in] Callback function for configuration save events.

  • cb_ctx[in] Context to be passed to the callback function.

Returns:

0 on success, negative error code on failure.

int config_get(const char *key, void *buf, size_t bufsize)#

Reads a configuration value.

Parameters:
  • key[in] Configuration key string (e.g., “device.id”).

  • buf[out] Buffer to store the retrieved value.

  • bufsize[in] Size of the buffer.

Returns:

0 on success, negative error code on failure.

int config_set(const char *key, const void *data, size_t datasize)#

Writes a configuration value.

Parameters:
  • key[in] Configuration key string (e.g., “device.id”).

  • data[in] Data to be written.

  • datasize[in] Size of the data to be written.

Returns:

0 on success, negative error code on failure.

int config_read_all(struct config *cfg)#

Reads all configuration settings.

Parameters:

cfg[out] A pointer to the config structure where the settings will be stored.

Returns:

int Returns 0 on success, or a negative error code on failure.

int config_write_all(const struct config *cfg)#

Writes all configuration settings.

Parameters:

cfg – A pointer to the config structure containing the settings to be written.

Returns:

int Returns 0 on success, or a negative error code on failure.

int config_save(void)#

Saves the modified configuration values.

Returns:

0 on success, negative error code on failure.

int config_set_and_save(const char *key, const void *data, size_t datasize)#

Writes a configuration value and saves it.

This function sets the configuration value associated with the given key and saves the configuration to persistent storage.

Parameters:
  • key[in] Configuration key string (e.g., “device.id”).

  • data[in] Data to be written.

  • datasize[in] Size of the data to be written.

Returns:

0 on success, negative error code on failure.

int config_reset(const char *key)#

Resets a specific configuration key to its default value.

Parameters:

key[in] Configuration key to reset (NULL resets all configurations).

Returns:

0 on success, negative error code on failure.

int config_update_json(const char *json, size_t json_len)#

Updates configuration values using a JSON string.

Parameters:
  • json[in] JSON-formatted configuration string.

  • json_len[in] Length of the JSON string.

Returns:

0 on success, negative error code on failure.

bool config_is_zeroed(const char *key)#

Checks if the configuration setting for the given key is zeroed.

This function does not support custom settings. If the key corresponds to a custom setting, the function will return false.

Warning

Be cautious when using this function to determine initialization status, as the actual configuration value might be zero.

Parameters:

key[in] The key of the configuration setting to check.

Returns:

bool Returns true if the configuration setting is zeroed, false otherwise.

Typedefs

typedef void (*config_save_cb_t)(void *ctx)#
struct config_charger#
#include <config.h>

Public Members

char mode[CONFIG_CHARGER_MODE_MAXLEN]#
uint8_t param[16]#
uint8_t connector_count#
uint8_t metering[16]#
uint8_t pilot[30]#
uint8_t plc_mac[6]#
struct config_charger connector[CONFIG_CHARGER_CONNECTOR_MAX]#
struct config_net#
#include <config.h>

Public Members

uint8_t mac[6]#
uint32_t health_check_interval#
uint32_t ping_interval#
char server_url[256]#
char server_id[32]#
char server_pass[40]#
struct config_ocpp#
#include <config.h>

Public Members

uint32_t version#
uint8_t config[546]#
uint8_t checkpoint[16]#
char vendor[20 + 1]#
char model[20 + 1]#
struct config#
#include <config.h>

Public Members

uint32_t version#
char device_id[CONFIG_DEVICE_ID_MAXLEN]#
char device_name[CONFIG_DEVICE_NAME_MAXLEN]#
uint8_t device_mode#
uint8_t log_mode#
uint8_t log_level#
bool dfu_reboot_manually#
struct config_charger charger#
struct config_net net#
struct config_ocpp ocpp#
uint32_t crc#

Defines

CONFIG_VERSION MAKE_VERSION(0, 0, 1)#
CONFIG_DEVICE_ID_MAXLEN 24#
CONFIG_DEVICE_NAME_MAXLEN 32#
CONFIG_CHARGER_MODE_MAXLEN 8#
CONFIG_CHARGER_CONNECTOR_MAX 1#
CONFIG_X509_MAXLEN 2048#