Microchip® Advanced Software Framework

pdsDataServer.h File Reference

The header file describes the Persistence Data Server interface.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

#include <pdsMemIds.h>
#include <compiler.h>
#include <wlPdsTypes.h>

Macros

#define PDS_COMMITMENT_OUT_OFF_DATE_FLAG   (1U << 2U)
 
#define PDS_STOPPED_FLAG   (1U << 0U)
 
#define PDS_WRITING_INPROGRESS_FLAG   (1U << 1U)
 

Functions

bool PDS_BlockingStore (PDS_MemId_t memoryId)
 Stores data in non-volatile memory in a synchronous way - the application execution will be blocked until the process is completed. More...
 
void PDS_ClearRestoredMemory (PDS_MemId_t memoryId)
 Marks the specified restored PDS files to be cleared during a reset phase (during ZDO_StartNetwork() execution) More...
 
PDS_Status_t PDS_CreateFile (PDS_MemId_t memoryId, void *initialValue)
 Creates a file in NV memory and initializes it with provided pattern. More...
 
PDS_DataServerState_t PDS_Delete (PDS_MemId_t memoryId)
 Removes specified file records from NV Storage. More...
 
bool PDS_DeleteAll (bool includingPersistentItems)
 Deletes data from non-volatile storage except the Persistant items depending on the parameter passed. More...
 
void PDS_EraseSecureItems (void)
 
void PDS_FlushData (PDS_MemId_t memoryIds)
 
void PDS_InitItems (void)
 
bool PDS_IsAbleToRestore (PDS_MemId_t memoryId)
 Checks if the specified PDS file or directory can be restored from non-volatile memory. More...
 
bool PDS_IsAbleToStore (PDS_MemId_t memoryId)
 Checks if the specified PDS file or directory can be stored in non-volatile memory. More...
 
bool PDS_IsBusy (void)
 
bool PDS_IsMemoryRestored (PDS_MemId_t memoryId)
 Checks if files specified have been restored from non-volatile memory during the latest restoring procedure. More...
 
PDS_DataServerState_t PDS_ReadUserData (uint16_t offset, uint8_t *data, uint16_t length, void(*callback)(void))
 Reads data from the user's area of NV memory. More...
 
PDS_DataServerState_t PDS_ResetStorage (PDS_MemId_t memoryId)
 
bool PDS_Restore (PDS_MemId_t memoryId)
 Restores data from non-volatile storage. More...
 
PDS_Status_t PDS_RestoreFilePart (PDS_MemId_t memoryId, uint16_t offset, PDS_DataSize_t dataLength, void *data)
 Reads a portion of data from a file. More...
 
void PDS_Run (void)
 Continue Persistent Data Server operation the same way as before stopping. More...
 
void PDS_Stop (void)
 Stops the Persistent Data Server. More...
 
bool PDS_Store (PDS_MemId_t memoryId)
 Stores data in non-volatile memory in background, not blocking other processes. More...
 
void PDS_StoreByEvents (PDS_MemId_t memoryId)
 Provides PDS with information about memory that should be kept up-to-date in the non-volatile storage. More...
 
void PDS_StoreByTimer (uint32_t interval, PDS_MemId_t memoryId)
 Enables periodic commitment of specified persistent items to a non-volatile storage. More...
 
PDS_Status_t PDS_StoreFilePart (PDS_MemId_t memoryId, uint16_t offset, PDS_DataSize_t dataLength, void *data)
 Writes a portion of data to a file. More...
 
PDS_DataServerState_t PDS_WriteUserData (uint16_t offset, uint8_t *data, uint16_t length, void(*callback)(void))
 Writes data to the user's area of NV memory. More...
 

#define PDS_COMMITMENT_OUT_OFF_DATE_FLAG   (1U << 2U)
#define PDS_STOPPED_FLAG   (1U << 0U)
#define PDS_WRITING_INPROGRESS_FLAG   (1U << 1U)

bool PDS_BlockingStore ( PDS_MemId_t  memoryId)

Stores data in non-volatile memory in a synchronous way - the application execution will be blocked until the process is completed.

