Trident IoT Z-Wave SDK
 
Loading...
Searching...
No Matches
Zpal-nvm

Defines a platform abstraction layer for the Z-Wave NVM. More...

+ Collaboration diagram for Zpal-nvm:

Typedefs

typedef uint32_t zpal_nvm_object_key_t
 Data id type. Only the 20 least significant bits are used.
 
typedef void * zpal_nvm_handle_t
 Defines the NVM handle type.
 

Enumerations

enum  zpal_nvm_area_t {
  ZPAL_NVM_AREA_APPLICATION ,
  ZPAL_NVM_AREA_ZAF ,
  ZPAL_NVM_AREA_STACK ,
  ZPAL_NVM_AREA_MANUFACTURER_TOKENS
}
 Defines the different areas of NVM storage. More...
 

Functions

zpal_nvm_handle_t zpal_nvm_init (zpal_nvm_area_t area)
 Initializes the NVM for a given area.
 
zpal_status_t zpal_nvm_close (zpal_nvm_handle_t handle)
 Closes the NVM of a given handle.
 
zpal_status_t zpal_nvm_read (zpal_nvm_handle_t handle, zpal_nvm_object_key_t key, void *object, size_t object_size)
 Reads object from a given area handle and given object key.
 
zpal_status_t zpal_nvm_read_object_part (zpal_nvm_handle_t handle, zpal_nvm_object_key_t key, void *object, size_t offset, size_t object_size)
 Reads part of object from a given area handle and given object key.
 
zpal_status_t zpal_nvm_write (zpal_nvm_handle_t handle, zpal_nvm_object_key_t key, const void *object, size_t object_size)
 Writes object to a given area handle and given object key.
 
zpal_status_t zpal_nvm_erase_all (zpal_nvm_handle_t handle)
 Erases everything in a given area.
 
zpal_status_t zpal_nvm_erase_object (zpal_nvm_handle_t handle, zpal_nvm_object_key_t key)
 Delete an object from NVM.
 
zpal_status_t zpal_nvm_get_object_size (zpal_nvm_handle_t handle, zpal_nvm_object_key_t key, size_t *len)
 Get the object size identified with a given key from NVM.
 
size_t zpal_nvm_enum_objects (zpal_nvm_handle_t handle, zpal_nvm_object_key_t *key_list, size_t key_list_size, zpal_nvm_object_key_t key_min, zpal_nvm_object_key_t key_max)
 Create a list of key for valid objects in NVM.
 
zpal_status_t zpal_nvm_backup_open (void)
 Opens the NVM for a backup/restore operation.
 
void zpal_nvm_backup_close (void)
 Closes the NVM after backup/restore operation.
 
zpal_status_t zpal_nvm_backup_read (uint32_t offset, void *data, size_t data_length)
 Reads raw data from the NVM.
 
zpal_status_t zpal_nvm_backup_write (uint32_t offset, const void *data, size_t data_length)
 Writes raw data to the NVM.
 
size_t zpal_nvm_backup_get_size (void)
 Get size of raw NVM area.
 
zpal_status_t zpal_nvm_lock (zpal_nvm_handle_t handle)
 Set write protection for storage.
 
zpal_status_t zpal_nvm_migrate_legacy_app_file_system (void)
 Migrates 800s legacy application file system to shared app/protocol file system.
 

Detailed Description

Defines a platform abstraction layer for the Z-Wave NVM.

How to use the entropy API

The ZPAL NVM provides a way for an application to safely store and retrieve variable size data in a page-based non-volatile memory (NVM). Data are identified with 20-bit identifiers denoted as data_id.

The following outlines an example of use:

  1. Initialize module with zpal_nvm_init().
  2. Invoke zpal_nvm_write() to store data.
  3. Invoke zpal_nvm_read() to get data.

Typedef Documentation

◆ zpal_nvm_handle_t

typedef void* zpal_nvm_handle_t

Defines the NVM handle type.

◆ zpal_nvm_object_key_t

typedef uint32_t zpal_nvm_object_key_t

Data id type. Only the 20 least significant bits are used.

Enumeration Type Documentation

◆ zpal_nvm_area_t

Defines the different areas of NVM storage.

Enumerator
ZPAL_NVM_AREA_APPLICATION 

Reserved for application data.

ZPAL_NVM_AREA_ZAF 

Reserved for ZAF data.

ZPAL_NVM_AREA_STACK 

Reserved for stack data.

ZPAL_NVM_AREA_MANUFACTURER_TOKENS 

Reserved for manufacturer tokens.

Function Documentation

◆ zpal_nvm_backup_close()

void zpal_nvm_backup_close ( void )

Closes the NVM after backup/restore operation.

◆ zpal_nvm_backup_get_size()

size_t zpal_nvm_backup_get_size ( void )

Get size of raw NVM area.

Returns
Size of raw NVM area.

◆ zpal_nvm_backup_open()

zpal_status_t zpal_nvm_backup_open ( void )

Opens the NVM for a backup/restore operation.

