VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
environment_interface.h
Go to the documentation of this file.
1#ifndef VITROIO_SDK_ENVIRONMENT_INTERFACE_H
2#define VITROIO_SDK_ENVIRONMENT_INTERFACE_H
3
4#include <mbed.h>
5
6#include <vitroio-sdk/types.h>
8
9namespace vitroio
10{
11
12namespace sdk
13{
14
15namespace impl
16{
17
23#define VITROIO_ENVIRONMENT_INTERFACE_BOOT_REGION_A 0x0A
24#define VITROIO_ENVIRONMENT_INTERFACE_BOOT_REGION_B 0x0B
25
26class FlashInterface;
27
32class EnvironmentInterface : private NonCopyable<EnvironmentInterface>
33{
34public:
39 {
43 };
44
61 explicit EnvironmentInterface(FlashInterface* flash, FlashSpace flashSpace);
62
67
76 bool isValid() const;
77
84 int save();
85
97 uint32_t getVariable(Variable variable) const;
98 void getVariableIOKeys(uint8_t* retValue, uint32_t offset, uint32_t bytes) const;
110 void setVariable(Variable variable, uint32_t value);
111 void setVariableIOKeys(uint8_t* value, uint32_t offset, uint32_t bytes);
112
113private:
114 bool valid_;
115
116 FlashInterface* flash_;
117 FlashSpace flashSpace_;
119
120 void setDefaults();
121
122 // Auxiliary method for internal usage to avoid double allocating of buffer
123 // (prevent memory fragmentation).
124 // Method assumes that the buffer size is minimum maxSectorSize of flash.
125 int save(uint8_t* buffer);
126
127 uint32_t getVariable(uint32_t offset, uint32_t bytes) const;
128 void setVariable(uint32_t value, uint32_t offset, uint32_t bytes);
129};
130
135} // namespace impl
136
137} // namespace sdk
138
139} // namespace vitroio
140
141#endif // VITROIO_SDK_ENVIRONMENT_INTERFACE_H
Class is wrapper for FlashInterface. It allows to read/write environment variables stored in flash me...
Definition: environment_interface.h:33
void getVariableIOKeys(uint8_t *retValue, uint32_t offset, uint32_t bytes) const
EnvironmentInterface(FlashInterface *flash, FlashSpace flashSpace)
Constructor initializes the interface.
uint32_t getVariable(Variable variable) const
Function allows to get value of environment variable.
int save()
Function saves environment variables to the flash memory.
void setVariable(Variable variable, uint32_t value)
Function allows to set value of environment variable.
void setVariableIOKeys(uint8_t *value, uint32_t offset, uint32_t bytes)
bool isValid() const
Function allows to check whether the interface is in valid state.
Variable
The Variable enum specifies supported environment variables.
Definition: environment_interface.h:39
@ ENVVAR_CURRENT_BOOT_REGION
Definition: environment_interface.h:40
@ ENVVAR_TIMESTAMP
Definition: environment_interface.h:42
@ ENVVAR_NEXT_BOOT_REGION
Definition: environment_interface.h:41
Class is a wrapper for mbed::FlashIAP module.
Definition: flash_interface.h:26
The file contains constants of vitro-shard-sdk for user usage.
#define VITROIO_CONSTS_ENVIRONMENT_REQUIRED_FLASH_SIZE
Defines required flash memory size in bytes for storing environment variables.
Definition: consts.h:15
The namespace contains all of components of vitro-shard-sdk and components based on the sdk....
Definition: can_layer.h:9
Structure representing space of flash memory.
Definition: types.h:79
The file contains types used by vitro-shard-sdk.