VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
vitroio::sdk::impl::EnvironmentInterface Class Reference

Class is wrapper for FlashInterface. It allows to read/write environment variables stored in flash memory. More...

#include <environment_interface.h>

Inheritance diagram for vitroio::sdk::impl::EnvironmentInterface:
Collaboration diagram for vitroio::sdk::impl::EnvironmentInterface:

Public Types

enum  Variable { ENVVAR_CURRENT_BOOT_REGION , ENVVAR_NEXT_BOOT_REGION , ENVVAR_TIMESTAMP }
 The Variable enum specifies supported environment variables. More...
 

Public Member Functions

 EnvironmentInterface (FlashInterface *flash, FlashSpace flashSpace)
 Constructor initializes the interface. More...
 
 ~EnvironmentInterface ()
 Destructor. More...
 
bool isValid () const
 Function allows to check whether the interface is in valid state. More...
 
int save ()
 Function saves environment variables to the flash memory. More...
 
uint32_t getVariable (Variable variable) const
 Function allows to get value of environment variable. More...
 
void getVariableIOKeys (uint8_t *retValue, uint32_t offset, uint32_t bytes) const
 
void setVariable (Variable variable, uint32_t value)
 Function allows to set value of environment variable. More...
 
void setVariableIOKeys (uint8_t *value, uint32_t offset, uint32_t bytes)
 

Detailed Description

Class is wrapper for FlashInterface. It allows to read/write environment variables stored in flash memory.

Member Enumeration Documentation

◆ Variable

The Variable enum specifies supported environment variables.

Enumerator
ENVVAR_CURRENT_BOOT_REGION 
ENVVAR_NEXT_BOOT_REGION 
ENVVAR_TIMESTAMP 

Constructor & Destructor Documentation

◆ EnvironmentInterface()

vitroio::sdk::impl::EnvironmentInterface::EnvironmentInterface ( FlashInterface flash,
FlashSpace  flashSpace 
)
explicit

Constructor initializes the interface.

Intialization includes verification whether the provided flash memory size is enough, reading of environment variables from flash memory and writing default values when variables are not set.

There is not guarantee that the object is in valid state. User should call isValid() method to determine if the object was initialized successfully. When the object is in invalid state, the behaviour is undefined.

Parameters
flashPointer to FlashInterface object.
flashSpaceSpecifies flash memory space for storing environment variables

◆ ~EnvironmentInterface()

vitroio::sdk::impl::EnvironmentInterface::~EnvironmentInterface ( )

Destructor.

Member Function Documentation

◆ getVariable()

uint32_t vitroio::sdk::impl::EnvironmentInterface::getVariable ( Variable  variable) const

Function allows to get value of environment variable.

Parameters
variableVariable for which the value is to be get.
Returns
Function returns value of variable.
Note
If the variable is unknown the function will return 0. Therefore it is important to use variables defined in Variable enum.

◆ getVariableIOKeys()

void vitroio::sdk::impl::EnvironmentInterface::getVariableIOKeys ( uint8_t *  retValue,
uint32_t  offset,
uint32_t  bytes 
) const

◆ isValid()

bool vitroio::sdk::impl::EnvironmentInterface::isValid ( ) const

Function allows to check whether the interface is in valid state.

Note
This method should be called always after creation of the object.
Returns
Function returns true if the object is valid or false otherwise.

◆ save()

int vitroio::sdk::impl::EnvironmentInterface::save ( )

Function saves environment variables to the flash memory.

Returns
Function returns VITROIO_ERR_SUCCESS on success or appropriate error code otherwise.

◆ setVariable()

void vitroio::sdk::impl::EnvironmentInterface::setVariable ( Variable  variable,
uint32_t  value 
)

Function allows to set value of environment variable.

Parameters
variableVariable for which the value is to be set.
valueValue of variable to set.
Note
If the variable is unknown the function will just return. Therefore it is important to use variables defined in Variable enum.

◆ setVariableIOKeys()

void vitroio::sdk::impl::EnvironmentInterface::setVariableIOKeys ( uint8_t *  value,
uint32_t  offset,
uint32_t  bytes 
)