Golioth Firmware SDK
Loading...
Searching...
No Matches
settings.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Golioth, Inc.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifdef __cplusplus
8extern "C"
9{
10#endif
11
12#pragma once
13
15#include <golioth/client.h>
16#include <golioth/config.h>
17#include <stdint.h>
18#include <stdbool.h>
19
46
48struct golioth_settings;
49
68
78
86typedef enum golioth_settings_status (*golioth_int_setting_cb)(int32_t new_value, void *arg);
87typedef enum golioth_settings_status (*golioth_bool_setting_cb)(bool new_value, void *arg);
88typedef enum golioth_settings_status (*golioth_float_setting_cb)(float new_value, void *arg);
89typedef enum golioth_settings_status (*golioth_string_setting_cb)(const char *new_value,
90 size_t new_value_len,
91 void *arg);
92
99struct golioth_settings *golioth_settings_init(struct golioth_client *client);
100
109enum golioth_status golioth_settings_deinit(struct golioth_settings *settings);
110
125enum golioth_status golioth_settings_register_int(struct golioth_settings *settings,
126 const char *setting_name,
127 golioth_int_setting_cb callback,
128 void *callback_arg);
129
132enum golioth_status golioth_settings_register_int_with_range(struct golioth_settings *settings,
133 const char *setting_name,
134 int32_t min_val,
135 int32_t max_val,
136 golioth_int_setting_cb callback,
137 void *callback_arg);
138
140enum golioth_status golioth_settings_register_bool(struct golioth_settings *settings,
141 const char *setting_name,
143 void *callback_arg);
144
146enum golioth_status golioth_settings_register_float(struct golioth_settings *settings,
147 const char *setting_name,
149 void *callback_arg);
150
152enum golioth_status golioth_settings_register_string(struct golioth_settings *settings,
153 const char *setting_name,
155 void *callback_arg);
157
158#ifdef __cplusplus
159}
160#endif
golioth_status
enum golioth_status golioth_settings_register_string(struct golioth_settings *settings, const char *setting_name, golioth_string_setting_cb callback, void *callback_arg)
Same as golioth_settings_register_int, but for type string.
enum golioth_status golioth_settings_register_bool(struct golioth_settings *settings, const char *setting_name, golioth_bool_setting_cb callback, void *callback_arg)
Same as golioth_settings_register_int, but for type bool.
enum golioth_status golioth_settings_register_float(struct golioth_settings *settings, const char *setting_name, golioth_float_setting_cb callback, void *callback_arg)
Same as golioth_settings_register_int, but for type float.
struct golioth_settings * golioth_settings_init(struct golioth_client *client)
enum golioth_settings_status(* golioth_string_setting_cb)(const char *new_value, size_t new_value_len, void *arg)
Definition settings.h:89
enum golioth_settings_status(* golioth_int_setting_cb)(int32_t new_value, void *arg)
Definition settings.h:86
enum golioth_settings_status(* golioth_bool_setting_cb)(bool new_value, void *arg)
Definition settings.h:87
enum golioth_settings_status(* golioth_float_setting_cb)(float new_value, void *arg)
Definition settings.h:88
golioth_settings_status
Enumeration of Settings status codes.
Definition settings.h:52
golioth_settings_value_type
Different types of setting values.
Definition settings.h:71
enum golioth_status golioth_settings_register_int_with_range(struct golioth_settings *settings, const char *setting_name, int32_t min_val, int32_t max_val, golioth_int_setting_cb callback, void *callback_arg)
enum golioth_status golioth_settings_register_int(struct golioth_settings *settings, const char *setting_name, golioth_int_setting_cb callback, void *callback_arg)
enum golioth_status golioth_settings_deinit(struct golioth_settings *settings)
@ GOLIOTH_SETTINGS_GENERAL_ERROR
Other general error (e.g. I/O error)
Definition settings.h:66
@ GOLIOTH_SETTINGS_VALUE_OUTSIDE_RANGE
The setting value is outside of allowed range.
Definition settings.h:62
@ GOLIOTH_SETTINGS_VALUE_STRING_TOO_LONG
The setting value string is too long, exceeds max length.
Definition settings.h:64
@ GOLIOTH_SETTINGS_KEY_NOT_VALID
The setting key is too long, ill-formatted.
Definition settings.h:58
@ GOLIOTH_SETTINGS_KEY_NOT_RECOGNIZED
The setting key is not recognized, this setting is unknown.
Definition settings.h:56
@ GOLIOTH_SETTINGS_SUCCESS
Setting applied successfully to the device, stored in NVS.
Definition settings.h:54
@ GOLIOTH_SETTINGS_VALUE_FORMAT_NOT_VALID
The setting value is improperly formatted.
Definition settings.h:60
@ GOLIOTH_SETTINGS_VALUE_TYPE_STRING
Definition settings.h:76
@ GOLIOTH_SETTINGS_VALUE_TYPE_UNKNOWN
Definition settings.h:72
@ GOLIOTH_SETTINGS_VALUE_TYPE_INT
Definition settings.h:73
@ GOLIOTH_SETTINGS_VALUE_TYPE_BOOL
Definition settings.h:74
@ GOLIOTH_SETTINGS_VALUE_TYPE_FLOAT
Definition settings.h:75