* # License
* Copyright 2019 Silicon Laboratories Inc.
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
* Documentation for this app is available online.
* See
#include "gos.h"
#define STARTUP_SETTINGS_MAGIC_NUMBER 0x00010000 // version 1.0.0
#define APPLICATION_START_LINE "\r\nApplication Settings example starting ..."
void gos_app_init(void)
gos_result_t result;
GOS_LOG("Loading application settings if required");
// Load all settings that require a save and reboot to take effect
// Note, if the settings have been previously loaded (i.e. the 'magic number' is the same)
// then the following call does nothing.
// If the magic number is different, this will load the settings, save to nvm, and reboot.
// A factory reset or changing the 'magic number' is required to reload the settings
if (GOS_FAILED(result, gos_load_app_settings_once("one_time_settings.ini", STARTUP_SETTINGS_MAGIC_NUMBER)))
GOS_LOG("Failed to load 'one_time_settings.ini', error: %d", result);
GOS_LOG("Loading run-time settings always");
// Load all settings that are only required at runtime.
// Unless gos_settings_save() is later called, these settings will be cleared
// on reset or reboot.
// Note that this is for demonstration purposes only.
// nvm_settings.ini and runtime_settings.ini could be merged
// and only call gos_load_app_settings_once() to gain nearly identical functionality.
if (GOS_FAILED(result, gos_load_app_settings("runtime_settings.ini")))
GOS_LOG("Failed to load 'runtime_settings.ini', error: %d", result);
GOS_LOG("Success, issue a factory reset to revert settings");