Zigbee Protocol Controller 1.6.0
config.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
33#ifndef CONFIG_H
34#define CONFIG_H
35#include <stdbool.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41// Configuration keys
42#define CONFIG_KEY_MQTT_HOST "mqtt.host"
43#define CONFIG_KEY_MQTT_PORT "mqtt.port"
44#define CONFIG_KEY_MQTT_CLIENT_ID "mqtt.client_id"
45#define CONFIG_KEY_MQTT_CAFILE "mqtt.cafile"
46#define CONFIG_KEY_MQTT_CERTFILE "mqtt.certfile"
47#define CONFIG_KEY_MQTT_KEYFILE "mqtt.keyfile"
48#define CONFIG_KEY_LOG_LEVEL "log.level"
49#define CONFIG_KEY_LOG_TAG_LEVEL "log.tag_level"
50
51// Default Settings
52#define DEFAULT_CONFIG_PATH "/etc/uic/uic.cfg"
53
54typedef enum {
62
72 const char *help,
73 const char *default_value);
74
84 config_add_int(const char *name, const char *help, int default_value);
85
95 config_add_double(const char *name, const char *help, double default_value);
96
106 config_add_bool(const char *name, const char *help, bool default_value);
107
115config_status_t config_add_flag(const char *name, const char *help);
116
128config_status_t config_parse(int argc, char **argv, const char *version);
129
130// Config Getters
131
143config_status_t config_get_as_string(const char *name, const char **result);
144
152config_status_t config_get_as_int(const char *name, int *result);
153
161config_status_t config_get_as_double(const char *name, double *result);
162
170config_status_t config_get_as_bool(const char *name, bool *result);
171
181
190
191#ifdef __cplusplus
192}
193#include <ostream>
198config_status_t config_parse_with_output(int argc,
199 char **argv,
200 const char *version,
201 std::ostream &out);
202#endif
203
204#endif //CONFIG_H
config_status_t config_add_string(const char *name, const char *help, const char *default_value)
Add string configuration.
config_status_t config_add_bool(const char *name, const char *help, bool default_value)
Add a bool configuration.
config_status_t config_get_as_string(const char *name, const char **result)
Get the config as a C-string.
config_status_t
Definition: config.h:54
config_status_t config_get_as_bool(const char *name, bool *result)
Get the config as bool.
config_status_t config_get_as_double(const char *name, double *result)
Get the config as a double.
config_status_t config_add_double(const char *name, const char *help, double default_value)
Add a double configuration.
config_status_t config_get_as_int(const char *name, int *result)
Get the config as an integer.
config_status_t config_add_int(const char *name, const char *help, int default_value)
Add an integer configuration.
config_status_t config_parse(int argc, char **argv, const char *version)
Parse command line arguments to the config system.
void config_reset()
Reset the config.
config_status_t config_has_flag(const char *name)
Check is a config paramter exists.
config_status_t config_add_flag(const char *name, const char *help)
Add a flag configuration.
@ CONFIG_STATUS_INVALID_TYPE
Definition: config.h:58
@ CONFIG_STATUS_INFO_MESSAGE
Definition: config.h:60
@ CONFIG_STATUS_ERROR
Definition: config.h:57
@ CONFIG_STATUS_NOK
Definition: config.h:56
@ CONFIG_STATUS_DOES_NOT_EXIST
Definition: config.h:59
@ CONFIG_STATUS_OK
Definition: config.h:55