All PDS files which are absent in the current build configuration will be ignored.

Parameters
[in]memoryId- an identifier of PDS file or directory to be stored in non-volatile memory.
Returns
True, if storing process has been performed successfully, false - otherwise.
void PDS_ClearRestoredMemory ( PDS_MemId_t  memoryId)

Marks the specified restored PDS files to be cleared during a reset phase (during ZDO_StartNetwork() execution)

Parameters
[in]memoryId- an identifier of PDS file or directory to be cleared.
PDS_Status_t PDS_CreateFile ( PDS_MemId_t  memoryId,
void *  initialValue 
)

Creates a file in NV memory and initializes it with provided pattern.

   If file already exists, no action will be performed and PDS_SUCCESS
   status will be returned.
Parameters
[in]memoryId- an identifier of PDS file to create
[in]initialValue- file data initial value; if NULL provided, then file will be initialized with all 0xFF. The size of this pattern should be the same as a file size, specified in file descriptor.
Returns
operation status
PDS_DataServerState_t PDS_Delete ( PDS_MemId_t  memoryId)

Removes specified file records from NV Storage.

Parameters
[in]memoryId- an identifier of PDS file or directory to be removed from NV memory.
Returns
- Whether the operation was successful

Removes specified file records from NV Storage.

Parameters
[in]memoryId- an identifier of PDS item or directory to be deleted from non-volatile memory
Returns
PDS_DataServerState_t - status of PDS delete

References i, PDS_ITEM_MASK_SIZE, PDS_SUCCESS, pdsInitItemMask(), and S_Nv_Delete().

bool PDS_DeleteAll ( bool  includingPersistentItems)

Deletes data from non-volatile storage except the Persistant items depending on the parameter passed.

Parameters
[in]includingPersistentItems- deletes persistant items if TRUE deletes all other items except persistant items if FALSE
Returns
- Whether the operation was successful
Parameters
[in]includingPersistentItems- deletes persistant items if TRUE deletes all other items except persistant items if false
Returns
bool - Whether the operation went successfully

References S_Nv_EraseAll(), and S_Nv_ReturnValue_Ok.

Referenced by MiApp_ResetToFactoryNew().

void PDS_EraseSecureItems ( void  )
void PDS_FlushData ( PDS_MemId_t  memoryIds)
bool PDS_IsAbleToRestore ( PDS_MemId_t  memoryId)

Checks if the specified PDS file or directory can be restored from non-volatile memory.

PDS files not included in the current build configuration will be ignored.

Parameters
[in]memoryId- an identifier of PDS file or directory to be checked.
Returns
true, if the specified memory can be restored; false - otherwise.

Checks if the specified PDS file or directory can be restored from non-volatile memory.

Parameters
[in]memoryId- an identifier of PDS file or directory to be checked
Returns
true, if the specified memory can be restored; false - otherwise

References i, PDS_ITEM_MASK_SIZE, pdsInitItemMask(), pdsIsItemUnderSecurityControl(), and S_Nv_IsItemAvailable().

Referenced by MiApp_ProtocolInit().

bool PDS_IsAbleToStore ( PDS_MemId_t  memoryId)

Checks if the specified PDS file or directory can be stored in non-volatile memory.

Parameters
[in]memoryId- an identifier of PDS file or directory to be checked.
Returns
true, if the specified memory can be stored; false - otherwise.
bool PDS_IsBusy ( void  )
bool PDS_IsMemoryRestored ( PDS_MemId_t  memoryId)

Checks if files specified have been restored from non-volatile memory during the latest restoring procedure.

Parameters
[in]memoryId- an identifier of PDS file or directory to be checked.
Returns
true, if the specified file(s) have been restored; false - otherwise.
PDS_DataServerState_t PDS_ReadUserData ( uint16_t  offset,
uint8_t *  data,
uint16_t  length,
void(*)(void)  callback 
)

Reads data from the user's area of NV memory.

