Wirepas SDK
app_persistent.h File Reference

Detailed Description

Application persistent library. It wraps the access of the application persistent area if it exists.

This library access the app persistent area in a basic way. It is mainly designed to access in read mode as many time as app want but written only very seldomly. Ideally, memory area is written first on the assembly line. Here are some implementations points:

  • Reading more than was written the previous time is undefined. The delta may be random or 0xff
  • When writting the area, the minimum size is previously erased to ensure that the new data is written on clean area.
  • All access are synchronous with a timeout. So writting long chunks of data may be quite long (up to 100ms)
  • There is no protection in case of reboot during a write (no backup)

Definition in file app_persistent.h.

Go to the source code of this file.

Functions

app_persistent_res_e App_Persistent_init (void)
 Initialize app persistent module. More...
 
app_persistent_res_e App_Persistent_write (uint8_t *data, size_t len)
 Write to persistent. More...
 
app_persistent_res_e App_Persistent_read (uint8_t *data, size_t len)
 Read from persistent. More...
 

Enumerations

enum  app_persistent_res_e {
  APP_PERSISTENT_RES_OK = 0, APP_PERSISTENT_RES_NO_AREA = 1, APP_PERSISTENT_RES_UNINITIALIZED = 2, APP_PERSISTENT_RES_TOO_BIG = 3,
  APP_PERSISTENT_RES_INVALID_CONTENT = 4, APP_PERSISTENT_RES_ACCESS_TIMEOUT = 5, APP_PERSISTENT_RES_FLASH_ERROR = 6
}
 List of return code. More...
 

Function Documentation

◆ App_Persistent_init()

app_persistent_res_e App_Persistent_init ( void  )

Initialize app persistent module.

Returns
Return code of the operation

◆ App_Persistent_read()

app_persistent_res_e App_Persistent_read ( uint8_t *  data,
size_t  len 
)

Read from persistent.

Parameters
dataPointer to store read data
lenLength of data to read
Returns
Return code of the operation
Note
data is valid only if return code is APP_PERSISTENT_RES_OK

◆ App_Persistent_write()

app_persistent_res_e App_Persistent_write ( uint8_t *  data,
size_t  len 
)

Write to persistent.

Parameters
dataPointer to the data to write
lenLength of data to write
Returns
Return code of the operation

Enumeration Type Documentation

◆ app_persistent_res_e

List of return code.

Enumerator
APP_PERSISTENT_RES_OK 

Operation is successful

APP_PERSISTENT_RES_NO_AREA 

No area found to store persistent data

APP_PERSISTENT_RES_UNINITIALIZED 

Library unitialized

APP_PERSISTENT_RES_TOO_BIG 

Read or write command is for a too big area

APP_PERSISTENT_RES_INVALID_CONTENT 

Content of area was never initialized

APP_PERSISTENT_RES_ACCESS_TIMEOUT 

Access to area has timeouted (unlikely on internal flash)

APP_PERSISTENT_RES_FLASH_ERROR 

Flash driver reported an error

Definition at line 35 of file app_persistent.h.

APP_PERSISTENT_RES_FLASH_ERROR
@ APP_PERSISTENT_RES_FLASH_ERROR
Definition: app_persistent.h:50
APP_PERSISTENT_RES_INVALID_CONTENT
@ APP_PERSISTENT_RES_INVALID_CONTENT
Definition: app_persistent.h:46
APP_PERSISTENT_RES_OK
@ APP_PERSISTENT_RES_OK
Definition: app_persistent.h:38
app_persistent_res_e
app_persistent_res_e
List of return code.
Definition: app_persistent.h:35
APP_PERSISTENT_RES_ACCESS_TIMEOUT
@ APP_PERSISTENT_RES_ACCESS_TIMEOUT
Definition: app_persistent.h:48
APP_PERSISTENT_RES_TOO_BIG
@ APP_PERSISTENT_RES_TOO_BIG
Definition: app_persistent.h:44
APP_PERSISTENT_RES_NO_AREA
@ APP_PERSISTENT_RES_NO_AREA
Definition: app_persistent.h:40
APP_PERSISTENT_RES_UNINITIALIZED
@ APP_PERSISTENT_RES_UNINITIALIZED
Definition: app_persistent.h:42