set int8_t value for given key Set value for the key, given its name. Note that the actual storage will not be updated until \c nvs_commit is called. Regardless whether key-value pair is created or updated, function always requires at least one nvs available entry. See \c nvs_get_stats . After create type of operation, the number of available entries is decreased by one. After update type of operation, the number of available entries remains the same.
Handle obtained from nvs_open function. Handles that were opened read only cannot be used.
key
Key name. Maximum length is (NVS_KEY_NAME_MAX_SIZE-1) characters. Shouldn't be empty.
value
The value to set.
Return value
- ESP_OK if value was set successfully - ESP_FAIL if there is an internal error; most likely due to corrupted NVS partition (only if NVS assertion checks are disabled) - ESP_ERR_NVS_INVALID_HANDLE if handle has been closed or is NULL - ESP_ERR_NVS_READ_ONLY if storage handle was opened as read only - ESP_ERR_NVS_INVALID_NAME if key name doesn't satisfy constraints - ESP_ERR_NVS_NOT_ENOUGH_SPACE if there is not enough space in the underlying storage to save the value - ESP_ERR_NVS_REMOVE_FAILED if the value wasn't updated because flash write operation has failed. The value was written however, and update will be finished after re-initialization of nvs, provided that flash operation doesn't fail again.
Examples
nvs_set_i8() is referenced by 2 libraries and example projects: