Golioth Firmware SDK
|
Typedefs | |
typedef enum golioth_settings_status(* | golioth_int_setting_cb) (int32_t new_value, void *arg) |
typedef enum golioth_settings_status(* | golioth_bool_setting_cb) (bool new_value, void *arg) |
typedef enum golioth_settings_status(* | golioth_float_setting_cb) (float new_value, void *arg) |
typedef enum golioth_settings_status(* | golioth_string_setting_cb) (const char *new_value, size_t new_value_len, void *arg) |
Enumerations | |
enum | golioth_settings_status { GOLIOTH_SETTINGS_SUCCESS = 0 , GOLIOTH_SETTINGS_KEY_NOT_RECOGNIZED = 1 , GOLIOTH_SETTINGS_KEY_NOT_VALID = 2 , GOLIOTH_SETTINGS_VALUE_FORMAT_NOT_VALID = 3 , GOLIOTH_SETTINGS_VALUE_OUTSIDE_RANGE = 4 , GOLIOTH_SETTINGS_VALUE_STRING_TOO_LONG = 5 , GOLIOTH_SETTINGS_GENERAL_ERROR = 6 } |
Enumeration of Settings status codes. More... | |
enum | golioth_settings_value_type { GOLIOTH_SETTINGS_VALUE_TYPE_UNKNOWN , GOLIOTH_SETTINGS_VALUE_TYPE_INT , GOLIOTH_SETTINGS_VALUE_TYPE_BOOL , GOLIOTH_SETTINGS_VALUE_TYPE_FLOAT , GOLIOTH_SETTINGS_VALUE_TYPE_STRING } |
Different types of setting values. More... | |
Functions | |
struct golioth_settings * | golioth_settings_init (struct golioth_client *client) |
enum golioth_status | golioth_settings_deinit (struct golioth_settings *settings) |
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_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_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. | |
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. | |
Functions for interacting with the Golioth Settings service
The Settings service is for long-lived persistent configuration data. Settings are configured/written from the cloud and read by the device. The device observes for settings updates, and reports status of applying the settings to the cloud.
Each setting is a key/value pair, where the key is a string and the value can be int32_t, bool, float, or string.
Overall, the flow is:
For each setting recieved, this library will check:
typedef enum golioth_settings_status(* golioth_bool_setting_cb) (bool new_value, void *arg) |
Definition at line 1 of file settings.h.
typedef enum golioth_settings_status(* golioth_float_setting_cb) (float new_value, void *arg) |
Definition at line 1 of file settings.h.
typedef enum golioth_settings_status(* golioth_int_setting_cb) (int32_t new_value, void *arg) |
Callback function types for golioth_settings_register_*
new_value | The setting value received from Golioth cloud |
arg | User's registered callback arg |
Definition at line 1 of file settings.h.
typedef enum golioth_settings_status(* golioth_string_setting_cb) (const char *new_value, size_t new_value_len, void *arg) |
Definition at line 1 of file settings.h.
Enumeration of Settings status codes.
Definition at line 51 of file settings.h.
Different types of setting values.
Enumerator | |
---|---|
GOLIOTH_SETTINGS_VALUE_TYPE_UNKNOWN | |
GOLIOTH_SETTINGS_VALUE_TYPE_INT | |
GOLIOTH_SETTINGS_VALUE_TYPE_BOOL | |
GOLIOTH_SETTINGS_VALUE_TYPE_FLOAT | |
GOLIOTH_SETTINGS_VALUE_TYPE_STRING |
Definition at line 70 of file settings.h.
enum golioth_status golioth_settings_deinit | ( | struct golioth_settings * | settings | ) |
Deinitialize the Settings service
Cancel all registered settings and free the Golioth Settings service handle.
settings | Golioth Settings service handle. |
struct golioth_settings * golioth_settings_init | ( | struct golioth_client * | client | ) |
Initialize the Settings service
client | Client handle |
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.
enum golioth_status golioth_settings_register_int | ( | struct golioth_settings * | settings, |
const char * | setting_name, | ||
golioth_int_setting_cb | callback, | ||
void * | callback_arg ) |
Register a specific setting of type int
settings | Settings handle |
setting_name | The name of the setting. This is expected to be a literal string, therefore on the pointer is registered (not a full copy of the string). |
callback | Callback function that will be called when the setting value is received from Golioth cloud |
callback_arg | General-purpose user argument, forwarded as-is to callback, can be NULL. |
GOLIOTH_OK | Setting registered successfully |
GOLIOTH_ERR_MEM_ALLOC | Max number of registered settings exceeded |
GOLIOTH_ERR_NOT_IMPLEMENTED | If Golioth settings are disabled in config |
GOLIOTH_ERR_NULL | callback is NULL |
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 ) |
Same as golioth_settings_register_int, but with specific min and max value which will be checked by this library.
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.