1 #include "tool_config.h"
6 #define STRDUP(a) (a) ? strdup(a) : NULL
40 .dp_type = DP_TYPE_UNKNOWN,
54 void tool_config_set_register(bool val)
59 bool tool_config_get_register()
64 void tool_config_set_discovery(bool val)
69 bool tool_config_get_discovery()
74 void tool_config_set_service_name(char *val)
76 configs.service_name = STRDUP(val);
79 const char *tool_config_get_service_name()
81 return (const char *)configs.service_name;
84 void tool_config_set_service_type(char *val)
86 configs.service_type = STRDUP(val);
89 const char *tool_config_get_service_type()
91 return (const char *)configs.service_type;
94 void tool_config_set_iface_name(char *val)
96 configs.iface_name = STRDUP(val);
99 const char *tool_config_get_iface_name()
101 return (const char *)configs.iface_name;
104 void tool_config_set_with_ble(bool val)
106 configs.with_ble = val;
109 bool tool_config_get_with_ble()
111 return configs.with_ble;
114 void tool_config_set_remote_address(char *val)
116 configs.remote_addr = STRDUP(val);
119 const char *tool_config_get_remote_address()
121 return (const char *)configs.remote_addr;
124 void tool_config_set_address_family(int val)
126 configs.addr_family = val;
129 int tool_config_get_address_family()
131 return configs.addr_family;
134 void tool_config_set_port(int val)
139 int tool_config_get_port()
144 void tool_config_set_dp_type(char *val)
149 if (strcmp(val, "client") == 0)
150 configs.dp_type = DP_TYPE_CLIENT;
151 else if (strcmp(val, "server") == 0)
152 configs.dp_type = DP_TYPE_SERVER;
153 else if (strcmp(val, "pubsub") == 0)
154 configs.dp_type = DP_TYPE_PUBSUB;
157 dp_type_t tool_config_get_dp_type()
159 return configs.dp_type;
162 void tool_config_set_max_conn(int val)
164 configs.max_conn = val;
167 int tool_config_get_max_conn()
169 return configs.max_conn;
172 void tool_config_set_topic(char *val)
174 configs.topic = STRDUP(val);
177 const char *tool_config_get_topic()
179 return configs.topic;
182 void tool_config_set_message(char *val)
184 configs.message = STRDUP(val);
187 const char *tool_config_get_message()
189 return configs.message;
192 void tool_config_set_file(char *val)
194 configs.file = STRDUP(val);
197 const char *tool_config_get_file()
202 void tool_config_set_interval(int val)
204 configs.interval = val;
207 int tool_config_get_interval()
209 return configs.interval;
212 sec_type_t tool_config_get_security_type()
215 return SEC_TYPE_PSK_OVER_TLS;
216 else if (configs.cacert || configs.cert)
219 return SEC_TYPE_NONE;
222 void tool_config_set_cacert(char *val)
224 configs.cacert = STRDUP(val);
227 const char *tool_config_get_cacert()
229 return configs.cacert;
232 void tool_config_set_cert(char *val)
234 configs.cert = STRDUP(val);
237 const char *tool_config_get_cert()
242 void tool_config_set_private_key(char *val)
244 configs.key = STRDUP(val);
247 const char *tool_config_get_private_key()
252 void tool_config_set_psk(char *val)
254 configs.psk = STRDUP(val);
257 const char *tool_config_get_psk()
262 void tool_config_set_verbose(bool val)
264 configs.verbose = val;
267 bool tool_config_get_verbose()
269 return configs.verbose;
272 void tool_config_set_log_file(char *val)
274 configs.log_file = STRDUP(val);
277 const char *tool_config_get_log_file()
279 return (const char *)configs.log_file;
282 void tool_config_deinit()
284 free(configs.service_name);
285 free(configs.service_type);
286 free(configs.iface_name);
287 free(configs.remote_addr);
289 free(configs.message);
290 free(configs.cacert);
294 free(configs.log_file);