Golioth Zephyr SDK
Golioth Settings

Data Structures

struct  golioth_settings_value
 A setting value. More...
 
struct  golioth_settings
 Settings state data, placed in struct golioth_client. More...
 

Typedefs

typedef enum golioth_settings_status(* golioth_settings_cb) (const char *key, const struct golioth_settings_value *value)
 Callback for an individual setting. More...
 

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_BOOL , GOLIOTH_SETTINGS_VALUE_TYPE_FLOAT , GOLIOTH_SETTINGS_VALUE_TYPE_STRING ,
  GOLIOTH_SETTINGS_VALUE_TYPE_INT64
}
 Different types of setting values. More...
 

Functions

int golioth_settings_register_callback (struct golioth_client *client, golioth_settings_cb callback)
 Register callback for handling settings. More...
 
int golioth_settings_observe (struct golioth_client *client)
 Observe for Settings. More...
 

Detailed Description

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 bool, float, or string.

Overall, the flow is:

  1. Application registers a callback to handle settings.
  2. This library observes for settings changes from cloud.
  3. Cloud pushes settings changes to device.
  4. For each setting, this library calls the user-registered callback.
  5. This library reports status of applying settings to cloud.

This library is responsible for interfacing with the cloud and has no knowledge of the specific settings.

Typedef Documentation

◆ golioth_settings_cb

typedef enum golioth_settings_status(* golioth_settings_cb) (const char *key, const struct golioth_settings_value *value)

Callback for an individual setting.

Parameters
keyThe setting key, NULL-terminated
valueThe setting value
Returns
GOLIOTH_SETTINGS_SUCCESS - setting is valid
Otherwise - setting is not valid

Definition at line 1 of file settings.h.

Enumeration Type Documentation

◆ golioth_settings_status

Enumeration of Settings status codes.

Enumerator
GOLIOTH_SETTINGS_SUCCESS 
GOLIOTH_SETTINGS_KEY_NOT_RECOGNIZED 
GOLIOTH_SETTINGS_KEY_NOT_VALID 
GOLIOTH_SETTINGS_VALUE_FORMAT_NOT_VALID 
GOLIOTH_SETTINGS_VALUE_OUTSIDE_RANGE 
GOLIOTH_SETTINGS_VALUE_STRING_TOO_LONG 
GOLIOTH_SETTINGS_GENERAL_ERROR 

Definition at line 45 of file settings.h.

◆ golioth_settings_value_type

Different types of setting values.

Note that there is no "int" type because all numbers sent by the server are formatted as floating point.

Enumerator
GOLIOTH_SETTINGS_VALUE_TYPE_UNKNOWN 
GOLIOTH_SETTINGS_VALUE_TYPE_BOOL 
GOLIOTH_SETTINGS_VALUE_TYPE_FLOAT 
GOLIOTH_SETTINGS_VALUE_TYPE_STRING 
GOLIOTH_SETTINGS_VALUE_TYPE_INT64 

Definition at line 68 of file settings.h.

Function Documentation

◆ golioth_settings_observe()

int golioth_settings_observe ( struct golioth_client client)

Observe for Settings.

User applications should call this function in the on_connect callback, if they wish to observe Settings.

Establishes a single observation for the settings endpoint ".c". The handler for this observation will call the callback registered with golioth_settings_register_callback.

Parameters
clientClient instance
Returns
0 - Settings observation established
<0 - Error observing Settings

◆ golioth_settings_register_callback()

int golioth_settings_register_callback ( struct golioth_client client,
golioth_settings_cb  callback 
)

Register callback for handling settings.

The client will be used to observe for settings from the cloud.

Parameters
clientClient handle
callbackCallback function to call for settings changes
Returns
0 - Callback registered successfully
<0 - Error, callback not registered