Parameters
[in]offset- offset of data in user's area
[in]data- pointer to memory, for reading data into
[in]length- data length
[in]callback- pointer to a callback function; if callback is NULL, then data will be read syncronously
Returns
- PDS state as a result of data reading operation
PDS_DataServerState_t PDS_ResetStorage ( PDS_MemId_t  memoryId)
bool PDS_Restore ( PDS_MemId_t  memoryId)

Restores data from non-volatile storage.

PDS files not included in the current build configuration will be ignored. Restoring process will be performed only if all files, expected for actual configuration, are presented in NV storage.

Parameters
[in]memoryId- an identifier of PDS file or directory to be restored from non-volatile memory.
Returns
true, if all expected files have been restored, false - otherwise.

PDS files not included in the current build configuration will be ignored. Restoring process will be performed only if all files, expected for actual configuration, are presented in NV storage

Parameters
[in]memoryId- an identifier of PDS file or directory to be restored from non-volatile memory
Returns
true, if all expected files have been restored, false - otherwise

References i, PDS_ITEM_MASK_SIZE, pdsInitItemMask(), and pdsRestoreItem().

Referenced by MiApp_ProtocolInit(), and MiMAC_Init().

PDS_Status_t PDS_RestoreFilePart ( PDS_MemId_t  memoryId,
uint16_t  offset,
PDS_DataSize_t  dataLength,
void *  data 
)

Reads a portion of data from a file.

File could have no permanent entity in RAM.

Parameters
[in]memoryId- an identifier of PDS file to read
[in]offset- offset of data part within a file
[in]dataLength- length of part to read
[in]data- buffer to place data part in
Returns
operation status
void PDS_Run ( void  )

Continue Persistent Data Server operation the same way as before stopping.

void PDS_Stop ( void  )

Stops the Persistent Data Server.

This doesn't affect a policy created through PDS_StoreByEvent() of PDS_StoreByTimer() functions. After calling the PDS_Run() function PDS continues working as before the stop.

bool PDS_Store ( PDS_MemId_t  memoryId)

Stores data in non-volatile memory in background, not blocking other processes.

All PDS files which are absent in the current build configuration will be ignored.

Parameters
[in]memoryId- an identifier of PDS file or directory to be stored in non-volatile memory.
Returns
True, if storing process has begun, false - otherwise.

References itemsToStore, PDS_STORE_ITEM_TASK_ID, pdsInitItemMask(), and pdsPostTask().

Referenced by frameParse(), MiApp_ConnectionMode(), MiApp_RemoveConnection(), MiApp_Set(), MiMAC_Init(), MiMAC_SendPacket(), and startCompleteProcedure().

void PDS_StoreByEvents ( PDS_MemId_t  memoryId)

Provides PDS with information about memory that should be kept up-to-date in the non-volatile storage.

Data will be saved im non-volatile memory upon specific events.

Parameters
[in]memoryId- an identifier of PDS file or directory to be stored in non-volatile memory.
void PDS_StoreByTimer ( uint32_t  interval,
PDS_MemId_t  memoryId 
)

Enables periodic commitment of specified persistent items to a non-volatile storage.

Parameters
[in]interval- period of time between successive commitments
[in]memoryId- an identifier of PDS file or directory to be stored in non-volatile memory.
PDS_Status_t PDS_StoreFilePart ( PDS_MemId_t  memoryId,
uint16_t  offset,
PDS_DataSize_t  dataLength,
void *  data 
)

Writes a portion of data to a file.

File could have no permanent entity in RAM.

Parameters
[in]memoryId- an identifier of PDS file to update
[in]offset- offset of data part within a file
[in]dataLength- length of part to write
[in]data- data to write
Returns
operation status
PDS_DataServerState_t PDS_WriteUserData ( uint16_t  offset,
uint8_t *  data,
uint16_t  length,
void(*)(void)  callback 
)

Writes data to the user's area of NV memory.

Parameters
[in]offset- offset to place data in user's area
[in]data- pointer to data
[in]length- data length
[in]callback- pointer to a callback function; if callback is NULL, then data will be written syncronously
Returns
- PDS state as a result of data writing operation