Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
cascoda_settings.c File Reference

This file implements the Cascoda platform abstraction for non-volatile storage of settings. More...

#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "cascoda-util/cascoda_flash.h"
#include "cascoda-util/cascoda_settings.h"
#include "ca821x_api.h"
Include dependency graph for cascoda_settings.c:

Classes

struct  settingsBlock
 

Macros

#define otEXPECT(aCondition)
 This checks for the specified condition, which is expected to commonly be true, and branches to the local label 'exit' if the condition is false. More...
 
#define otEXPECT_ACTION(aCondition, aAction)
 This checks for the specified condition, which is expected to commonly be true, and both executes anAction and branches to the local label 'exit' if the condition is false. More...
 
#define otEXIT_NOW(aAction)
 This unconditionally executes aAction and branches to the local label 'exit'. More...
 
#define SETTINGS_CONFIG_BASE_ADDRESS   0
 The base address of settings. More...
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 

Enumerations

enum  { kBlockAddBeginFlag = 0x1 , kBlockAddCompleteFlag = 0x02 , kBlockDeleteFlag = 0x04 , kBlockIndex0Flag = 0x08 }
 
enum  {
  kSettingsFlagSize = 4 , kSettingsBlockDataSize = 511 , kSettingsInSwap = 0xbe5cc5ef , kSettingsInUse = 0xbe5cc5ee ,
  kSettingsNotUse = 0xbe5cc5ec
}
 

Functions

void BSP_GetFlashInfo (struct ca_flash_info *aFlashInfoOut)
 Get the flashinfo struct for the current platform. More...
 
void caUtilSettingsInit (struct ca821x_dev *aInstance, const char *aApplicationName, uint32_t aNodeId)
 Performs any initialization for the settings subsystem, if necessary. More...
 
ca_error caUtilSettingsBeginChange (struct ca821x_dev *aInstance)
 
ca_error caUtilSettingsCommitChange (struct ca821x_dev *aInstance)
 
ca_error caUtilSettingsAbandonChange (struct ca821x_dev *aInstance)
 
void caUtilSettingsDeinit (struct ca821x_dev *aInstance)
 Performs any de-initialization for the settings subsystem, if necessary. More...
 
ca_error caUtilSettingsGet (struct ca821x_dev *aInstance, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
 This function fetches the value of the setting identified by aKey and write it to the memory pointed to by aValue. More...
 
ca_error caUtilSettingsGetAddress (struct ca821x_dev *aInstance, uint16_t aKey, int aIndex, void **aValue, uint16_t *aValueLength)
 Get the address at which a particular setting is stored. More...
 
ca_error caUtilSettingsSet (struct ca821x_dev *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
 Sets or replaces the value of a setting. More...
 
ca_error caUtilSettingsAdd (struct ca821x_dev *aInstance, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
 Adds a value to a setting This function adds the value to a setting identified by aKey, without replacing any existing values. More...
 
ca_error caUtilSettingsAddVector (struct ca821x_dev *aInstance, uint16_t aKey, struct settingBuffer *aVector, size_t aCount)
 Add a vector of buffers to the storage. More...
 
ca_error caUtilSettingsDelete (struct ca821x_dev *aInstance, uint16_t aKey, int aIndex)
 Removes a setting from the setting store. More...
 
void caUtilSettingsWipe (struct ca821x_dev *aInstance, const char *aApplicationName, uint32_t aNodeId)
 Removes all settings from the setting store. More...
 

Detailed Description

This file implements the Cascoda platform abstraction for non-volatile storage of settings.

Macro Definition Documentation

◆ MIN

#define MIN (   a,
 
)    (((a) < (b)) ? (a) : (b))

◆ otEXIT_NOW

#define otEXIT_NOW (   aAction)
Value:
do \
{ \
aAction; \
goto exit; \
} while (0)

This unconditionally executes aAction and branches to the local label 'exit'.

Note
The use of this interface implies neither success nor failure for the overall exit status of the enclosing function body.
Parameters
[in]aActionAn expression or block to execute.

◆ otEXPECT

#define otEXPECT (   aCondition)
Value:
do \
{ \
if (!(aCondition)) \
{ \
goto exit; \
} \
} while (0)

This checks for the specified condition, which is expected to commonly be true, and branches to the local label 'exit' if the condition is false.

Parameters
[in]aConditionA Boolean expression to be evaluated.

◆ otEXPECT_ACTION

#define otEXPECT_ACTION (   aCondition,
  aAction 
)
Value:
do \
{ \
if (!(aCondition)) \
{ \
aAction; \
goto exit; \
} \
} while (0)

This checks for the specified condition, which is expected to commonly be true, and both executes anAction and branches to the local label 'exit' if the condition is false.

Parameters
[in]aConditionA Boolean expression to be evaluated.
[in]aActionAn expression or block to execute when the assertion fails.

◆ SETTINGS_CONFIG_BASE_ADDRESS

#define SETTINGS_CONFIG_BASE_ADDRESS   0

The base address of settings.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kBlockAddBeginFlag 
kBlockAddCompleteFlag 
kBlockDeleteFlag 
kBlockIndex0Flag 

◆ anonymous enum

anonymous enum
Enumerator
kSettingsFlagSize 
kSettingsBlockDataSize 
kSettingsInSwap 
kSettingsInUse 
kSettingsNotUse 

Function Documentation

◆ caUtilSettingsAbandonChange()

ca_error caUtilSettingsAbandonChange ( struct ca821x_dev aInstance)

◆ caUtilSettingsBeginChange()

ca_error caUtilSettingsBeginChange ( struct ca821x_dev aInstance)

◆ caUtilSettingsCommitChange()

ca_error caUtilSettingsCommitChange ( struct ca821x_dev aInstance)