Application NVM

Functions for reading/writing/loading NVM entries that are custom defined by Gecko OS applications. More...

Modules

Macros
Settings specific macros.

Enumerations

enum gos_factory_reset_t {
GOS_NVM_RESET_BACKUP ,
GOS_NVM_RESET_FACTORY ,
GOS_NVM_RESET_CACHE_ONLY
}

Functions

gos_result_t gos_nvm_retrieve (gos_nvm_entry_header_t key, void **value_ptr)
Retrieve a reference to an NVM cache entry. More...
gos_result_t gos_nvm_update (gos_nvm_entry_header_t key, const void *new_value, bool force_set)
Update the value of a NVM cache entry. More...
gos_result_t gos_nvm_save (void)
Save cached RAM NVM setting to NVM. More...
gos_result_t gos_nvm_factory_reset ( gos_factory_reset_t reset_type)

Detailed Description

Functions for reading/writing/loading NVM entries that are custom defined by Gecko OS applications.

Enumeration Type Documentation

gos_factory_reset_t

NVM Factory reset type

Enumerator
GOS_NVM_RESET_BACKUP

Reset NVM to factory defaults, restoring backed up values (i.e. SSID, password, etc)

GOS_NVM_RESET_FACTORY

Reset every thing to factory defaults,.

Note
This will reboot the device.
GOS_NVM_RESET_CACHE_ONLY

Only reset the RAM cached NVM values to factory defaults (leave NVM as-is)

Function Documentation

gos_nvm_factory_reset()

gos_result_t gos_nvm_factory_reset ( gos_factory_reset_t reset_type )

Factory reset the application's NVM settings

Refer to gos_factory_reset_t for the various reset types.

Note
This API does NOT return when GOS_NVM_RESET_FACTORY is used.
This API will reset application NVM ONLY, Gecko OS Plugin and Kernel settings are NOT affected by the API. See gos_settings_factory_reset() to factory reset ALL settings
Parameters
reset_type The factory reset type, see gos_factory_reset_t
Returns
The result of the API, see gos_result_t
Examples:
system/application_nvm/main.c .

gos_nvm_retrieve()

gos_result_t gos_nvm_retrieve ( gos_nvm_entry_header_t key,
void ** value_ptr
)

Retrieve a reference to an NVM cache entry.

On Gecko OS startup, the NVM data is loaded into a cache. This API allows for retrieving a reference to the cached entry.

See GOS_NVM_GET() for a simplified version of this API.

Parameters
key NVM entry key, use GOS_NVM_KEY() to specify the key
value_ptr Pointer to hold NVM cache reference
Returns
Result of API, see gos_result_t

gos_nvm_save()

gos_result_t gos_nvm_save ( void )

Save cached RAM NVM setting to NVM.

This saves all data in the application's NVM RAM cache to NVM. All saved data will automatically be reload on powerup/startup.

Note
This API will save the Application's NVM ONLY, Gecko OS Plugin and Kernel settings are NOT affected by the API. See gos_settings_save() to save Plugin and Kernel settings.
Returns
Result of API, see gos_result_t
Examples:
hurricane/arducam/settings.c , hurricane/security_camera/settings.c , and system/application_nvm/main.c .

gos_nvm_update()

gos_result_t gos_nvm_update ( gos_nvm_entry_header_t key,
const void * new_value,
bool force_set
)

Update the value of a NVM cache entry.

This attempts to update the value of the specified NVM entry in cache. IfF the entry's key is not found and:

  • force_set = false THEN this API fails
  • force_set = true THEN this API creates a new entry in cache with the given value

See GOS_NVM_UPDATE() and GOS_NVM_UPDATE_FORCED() for simplified versions of this API.

Note
This API ONLY updates the NVM entry in cache. gos_nvm_save() must be used to save the cache to NVM.
Parameters
key NVM entry key, use GOS_NVM_KEY() to specify the key
new_value New value of NVM cache entry. The length of the value must NOT be longer than what was specified when the NVM entry key was defined using GOS_NVM_DEFINE_ENTRY()
force_set Set the new NVM value even if it doesn't exist, if this is false and the entry does not exist (i.e. no default value is defined) then this return @ GOS_NOT_FOUND
Returns
Result of API, see gos_result_t