Returns
ZPAL_STATUS_OK on success and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_backup_read()

zpal_status_t zpal_nvm_backup_read ( uint32_t offset,
void * data,
size_t data_length )

Reads raw data from the NVM.

Parameters
[in]offsetThe offset where data shall be read from.
[out]dataAddress of array where data can be written to.
[in]data_lengthLength of the stored data.
Returns
ZPAL_STATUS_OK if the data was successfully read and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_backup_write()

zpal_status_t zpal_nvm_backup_write ( uint32_t offset,
const void * data,
size_t data_length )

Writes raw data to the NVM.

Parameters
[in]offsetThe offset where data shall be written to.
[out]dataAddress of array of data that must be written.
[in]data_lengthLength of the data to be stored.
Returns
ZPAL_STATUS_OK if the data was successfully written and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_close()

zpal_status_t zpal_nvm_close ( zpal_nvm_handle_t handle)

Closes the NVM of a given handle.

Parameters
[in]handleNVM area handle.
Returns
ZPAL_STATUS_OK if the file system was successfully closed and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_enum_objects()

size_t zpal_nvm_enum_objects ( zpal_nvm_handle_t handle,
zpal_nvm_object_key_t * key_list,
size_t key_list_size,
zpal_nvm_object_key_t key_min,
zpal_nvm_object_key_t key_max )

Create a list of key for valid objects in NVM.

Parameters
[in]handleNvm storage handle.
[out]key_listA pointer to a buffer for the key list.
[in]key_list_sizeThe size of the key list buffer.
[in]key_minThe lower search key.
[in]key_maxThe upper search key.
Returns
The number of keys written to the key list. This value is less than or equal to key_list_size.

◆ zpal_nvm_erase_all()

zpal_status_t zpal_nvm_erase_all ( zpal_nvm_handle_t handle)

Erases everything in a given area.

Parameters
[in]handleNVM area handle.
Returns
ZPAL_STATUS_OK if the all objects was successfully erased and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_erase_object()

zpal_status_t zpal_nvm_erase_object ( zpal_nvm_handle_t handle,
zpal_nvm_object_key_t key )

Delete an object from NVM.

Parameters
[in]handleNvm storage handle.
[in]keyObject key.
Returns
ZPAL_STATUS_OK on success and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_get_object_size()

zpal_status_t zpal_nvm_get_object_size ( zpal_nvm_handle_t handle,
zpal_nvm_object_key_t key,
size_t * len )

Get the object size identified with a given key from NVM.

Parameters
[in]handleNvm storage handle.
[in]keyObject key.
[out]lenObject size.
Returns
ZPAL_STATUS_OK on success and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_init()

zpal_nvm_handle_t zpal_nvm_init ( zpal_nvm_area_t area)

Initializes the NVM for a given area.

Parameters
[in]areaNVM area to initialize.
Returns
A valid NVM handle if successfully initialized. Otherwise it returns NULL.

◆ zpal_nvm_lock()

zpal_status_t zpal_nvm_lock ( zpal_nvm_handle_t handle)

Set write protection for storage.

Parameters
[in]handleNvm storage handle.
Returns
ZPAL_STATUS_OK if the lock was set successfully, ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_migrate_legacy_app_file_system()

zpal_status_t zpal_nvm_migrate_legacy_app_file_system ( void )

Migrates 800s legacy application file system to shared app/protocol file system.

Returns
ZPAL_STATUS_OK if the file system was successfully migrated and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_read()

zpal_status_t zpal_nvm_read ( zpal_nvm_handle_t handle,
zpal_nvm_object_key_t key,
void * object,
size_t object_size )

Reads object from a given area handle and given object key.

Parameters
[in]handleNVM area handle.
[in]keyObject key.
[out]objectAddress of array where object can be written to.
[in]object_sizeSize of the stored object.
Returns
ZPAL_STATUS_OK if the object was successfully read and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_read_object_part()

zpal_status_t zpal_nvm_read_object_part ( zpal_nvm_handle_t handle,
zpal_nvm_object_key_t key,
void * object,
size_t offset,
size_t object_size )

Reads part of object from a given area handle and given object key.

Parameters
[in]handleNVM area handle.
[in]keyObject key.
[out]objectAddress of array where object can be written to.
[in]offsetThe offset where object shall be read from.
[in]object_sizeSize of the stored object.
Returns
ZPAL_STATUS_OK if the object was successfully read and ZPAL_STATUS_FAIL otherwise.

◆ zpal_nvm_write()

zpal_status_t zpal_nvm_write ( zpal_nvm_handle_t handle,
zpal_nvm_object_key_t key,
const void * object,
size_t object_size )

Writes object to a given area handle and given object key.

Parameters
[in]handleNVM area handle.
[in]keyObject key.
[out]objectAddress of array of object that must be written.
[in]object_sizeSize of the object to be stored.
Returns
ZPAL_STATUS_OK if the object was successfully written and ZPAL_STATUS_FAIL otherwise.