Golioth Zephyr SDK
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 #ifndef GOLIOTH_INCLUDE_NET_GOLIOTH_SETTINGS_H_
8 #define GOLIOTH_INCLUDE_NET_GOLIOTH_SETTINGS_H_
9 
10 #include <stdint.h>
11 #include <zephyr/net/coap.h>
12 
40 struct golioth_client;
41 
46  /* Setting applied successfully to the device */
48  /* The setting key is not recognized, this setting is unknown */
50  /* The setting key is too long, ill-formatted */
52  /* The setting value is improperly formatted */
54  /* The setting value is outside of allowed range */
56  /* The setting value string is too long, exceeds max length */
58  /* Other general error */
60 };
61 
74 };
75 
83  union {
84  bool b;
85  float f;
86  struct {
87  const char *ptr; /* not NULL-terminated */
88  size_t len;
89  } string;
90  int64_t i64;
91  };
92 };
93 
104  const char *key,
105  const struct golioth_settings_value *value);
106 
111 #if defined(CONFIG_GOLIOTH_SETTINGS)
112  bool initialized;
113  golioth_settings_cb callback;
114 #endif
115 };
116 
129  golioth_settings_cb callback);
130 
147 
150 #endif /* GOLIOTH_INCLUDE_NET_GOLIOTH_SETTINGS_H_ */
int golioth_settings_observe(struct golioth_client *client)
Observe for Settings.
int golioth_settings_register_callback(struct golioth_client *client, golioth_settings_cb callback)
Register callback for handling settings.
enum golioth_settings_status(* golioth_settings_cb)(const char *key, const struct golioth_settings_value *value)
Callback for an individual setting.
Definition: settings.h:103
golioth_settings_status
Enumeration of Settings status codes.
Definition: settings.h:45
golioth_settings_value_type
Different types of setting values.
Definition: settings.h:68
@ GOLIOTH_SETTINGS_GENERAL_ERROR
Definition: settings.h:59
@ GOLIOTH_SETTINGS_VALUE_OUTSIDE_RANGE
Definition: settings.h:55
@ GOLIOTH_SETTINGS_VALUE_STRING_TOO_LONG
Definition: settings.h:57
@ GOLIOTH_SETTINGS_KEY_NOT_VALID
Definition: settings.h:51
@ GOLIOTH_SETTINGS_KEY_NOT_RECOGNIZED
Definition: settings.h:49
@ GOLIOTH_SETTINGS_SUCCESS
Definition: settings.h:47
@ GOLIOTH_SETTINGS_VALUE_FORMAT_NOT_VALID
Definition: settings.h:53
@ GOLIOTH_SETTINGS_VALUE_TYPE_STRING
Definition: settings.h:72
@ GOLIOTH_SETTINGS_VALUE_TYPE_UNKNOWN
Definition: settings.h:69
@ GOLIOTH_SETTINGS_VALUE_TYPE_INT64
Definition: settings.h:73
@ GOLIOTH_SETTINGS_VALUE_TYPE_BOOL
Definition: settings.h:70
@ GOLIOTH_SETTINGS_VALUE_TYPE_FLOAT
Definition: settings.h:71
Represents a Golioth client instance.
Definition: net/golioth.h:50
A setting value.
Definition: settings.h:81
struct golioth_settings_value::@0::@2 string
const char * ptr
Definition: settings.h:87
enum golioth_settings_value_type type
Definition: settings.h:82
Settings state data, placed in struct golioth_client.
Definition: settings.h:110