Optimize and refactor tilt counting

- Optimized tilt counting data by reducing the tilt counter variables into one for smaller memory footprint. So the `relay_chn_tilt_counter_t` type is replaced by a single `uint16_t` variable in the `relay_chn_tilt_ctl_t` structure. Hence the `relay_chn_tilt_counter_t` type has been removed since it is not necessary anymore.
- Refactored tilt count handling in NVS: consolidate forward and reverse counts into a single tilt count parameter.
- Updated NVS test files that affected by the data type and function signature changes.

Fixes #1079
This commit is contained in:
2025-08-20 10:41:30 +03:00
parent dc2aa93d2d
commit aeeda44a2c
5 changed files with 76 additions and 110 deletions

View File

@@ -68,21 +68,19 @@ esp_err_t relay_chn_nvs_get_tilt_sensitivity(uint8_t ch, uint8_t *sensitivity);
* @brief Store tilt counters in NVS.
*
* @param[in] ch Channel number.
* @param[in] forward_count Forward tilt counter value.
* @param[in] reverse_count Reverse tilt counter value.
* @param[in] tilt_count Tilt count value.
* @return ESP_OK on success, error code otherwise.
*/
esp_err_t relay_chn_nvs_set_tilt_count(uint8_t ch, uint32_t forward_count, uint32_t reverse_count);
esp_err_t relay_chn_nvs_set_tilt_count(uint8_t ch, uint16_t tilt_count);
/**
* @brief Retrieve tilt counters from NVS.
*
* @param[in] ch Channel number.
* @param[out] forward_count Pointer to store forward tilt counter.
* @param[out] reverse_count Pointer to store reverse tilt counter.
* @param[out] tilt_count Pointer to store tilt count.
* @return ESP_OK on success, error code otherwise.
*/
esp_err_t relay_chn_nvs_get_tilt_count(uint8_t ch, uint32_t *forward_count, uint32_t *reverse_count);
esp_err_t relay_chn_nvs_get_tilt_count(uint8_t ch, uint16_t *tilt_count);
#endif // RELAY_CHN_ENABLE_TILTING
/**

View File

@@ -10,8 +10,7 @@
#define RELAY_CHN_KEY_DIR "dir"
#ifdef RELAY_CHN_ENABLE_TILTING
#define RELAY_CHN_KEY_SENS(ch) "sens_%d"
#define RELAY_CHN_KEY_TFWD(ch) "tfwd_%d"
#define RELAY_CHN_KEY_TREV(ch) "trev_%d"
#define RELAY_CHN_KEY_TCNT(ch) "tcnt_%d" /*!< Tilt count key */
#endif
static const char *TAG = "RELAY_CHN_STORAGE_NVS";
@@ -85,26 +84,19 @@ esp_err_t relay_chn_nvs_get_tilt_sensitivity(uint8_t ch, uint8_t *sensitivity)
return nvs_get_u8(relay_chn_nvs, RELAY_CHN_KEY_SENS(ch), sensitivity);
}
esp_err_t relay_chn_nvs_set_tilt_count(uint8_t ch, uint32_t forward_count, uint32_t reverse_count)
esp_err_t relay_chn_nvs_set_tilt_count(uint8_t ch, uint16_t tilt_count)
{
esp_err_t ret;
ret = nvs_set_u32(relay_chn_nvs, RELAY_CHN_KEY_TFWD(ch), forward_count);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to save forward_count tilt counter");
ret = nvs_set_u32(relay_chn_nvs, RELAY_CHN_KEY_TREV(ch), reverse_count);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to save reverse_count tilt counter");
ret = nvs_set_u16(relay_chn_nvs, RELAY_CHN_KEY_TCNT(ch), tilt_count);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to save tilt_count tilt counter");
return nvs_commit(relay_chn_nvs);
}
esp_err_t relay_chn_nvs_get_tilt_count(uint8_t ch, uint32_t *forward_count, uint32_t *reverse_count)
esp_err_t relay_chn_nvs_get_tilt_count(uint8_t ch, uint16_t *tilt_count)
{
ESP_RETURN_ON_FALSE(forward_count != NULL && reverse_count != NULL,
ESP_RETURN_ON_FALSE(tilt_count != NULL,
ESP_ERR_INVALID_ARG, TAG, "Counter pointers are NULL");
esp_err_t ret = nvs_get_u32(relay_chn_nvs, RELAY_CHN_KEY_TFWD(ch), forward_count);
if (ret != ESP_OK) {
return ret; // Return error if the key does not exist
}
return nvs_get_u32(relay_chn_nvs, RELAY_CHN_KEY_TREV(ch), reverse_count);
return nvs_get_u16(relay_chn_nvs, RELAY_CHN_KEY_TCNT(ch), tilt_count);
}
#endif // RELAY_CHN_ENABLE_TILTING

View File

@@ -57,19 +57,13 @@ typedef struct {
uint32_t pause_time_ms; /*!< Pause time in milliseconds */
} relay_chn_tilt_timing_t;
/// @brief Tilt counter structure to manage tilt count.
typedef struct {
uint32_t tilt_forward_count; /*!< Tilt forward count */
uint32_t tilt_reverse_count; /*!< Tilt reverse count */
} relay_chn_tilt_counter_t;
/// @brief Tilt control structure to manage tilt operations.
typedef struct relay_chn_tilt_ctl {
relay_chn_ctl_t *chn_ctl; /*!< The relay channel control structure */
relay_chn_tilt_cmd_t cmd; /*!< The tilt command in process */
relay_chn_tilt_step_t step; /*!< Current tilt step */
relay_chn_tilt_timing_t tilt_timing; /*!< Tilt timing structure */
relay_chn_tilt_counter_t tilt_counter; /*!< Tilt counter structure */
uint16_t tilt_count; /*!< Tilt count to manage forward and reverse tilts */
esp_timer_handle_t tilt_timer; /*!< Tilt timer handle */
#if RELAY_CHN_ENABLE_NVS == 1
esp_timer_handle_t flush_timer; /*!< Flush timer to avoid frequent write of tilt counters */
@@ -401,8 +395,7 @@ uint8_t relay_chn_tilt_get_sensitivity()
void relay_chn_tilt_reset_count(relay_chn_tilt_ctl_t *tilt_ctl)
{
tilt_ctl->tilt_counter.tilt_forward_count = 0;
tilt_ctl->tilt_counter.tilt_reverse_count = 0;
tilt_ctl->tilt_count = 0;
#if RELAY_CHN_ENABLE_NVS == 1
esp_timer_stop(tilt_ctl->flush_timer);
@@ -415,74 +408,70 @@ void relay_chn_tilt_reset_count(relay_chn_tilt_ctl_t *tilt_ctl)
* This helper function updates the relevant tilt count depending on the
* last run info and helps the tilt module in deciding whether the requested
* tilt should execute or not.
* This is useful to control reverse tilting particularly. For example:
*
* This is useful to control reverse tilting for the same direction particularly.
* For example:
* - If the channel's last run was FORWARD and a TILT_FORWARD is requested,
* then the tilt counter will count up on the
* relay_chn_tilt_counter_type::tilt_forward_count and the function will
* return the actual count.
* then the tilt count will count up on the relay_chn_tilt_ctl_t::tilt_count
* and the function will return the actual count.
* - If the channel's last run was FORWARD and a TILT_REVERSE is requested,
* then the relay_chn_tilt_counter_type::tilt_forward_count will be checked
* against zero first, and then it will count down and return the actual count
* if it is greater than 0, else the function will return 0.
* then the relay_chn_tilt_ctl_t::tilt_count will be checked against zero first,
* and then it will count down and return the actual count if it is greater
* than 0, else the function will return 0.
* - If the tilt command is irrelevant then the function will return 0.
* - If the last run is irrelevant then the function will return 0.
*
* @param tilt_ctl The relay channel handle.
* @return uint32_t The actual value of the relevant counter.
*
* @return The actual value of the relevant count.
* @return 1 if the last tilt_count was 1 and decremented to 0.
* @return 0 if:
* - related counter is already 0.
* - related count is already 0.
* - tilt command is irrelevant.
* - last run info is irrelevant.
*/
static uint32_t relay_chn_tilt_count_update(relay_chn_tilt_ctl_t *tilt_ctl)
static uint16_t relay_chn_tilt_count_update(relay_chn_tilt_ctl_t *tilt_ctl)
{
relay_chn_cmd_t last_run_cmd = relay_chn_run_info_get_last_run_cmd(tilt_ctl->chn_ctl->run_info);
if (last_run_cmd == RELAY_CHN_CMD_FORWARD) {
if (tilt_ctl->cmd == RELAY_CHN_TILT_CMD_FORWARD) {
return ++tilt_ctl->tilt_counter.tilt_forward_count;
return ++tilt_ctl->tilt_count;
}
else if (tilt_ctl->cmd == RELAY_CHN_TILT_CMD_REVERSE) {
if (tilt_ctl->tilt_counter.tilt_forward_count > 0) {
--tilt_ctl->tilt_counter.tilt_forward_count;
if (tilt_ctl->tilt_count > 0) {
--tilt_ctl->tilt_count;
// Still should do one more move, return non-zero value
return 1;
}
else
return 0;
}
else {
relay_chn_tilt_reset_count(tilt_ctl);
return 0;
}
}
else if (last_run_cmd == RELAY_CHN_CMD_REVERSE) {
if (tilt_ctl->cmd == RELAY_CHN_TILT_CMD_REVERSE) {
return ++tilt_ctl->tilt_counter.tilt_reverse_count;
return ++tilt_ctl->tilt_count;
}
else if (tilt_ctl->cmd == RELAY_CHN_TILT_CMD_FORWARD) {
if (tilt_ctl->tilt_counter.tilt_reverse_count > 0) {
--tilt_ctl->tilt_counter.tilt_reverse_count;
if (tilt_ctl->tilt_count > 0) {
--tilt_ctl->tilt_count;
// Still should do one more move, return non-zero value
return 1;
}
else
return 0;
}
else {
relay_chn_tilt_reset_count(tilt_ctl);
return 0;
}
}
// Irrelevant case -> reset
tilt_ctl->tilt_count = 0;
return 0;
}
#if RELAY_CHN_ENABLE_NVS == 1
static esp_err_t relay_chn_tilt_save_tilt_counter(relay_chn_tilt_ctl_t *tilt_ctl)
static esp_err_t relay_chn_tilt_save_tilt_count(relay_chn_tilt_ctl_t *tilt_ctl)
{
// Save the tilt count to NVS storage
esp_err_t ret = relay_chn_nvs_set_tilt_count(tilt_ctl->chn_ctl->id,
tilt_ctl->tilt_counter.tilt_forward_count,
tilt_ctl->tilt_counter.tilt_reverse_count);
esp_err_t ret = relay_chn_nvs_set_tilt_count(tilt_ctl->chn_ctl->id, tilt_ctl->tilt_count);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "relay_chn_tilt_execute_stop: Failed to save tilt count for channel #%d: %s", tilt_ctl->chn_ctl->id, esp_err_to_name(ret));
}
@@ -494,7 +483,7 @@ static void relay_chn_tilt_flush_timer_cb(void *arg)
relay_chn_tilt_ctl_t* tilt_ctl = (relay_chn_tilt_ctl_t*) arg;
ESP_RETURN_VOID_ON_FALSE(tilt_ctl != NULL, TAG, "relay_chn_tilt_flush_timer_cb: timer arg is NULL");
// Save the tilt count to storage
esp_err_t ret = relay_chn_tilt_save_tilt_counter(tilt_ctl);
esp_err_t ret = relay_chn_tilt_save_tilt_count(tilt_ctl);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "relay_chn_tilt_execute_stop: Failed to save tilt count for channel #%d: %s", tilt_ctl->chn_ctl->id, esp_err_to_name(ret));
}
@@ -558,7 +547,7 @@ static void relay_chn_tilt_execute_pause(relay_chn_tilt_ctl_t *tilt_ctl)
return;
}
// Update the tilt counter before the next move and expect the return value to be greater than 0
// Update the tilt count before the next move and expect the return value to be greater than 0
if (relay_chn_tilt_count_update(tilt_ctl) == 0) {
ESP_LOGD(TAG, "relay_chn_tilt_execute_pause: Relay channel cannot tilt anymore");
// Stop tilting since the tilting limit has been reached
@@ -640,13 +629,12 @@ static esp_err_t relay_chn_tilt_load_sensitivity(uint8_t ch, uint8_t *sensitivit
return ESP_OK;
}
static esp_err_t relay_chn_tilt_load_tilt_counter(uint8_t ch, relay_chn_tilt_counter_t *tilt_counter)
static esp_err_t relay_chn_tilt_load_tilt_count(uint8_t ch, uint16_t *tilt_count)
{
esp_err_t ret = relay_chn_nvs_get_tilt_count(ch, &tilt_counter->tilt_forward_count, &tilt_counter->tilt_reverse_count);
esp_err_t ret = relay_chn_nvs_get_tilt_count(ch, tilt_count);
if (ret == ESP_ERR_NVS_NOT_FOUND) {
ESP_LOGD(TAG, "relay_chn_tilt_load_tilt_counter: No tilt counters found in NVS for channel %d, initializing to zero", ch);
tilt_counter->tilt_forward_count = 0;
tilt_counter->tilt_reverse_count = 0;
ESP_LOGD(TAG, "relay_chn_tilt_load_tilt_count: No tilt count found in NVS for channel %d, initializing to zero", ch);
tilt_count = 0;
return ESP_OK;
}
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt counters for channel %d", ch);
@@ -654,15 +642,15 @@ static esp_err_t relay_chn_tilt_load_tilt_counter(uint8_t ch, relay_chn_tilt_cou
}
#endif // RELAY_CHN_ENABLE_NVS
static esp_err_t relay_chn_tilt_ctl_init(relay_chn_tilt_ctl_t *tilt_ctl, relay_chn_ctl_t *chn_ctl,
relay_chn_tilt_counter_t *tilt_counter, uint8_t sensitivity)
static esp_err_t relay_chn_tilt_ctl_init(relay_chn_tilt_ctl_t *tilt_ctl,
relay_chn_ctl_t *chn_ctl,
uint16_t tilt_count ,
uint8_t sensitivity)
{
tilt_ctl->cmd = RELAY_CHN_TILT_CMD_NONE;
tilt_ctl->step = RELAY_CHN_TILT_STEP_NONE;
relay_chn_tilt_compute_set_sensitivity(tilt_ctl, sensitivity);
// Init tilt counters
tilt_ctl->tilt_counter.tilt_forward_count = tilt_counter->tilt_forward_count;
tilt_ctl->tilt_counter.tilt_reverse_count = tilt_counter->tilt_reverse_count;
tilt_ctl->tilt_count = tilt_count;
tilt_ctl->chn_ctl = chn_ctl;
tilt_ctl->chn_ctl->tilt_ctl = tilt_ctl;
@@ -692,33 +680,31 @@ static esp_err_t relay_chn_tilt_ctl_init(relay_chn_tilt_ctl_t *tilt_ctl, relay_c
esp_err_t relay_chn_tilt_init(relay_chn_ctl_t *chn_ctls)
{
uint8_t sensitivity;
relay_chn_tilt_counter_t tilt_counter;
uint16_t tilt_count;
#if RELAY_CHN_COUNT > 1
for (int i = 0; i < RELAY_CHN_COUNT; i++) {
#if RELAY_CHN_ENABLE_NVS == 1
esp_err_t ret = relay_chn_tilt_load_sensitivity(i, &sensitivity);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt sensitivity for channel %d", i);
ret = relay_chn_tilt_load_tilt_counter(i, &tilt_counter);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt counters for channel %d", i);
ret = relay_chn_tilt_load_tilt_count(i, &tilt_count);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt count for channel %d", i);
#else
sensitivity = RELAY_CHN_TILT_DEFAULT_SENSITIVITY;
tilt_counter.tilt_forward_count = 0;
tilt_counter.tilt_reverse_count = 0;
tilt_count = 0;
#endif // RELAY_CHN_ENABLE_NVS == 1
relay_chn_tilt_ctl_init(&tilt_ctls[i], &chn_ctls[i], &tilt_counter, sensitivity);
}
relay_chn_tilt_ctl_init(&tilt_ctls[i], &chn_ctls[i], tilt_count, sensitivity);
}
#else
sensitivity = RELAY_CHN_TILT_DEFAULT_SENSITIVITY;
tilt_counter.tilt_forward_count = 0;
tilt_counter.tilt_reverse_count = 0;
tilt_count = 0;
#if RELAY_CHN_ENABLE_NVS == 1
esp_err_t ret = relay_chn_tilt_load_sensitivity(0, &sensitivity);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt sensitivity for channel %d", 0);
ret = relay_chn_tilt_load_tilt_counter(0, &tilt_counter);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt counters for channel %d", 0);
ret = relay_chn_tilt_load_tilt_count(0, &tilt_count);
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load tilt count for channel %d", 0);
#endif // RELAY_CHN_ENABLE_NVS == 1
relay_chn_tilt_ctl_init(&tilt_ctl, chn_ctls, &tilt_counter, sensitivity);
relay_chn_tilt_ctl_init(&tilt_ctl, chn_ctls, tilt_count, sensitivity);
#endif // RELAY_CHN_COUNT > 1
return esp_event_handler_register_with(relay_chn_event_loop,

View File

@@ -62,7 +62,7 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
uint8_t sensitivity = 50;
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(0, sensitivity));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, 100, 200));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, 100));
}
#endif
@@ -77,8 +77,8 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
uint8_t read_sensitivity;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_sensitivity(0, &read_sensitivity));
uint32_t fwd_count, rev_count;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_count(0, &fwd_count, &rev_count));
uint16_t tilt_count;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_count(0, &tilt_count));
#endif
TEST_ESP_OK(relay_chn_nvs_deinit());
@@ -106,17 +106,15 @@ TEST_CASE("Test tilt counter operations", "[relay_chn][nvs][tilt]")
{
TEST_ESP_OK(relay_chn_nvs_init());
const uint32_t fwd_count = 100;
const uint32_t rev_count = 200;
uint32_t fwd_read, rev_read;
const uint16_t tilt_count = 100;
uint16_t tilt_count_read;
// Test all channels
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
// Test setting counters
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(channel, fwd_count, rev_count));
TEST_ESP_OK(relay_chn_nvs_get_tilt_count(channel, &fwd_read, &rev_read));
TEST_ASSERT_EQUAL(fwd_count, fwd_read);
TEST_ASSERT_EQUAL(rev_count, rev_read);
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(channel, tilt_count));
TEST_ESP_OK(relay_chn_nvs_get_tilt_count(channel, &tilt_count_read));
TEST_ASSERT_EQUAL(tilt_count, tilt_count_read);
}
TEST_ESP_OK(relay_chn_nvs_deinit());
@@ -126,13 +124,10 @@ TEST_CASE("Test tilting invalid parameters", "[relay_chn][nvs][tilt]")
{
TEST_ESP_OK(relay_chn_nvs_init());
uint32_t fwd_count, rev_count;
// Test NULL pointers for all channels
for (int channel = 0; channel < RELAY_CHN_COUNT; channel++) {
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_sensitivity(channel, NULL));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(channel, NULL, &rev_count));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(channel, &fwd_count, NULL));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(channel, NULL));
}
TEST_ESP_OK(relay_chn_nvs_deinit());

