Browse Source

Storage: Add function to delete entry

Helmut Pozimski 1 year ago
parent
commit
b959fa8e8a
2 changed files with 6 additions and 0 deletions
  1. 5 0
      main/storage.c
  2. 1 0
      main/storage.h

+ 5 - 0
main/storage.c

@@ -46,6 +46,11 @@ esp_err_t read_wakeup_time_tm(struct tm* datetime, uint16_t* value) {
 	return read_wakeup_time_str(key, value);
 }
 
+esp_err_t delete_wakeup_time_str(char* key) {
+	esp_err_t ret = nvs_erase_key(handle, key);
+	return ret | nvs_commit(handle);
+}
+
 void delete_outdated_entries(struct tm* datetime, char* namespace) {
 	char reference_date_str[9];
 	format_date(datetime, reference_date_str);

+ 1 - 0
main/storage.h

@@ -14,4 +14,5 @@ esp_err_t write_wakeup_time_tm(struct tm* datetime, uint16_t value);
 esp_err_t write_wakeup_time_str(char* key, uint16_t value);
 esp_err_t read_wakeup_time_tm(struct tm* datetime, uint16_t* value);
 esp_err_t read_wakeup_time_str(char* key, uint16_t* value);
+esp_err_t delete_wakeup_time_str(char* key);
 void delete_outdated_entries(struct tm* datetime, char* namespace);