Function esp_idf_svc::sys::nvs_set_str
source · pub unsafe extern "C" fn nvs_set_str(
handle: u32,
key: *const i8,
value: *const i8,
) -> i32
Expand description
@brief set string for given key
Sets string value for the key. Function requires whole space for new data to be available as contiguous entries in same nvs page. Operation consumes 1 overhead entry and 1 entry per each 32 characters of new string including zero character to be set. In case of value update for existing key, entries occupied by the previous value and overhead entry are returned to the pool of available entries. Note that storage of long string values can fail due to fragmentation of nvs pages even if \c available_entries returned by \c nvs_get_stats suggests enough overall space available. Note that the underlying storage will not be updated until \c nvs_commit is called.
@param[in] handle Handle obtained from nvs_open function. Handles that were opened read only cannot be used. @param[in] key Key name. Maximum length is (NVS_KEY_NAME_MAX_SIZE-1) characters. Shouldn’t be empty. @param[in] value The value to set. For strings, the maximum length (including null character) is 4000 bytes, if there is one complete page free for writing. This decreases, however, if the free space is fragmented.
@return - ESP_OK if value was set successfully - 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. - ESP_ERR_NVS_VALUE_TOO_LONG if the string value is too long