View File

@@ -56,7 +56,7 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
#ifdef RELAY_CHN_ENABLE_TILTING
uint8_t sensitivity = 50;
TEST_ESP_OK(relay_chn_nvs_set_tilt_sensitivity(0, sensitivity));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, 100, 200));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, 100));
#endif
// Test erase all
@@ -70,8 +70,8 @@ TEST_CASE("Test relay_chn_nvs_erase_all", "[relay_chn][nvs]")
uint8_t read_sensitivity;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_sensitivity(0, &read_sensitivity));
uint32_t fwd_count, rev_count;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_count(0, &fwd_count, &rev_count));
uint16_t tilt_count;
TEST_ASSERT_EQUAL(ESP_ERR_NVS_NOT_FOUND, relay_chn_nvs_get_tilt_count(0, &tilt_count));
#endif
TEST_ESP_OK(relay_chn_nvs_deinit());
@@ -96,16 +96,14 @@ TEST_CASE("Test tilt counter operations", "[relay_chn][nvs][tilt]")
{
TEST_ESP_OK(relay_chn_nvs_init());
const uint32_t fwd_count = 100;
const uint32_t rev_count = 200;
const uint16_t tilt_count = 100;
// Test setting counters
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, fwd_count, rev_count));
TEST_ESP_OK(relay_chn_nvs_set_tilt_count(0, tilt_count));
uint32_t fwd_read, rev_read;
TEST_ESP_OK(relay_chn_nvs_get_tilt_count(0, &fwd_read, &rev_read));
TEST_ASSERT_EQUAL(fwd_count, fwd_read);
TEST_ASSERT_EQUAL(rev_count, rev_read);
uint16_t tilt_count_read;
TEST_ESP_OK(relay_chn_nvs_get_tilt_count(0, &tilt_count_read));
TEST_ASSERT_EQUAL(tilt_count, tilt_count_read);
TEST_ESP_OK(relay_chn_nvs_deinit());
}
@@ -114,12 +112,9 @@ TEST_CASE("Test tilting invalid parameters", "[relay_chn][nvs][tilt]")
{
TEST_ESP_OK(relay_chn_nvs_init());
uint32_t fwd_count, rev_count;
// Test NULL pointers
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_sensitivity(0, NULL));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(0, NULL, &rev_count));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(0, &fwd_count, NULL));
TEST_ASSERT_EQUAL(ESP_ERR_INVALID_ARG, relay_chn_nvs_get_tilt_count(0, NULL));
TEST_ESP_OK(relay_chn_nvs_deinit());
}