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" |
typedef struct _EventToMemoryIdMapping_t EventToMemoryIdMapping_t |
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.
[in] | memoryId | - an identifier of PDS item or directory to be deleted from non-volatile memory |
References i, PDS_ITEM_MASK_SIZE, PDS_SUCCESS, pdsInitItemMask(), and S_Nv_Delete().
Deletes data from non-volatile storage except the Persistant items depending on the parameter passed.
[in] | includingPersistentItems | - deletes persistant items if TRUE deletes all other items except persistant items if false |
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.
[in] | memoryId | - an identifier of PDS file or directory to be checked |
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
[in] | memoryId | - an identifier of PDS file or directory to be restored from non-volatile memory |
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.
[in] | memoryId | - an identifier of PDS file or directory to be stored in non-volatile memory. |
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().
|
static |
References PDS_DirDescr_t::filesCount, FLASH_PTR, PDS_DirDescr_t::list, PDS_ALL_EXISTENT_MEMORY, PDS_DIRECTORY_MASK, PDS_ITEM_MASK_SIZE, and pdsGetDirDescr().
Referenced by PDS_Delete(), PDS_IsAbleToRestore(), PDS_Restore(), and PDS_Store().
|
static |
References ItemIdToMemoryMapping_t::filler, ItemIdToMemoryMapping_t::itemData, ItemIdToMemoryMapping_t::itemSize, NULL, pdsGetItemDescr(), pdsIsItemUnderSecurityControl(), pdsUpdateMemory(), S_Nv_ItemInit(), S_Nv_ItemLength(), S_Nv_ReturnValue_DidNotExist, and S_Nv_ReturnValue_Ok.
Referenced by PDS_Restore().
|
static |
void pdsStoreItemTaskHandler | ( | void | ) |
References ItemIdToMemoryMapping_t::filler, i, ItemIdToMemoryMapping_t::itemData, ItemIdToMemoryMapping_t::itemSize, itemsToStore, PDS_ITEM_MASK_SIZE, PDS_STORE_ITEM_TASK_ID, pdsGetItemDescr(), pdsIsItemUnderSecurityControl(), pdsPostTask(), pdsStoreItem(), S_Nv_IsItemAvailable(), S_Nv_ItemInit(), S_Nv_ReturnValue_DidNotExist, and S_Nv_ReturnValue_Ok.
|
static |
Referenced by PDS_Store(), and pdsStoreItemTaskHandler().