Configuration Service
The configuration service is responsible for managing system configuration information, including device name, language, display settings, backlight brightness, and other system-level configurations. All configurations are stored in the system configuration file (config.json).
Configuration Keys
System Configuration Keys
#define EOS_CONFIG_KEY_DEVICE_NAME_STR "device_name" // Device name
#define EOS_CONFIG_KEY_LANGUAGE_STR "language" // Language
#define EOS_CONFIG_KEY_WATCHFACE_ID_STR "wf_id" // Watchface ID
#define EOS_CONFIG_KEY_BLUETOOTH_BOOL "bluetooth" // Bluetooth switch
#define EOS_CONFIG_KEY_DISPLAY_BRIGHTNESS_NUMBER "display_brightness" // Display brightness
#define EOS_CONFIG_KEY_SPEAKER_VOLUME_NUMBER "speaker_volume" // Speaker volume
#define EOS_CONFIG_KEY_MUTE_BOOL "mute" // Mute switch
#define EOS_CONFIG_KEY_SLEEP_TIMEOUT_SEC_NUMBER "sleep_timeout_sec" // Sleep timeout
#define EOS_CONFIG_KEY_AOD_MODE_BOOL "aod_mode" // AOD mode switch
#define EOS_CONFIG_KEY_WAKE_ON_RAISE_BOOL "wake_on_raise" // Wake on raise switch
#define EOS_CONFIG_KEY_VIBRATOR_STRENGTH_NUMBER "vibrator_strength" // Vibration strength
#define EOS_CONFIG_KEY_APP_ORDER_ARRAY "app_order" // App order
Default Values
#define EOS_CONFIG_DEFAULT_DEVICE_NAME "Elenix Watch" // Default device name
#define EOS_CONFIG_DEFAULT_WATCHFACE_ID_STR "cn.sab1e.clock" // Default watchface ID
Service Initialization
Initialize the configuration service on first system run:
void eos_service_config_init(void);
Boolean Configuration
eos_result_t eos_config_set_bool(const char *key, bool value);
bool eos_config_get_bool(const char *key, bool default_value);
String Configuration
eos_result_t eos_config_set_string(const char *key, const char *value);
char *eos_config_get_string(const char *key, const char *default_value);
The returned string needs to be freed using eos_malloc(str) when no longer needed.
Number Configuration
eos_result_t eos_config_set_number(const char *key, double value);
double eos_config_get_number(const char *key, double default_value);
JSON Configuration
cJSON *eos_config_get_json(const char *key);
eos_result_t eos_config_set_json(const char *key, cJSON *json_value);
The returned cJSON object needs to be freed using cJSON_Delete() after use.
Add Configuration Item
Add a new configuration item to the system configuration file:
eos_result_t eos_config_add_item(const char *key, const char *value);