My climat station
NVStore Class Reference
#include <nvstore.h>
Inherits NonCopyable< NVStore >.
Public Member Functions | |
| uint16_t | get_max_keys () const |
| Returns number of keys. | |
| void | set_max_keys (uint16_t num_keys) |
| Set number of keys. | |
| uint16_t | get_max_possible_keys () |
| Return maximal possible number of keys (in this flash configuration). | |
| int | get (uint16_t key, uint16_t buf_size, void *buf, uint16_t &actual_size) |
| Returns one item of data programmed on Flash, given key. | |
| int | get_item_size (uint16_t key, uint16_t &actual_size) |
| Returns size of the data programmed on Flash, given key. | |
| int | set (uint16_t key, uint16_t buf_size, const void *buf) |
| Programs one item of data on Flash, given key. | |
| int | set_alloc_key (uint16_t &key, uint16_t buf_size, const void *buf) |
| Programs one item of data on Flash, allocating a key. | |
| int | set_once (uint16_t key, uint16_t buf_size, const void *buf) |
| Programs one item of data on Flash, given key, allowing no consequent sets to this key. | |
| int | remove (uint16_t key) |
| Remove an item from flash. | |
| int | init () |
| Initializes NVStore component. | |
| int | deinit () |
| Deinitializes NVStore component. | |
| int | reset () |
| Reset Flash NVStore areas. | |
| size_t | size () |
| Return NVStore size (area size). | |
| int | get_area_params (uint8_t area, uint32_t &address, size_t &size) |
| Return address and size of an NVStore area. | |
Static Public Member Functions | |
| static NVStore & | get_instance () |
| As a singleton, return the single instance of the class. | |
Private Member Functions | |
| MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &) | |
| NonCopyable copy constructor. | |
| MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator | |
| NonCopyable copy assignment operator. | |
Detailed Description
NVStore class.
Class for storing data by keys in the internal flash
Definition at line 68 of file nvstore.h.
Member Function Documentation
| int deinit | ( | ) |
Deinitializes NVStore component.
Warning: This function is not thread safe and should not be called concurrently with other NVStore functions.
- Returns:
- NVSTORE_SUCCESS Deinitialization completed successfully.
Definition at line 879 of file nvstore.cpp.
| int get | ( | uint16_t | key, |
| uint16_t | buf_size, | ||
| void * | buf, | ||
| uint16_t & | actual_size | ||
| ) |
Returns one item of data programmed on Flash, given key.
- Parameters:
-
[in] key Key of stored item. [in] buf_size Length of input buffer in bytes. [in] buf Buffer to store data on. [out] actual_size Actual size of returned data.
- Returns:
- NVSTORE_SUCCESS Value was found on Flash. NVSTORE_NOT_FOUND Value was not found on Flash. NVSTORE_READ_ERROR Physical error reading data. NVSTORE_DATA_CORRUPT Data on Flash is corrupt. NVSTORE_BAD_VALUE Bad value in any of the parameters. NVSTORE_BUFF_TOO_SMALL Not enough memory in user buffer.
Definition at line 621 of file nvstore.cpp.
| int get_area_params | ( | uint8_t | area, |
| uint32_t & | address, | ||
| size_t & | size | ||
| ) |
Return address and size of an NVStore area.
- Parameters:
-
[in] area Area. [out] address Area address. [out] size Area size (bytes).
- Returns:
- NVSTORE_SUCCESS Success. NVSTORE_BAD_VALUE Bad area parameter.
Definition at line 921 of file nvstore.cpp.
| static NVStore& get_instance | ( | ) | [static] |
As a singleton, return the single instance of the class.
Reason for this class being a singleton is the following:
- Ease the use for users of this class not having to coordinate instantiations.
- Lazy instantiation of internal data (which we can't achieve with simple static classes).
- Returns:
- Singleton instance reference.
| int get_item_size | ( | uint16_t | key, |
| uint16_t & | actual_size | ||
| ) |
Returns size of the data programmed on Flash, given key.
- Parameters:
-
[in] key Key of stored item. [out] actual_size Actual size of item
- Returns:
- NVSTORE_SUCCESS Value was found on Flash. NVSTORE_NOT_FOUND Value was not found on Flash. NVSTORE_READ_ERROR Physical error reading data. NVSTORE_DATA_CORRUPT Data on Flash is corrupt. NVSTORE_BAD_VALUE Bad value in any of the parameters.
Definition at line 626 of file nvstore.cpp.
| uint16_t get_max_keys | ( | ) | const |
| uint16_t get_max_possible_keys | ( | ) |
Return maximal possible number of keys (in this flash configuration).
- Returns:
- Max possible number of keys.
Definition at line 152 of file nvstore.cpp.
| int init | ( | ) |
Initializes NVStore component.
- Returns:
- NVSTORE_SUCCESS Initialization completed successfully. NVSTORE_READ_ERROR Physical error reading data. NVSTORE_WRITE_ERROR Physical error writing data (on recovery). NVSTORE_FLASH_AREA_TOO_SMALL Not enough space in Flash area.
Definition at line 730 of file nvstore.cpp.
| int remove | ( | uint16_t | key ) |
Remove an item from flash.
- Parameters:
-
[in] key Key of stored item.
- Returns:
- NVSTORE_SUCCESS Value was successfully written on Flash. NVSTORE_WRITE_ERROR Physical error writing data. NVSTORE_BAD_VALUE Bad value in any of the parameters. NVSTORE_FLASH_AREA_TOO_SMALL Not enough space in Flash area.
Definition at line 725 of file nvstore.cpp.
| int reset | ( | void | ) |
Reset Flash NVStore areas.
Warning: This function is not thread safe and should not be called concurrently with other NVStore functions.
- Returns:
- NVSTORE_SUCCESS Reset completed successfully. NVSTORE_READ_ERROR Physical error reading data. NVSTORE_WRITE_ERROR Physical error writing data.
Definition at line 898 of file nvstore.cpp.
| int set | ( | uint16_t | key, |
| uint16_t | buf_size, | ||
| const void * | buf | ||
| ) |
Programs one item of data on Flash, given key.
- Parameters:
-
[in] key Key of stored item. [in] buf_size Item size in bytes. [in] buf Buffer containing data.
- Returns:
- NVSTORE_SUCCESS Value was successfully written on Flash. NVSTORE_WRITE_ERROR Physical error writing data. NVSTORE_BAD_VALUE Bad value in any of the parameters. NVSTORE_FLASH_AREA_TOO_SMALL Not enough space in Flash area. NVSTORE_ALREADY_EXISTS Item set with write once API already exists.
Definition at line 709 of file nvstore.cpp.
| int set_alloc_key | ( | uint16_t & | key, |
| uint16_t | buf_size, | ||
| const void * | buf | ||
| ) |
Programs one item of data on Flash, allocating a key.
- Parameters:
-
[out] key Returned key of stored item. [in] buf_size Item size in bytes. [in] buf Buffer containing data.
- Returns:
- NVSTORE_SUCCESS Value was successfully written on Flash. NVSTORE_WRITE_ERROR Physical error writing data. NVSTORE_BAD_VALUE Bad value in any of the parameters. NVSTORE_FLASH_AREA_TOO_SMALL Not enough space in Flash area. NVSTORE_ALREADY_EXISTS Item set with write once API already exists. NVSTORE_NO_FREE_KEY Couldn't allocate a key for this call.
Definition at line 719 of file nvstore.cpp.
| void set_max_keys | ( | uint16_t | num_keys ) |
| int set_once | ( | uint16_t | key, |
| uint16_t | buf_size, | ||
| const void * | buf | ||
| ) |
Programs one item of data on Flash, given key, allowing no consequent sets to this key.
- Parameters:
-
[in] key Key of stored item. [in] buf_size Item size in bytes. [in] buf Buffer containing data.
- Returns:
- NVSTORE_SUCCESS Value was successfully written on Flash. NVSTORE_WRITE_ERROR Physical error writing data. NVSTORE_BAD_VALUE Bad value in any of the parameters. NVSTORE_FLASH_AREA_TOO_SMALL Not enough space in Flash area. NVSTORE_ALREADY_EXISTS Item set with write once API already exists.
Definition at line 714 of file nvstore.cpp.
| size_t size | ( | ) |
Generated on Tue Jul 12 2022 14:26:51 by
1.7.2
Gleb Klochkov