Microchip® Advanced Software Framework

wlPdsDataServer.c File Reference

PDS data server implementation.

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

#include <wlPdsMemIds.h>
#include <wlPdsBindings.h>
#include <S_Nv_Init.h>
#include <S_Nv.h>
#include <wlPdsTaskManager.h>
#include <wlPdsTypesConverter.h>
#include "assert.h"
#include <D_Nv_Init.h>
#include <wlPdsTypes.h>
#include <string.h>
#include "pdsDataServer.h"

Data Structures

struct  _EventToMemoryIdMapping_t
 

Macros

#define COMPID   "wlPdsDataServer"
 
#define EVENT_TO_MEM_ID_MAPPING(event, id)   {.eventId = event, .itemId = id}
 

Typedefs

typedef struct
_EventToMemoryIdMapping_t 
EventToMemoryIdMapping_t
 
typedef uint8_t PDS_MemMask_t [PDS_ITEM_MASK_SIZE]
 

Functions

PDS_DataServerState_t PDS_Delete (PDS_MemId_t memoryId)
 Deletes data from non-volatile storage. More...
 
bool PDS_DeleteAll (bool includingPersistentItems)
 Deletes data from non-volatile storage except the Persistant items depending on the parameter passed. More...
 
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. More...
 
bool PDS_Restore (PDS_MemId_t memoryId)
 Restores data from non-volatile storage. More...
 
bool PDS_Store (PDS_MemId_t memoryId)
 Stores data in non-volatile memory in background, not blocking other processes. More...
 
static bool pdsInitItemMask (S_Nv_ItemId_t memoryId, uint8_t *itemMask)
 
static bool pdsRestoreItem (S_Nv_ItemId_t id)
 
static void pdsStoreItem (S_Nv_ItemId_t id)
 
void pdsStoreItemTaskHandler (void)
 

Variables

static uint8_t itemsToStore [PDS_ITEM_MASK_SIZE]
 

#define COMPID   "wlPdsDataServer"
#define EVENT_TO_MEM_ID_MAPPING (   event,
  id 
)    {.eventId = event, .itemId = id}

typedef uint8_t PDS_MemMask_t[PDS_ITEM_MASK_SIZE]

PDS_DataServerState_t PDS_Delete ( PDS_MemId_t  memoryId)

Deletes data from non-volatile storage.

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
bool - Whether the operation went successfully

References S_Nv_EraseAll(), and S_Nv_ReturnValue_Ok.

Referenced by MiApp_ResetToFactoryNew().

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.

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_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

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

Referenced by MiApp_ProtocolInit(), and MiMAC_Init().

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().

uint8_t itemsToStore[PDS_ITEM_MASK_SIZE]
static