Use original names for config parameters
The config parameter names defined in the relay_chn_defs.h file have been changed back to their original names (with the CONFIG_ prefix), so that they are not confused with application-level defines. Refs #1085
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
#include "relay_chn_nvs.h"
|
||||
|
||||
#define RELAY_CHN_KEY_DIR "dir" /*!< Direction key */
|
||||
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
#define RELAY_CHN_KEY_RLIM(ch) "rlim_%d" /*!< Run limit key */
|
||||
#endif
|
||||
#ifdef RELAY_CHN_ENABLE_TILTING
|
||||
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
|
||||
#define RELAY_CHN_KEY_TSENS(ch) "tsens_%d" /*!< Tilt sensitivity key */
|
||||
#define RELAY_CHN_KEY_TCNT(ch) "tcnt_%d" /*!< Tilt count key */
|
||||
#endif
|
||||
@@ -23,22 +23,22 @@ static nvs_handle_t relay_chn_nvs;
|
||||
esp_err_t relay_chn_nvs_init()
|
||||
{
|
||||
esp_err_t ret;
|
||||
#if RELAY_CHN_NVS_CUSTOM_PARTITION == 1
|
||||
ret = nvs_open_from_partition(RELAY_CHN_NVS_CUSTOM_PARTITION_NAME,
|
||||
RELAY_CHN_NVS_NAMESPACE,
|
||||
#if CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION == 1
|
||||
ret = nvs_open_from_partition(CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION_NAME,
|
||||
CONFIG_RELAY_CHN_NVS_NAMESPACE,
|
||||
NVS_READWRITE,
|
||||
&relay_chn_nvs);
|
||||
|
||||
ESP_RETURN_ON_ERROR(ret,
|
||||
TAG,
|
||||
"Failed to open NVS namespace '%s' from partition '%s' with error %s",
|
||||
RELAY_CHN_NVS_NAMESPACE,
|
||||
RELAY_CHN_NVS_CUSTOM_PARTITION_NAME,
|
||||
CONFIG_RELAY_CHN_NVS_NAMESPACE,
|
||||
CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION_NAME,
|
||||
esp_err_to_name(ret));
|
||||
#else
|
||||
ret = nvs_open(RELAY_CHN_NVS_NAMESPACE, NVS_READWRITE, &relay_chn_nvs);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to open NVS namespace '%s'", RELAY_CHN_NVS_NAMESPACE);
|
||||
#endif // RELAY_CHN_NVS_CUSTOM_PARTITION
|
||||
ret = nvs_open(CONFIG_RELAY_CHN_NVS_NAMESPACE, NVS_READWRITE, &relay_chn_nvs);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to open NVS namespace '%s'", CONFIG_RELAY_CHN_NVS_NAMESPACE);
|
||||
#endif // CONFIG_RELAY_CHN_NVS_CUSTOM_PARTITION
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ esp_err_t relay_chn_nvs_get_direction(uint8_t ch, relay_chn_direction_t *directi
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
#if CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
esp_err_t relay_chn_nvs_set_run_limit(uint8_t ch, uint16_t time_sec)
|
||||
{
|
||||
esp_err_t ret = nvs_set_u16(relay_chn_nvs, RELAY_CHN_KEY_RLIM(ch), time_sec);
|
||||
@@ -86,9 +86,9 @@ esp_err_t relay_chn_nvs_get_run_limit(uint8_t ch, uint16_t *time_sec)
|
||||
|
||||
return nvs_get_u16(relay_chn_nvs, RELAY_CHN_KEY_RLIM(ch), time_sec);
|
||||
}
|
||||
#endif // RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
#endif // CONFIG_RELAY_CHN_ENABLE_RUN_LIMIT == 1
|
||||
|
||||
#ifdef RELAY_CHN_ENABLE_TILTING
|
||||
#ifdef CONFIG_RELAY_CHN_ENABLE_TILTING
|
||||
esp_err_t relay_chn_nvs_set_tilt_sensitivity(uint8_t ch, uint8_t sensitivity)
|
||||
{
|
||||
esp_err_t ret = nvs_set_u8(relay_chn_nvs, RELAY_CHN_KEY_TSENS(ch), sensitivity);
|
||||
@@ -117,13 +117,13 @@ esp_err_t relay_chn_nvs_get_tilt_count(uint8_t ch, uint16_t *tilt_count)
|
||||
ESP_ERR_INVALID_ARG, TAG, "Counter pointers are NULL");
|
||||
return nvs_get_u16(relay_chn_nvs, RELAY_CHN_KEY_TCNT(ch), tilt_count);
|
||||
}
|
||||
#endif // RELAY_CHN_ENABLE_TILTING
|
||||
#endif // CONFIG_RELAY_CHN_ENABLE_TILTING
|
||||
|
||||
esp_err_t relay_chn_nvs_erase_all()
|
||||
{
|
||||
// Erase all key-value pairs in the relay_chn NVS namespace
|
||||
esp_err_t ret = nvs_erase_all(relay_chn_nvs);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to erase all keys in NVS namespace '%s'", RELAY_CHN_NVS_NAMESPACE);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to erase all keys in NVS namespace '%s'", CONFIG_RELAY_CHN_NVS_NAMESPACE);
|
||||
|
||||
// Commit the changes
|
||||
return nvs_commit(relay_chn_nvs);
|
||||
|
||||
Reference in New Issue
Block a user