Fawkes API Fawkes Development Version
net_handler.cpp
1
2/***************************************************************************
3 * net_handler.cpp - Fawkes configuration network handler
4 *
5 * Generated: Sat Jan 06 22:55:03 2007
6 * Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#include <config/config.h>
25#include <config/net_handler.h>
26#include <config/net_list_content.h>
27#include <config/net_messages.h>
28#include <logging/liblogger.h>
29#include <netcomm/fawkes/component_ids.h>
30#include <netcomm/fawkes/hub.h>
31
32#include <algorithm>
33#include <cstring>
34
35namespace fawkes {
36
37/** @class ConfigNetworkHandler <config/net_handler.h>
38 * Fawkes Configuration Network Handler.
39 * It provides access to a given config via the network.
40 * This is mainly used to allow modification of config values over the network.
41 *
42 * @author Tim Niemueller
43 */
44
45/** Constructor.
46 * @param config configuration, loaded and ready to be used for getting and
47 * setting values
48 * @param hub Fawkes network hub to use for receiving and sending network
49 * messages
50 */
52: Thread("ConfigNetworkHandler", Thread::OPMODE_WAITFORWAKEUP),
53 FawkesNetworkHandler(FAWKES_CID_CONFIGMANAGER),
55{
56 config_ = config;
57 hub_ = hub;
58
59 start();
60
61 config_->add_change_handler(this);
62 hub_->add_handler(this);
63}
64
65/** Destructor. */
67{
68 hub_->remove_handler(this);
69 cancel();
70 join();
71 config_->rem_change_handler(this);
72 inbound_queue_.clear();
73}
74
75/** Send invalid value message.
76 * @param clid client ID
77 * @param path path
78 */
79void
80ConfigNetworkHandler::send_inv_value(unsigned int clid, const char *path)
81{
82 config_invval_msg_t *r = prepare_msg<config_invval_msg_t>(path, false);
83 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INV_VALUE, r, sizeof(config_invval_msg_t));
84}
85
86/** Send value.
87 * @param clid client ID
88 * @param i value
89 */
90void
91ConfigNetworkHandler::send_value(unsigned int clid, const Configuration::ValueIterator *i)
92{
93 if (i->is_uint()) {
94 try {
95 uint32_t *values;
96 uint16_t num_values = i->is_list() ? i->get_list_size() : 0;
97 size_t data_size = 0;
98 void * m = prepare_value_msg<uint32_t>(
99 i->path(), i->is_default(), i->is_list(), num_values, data_size, (void **)&values);
100 if (i->is_list()) {
101 std::vector<unsigned int> c_values = i->get_uints();
102 for (uint16_t j = 0; j < num_values; ++j)
103 values[j] = c_values[j];
104 } else {
105 values[0] = i->get_uint();
106 }
107 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_UINT_VALUE, m, data_size);
108 } catch (Exception &e) {
109 LibLogger::log_warn("ConfigNetworkHandler",
110 "send_value: Value %s could not be sent",
111 i->path());
112 LibLogger::log_warn("ConfigNetworkHandler", e);
113 }
114 } else if (i->is_int()) {
115 try {
116 int32_t *values;
117 int16_t num_values = i->is_list() ? i->get_list_size() : 0;
118 size_t data_size = 0;
119 void * m = prepare_value_msg<int32_t>(
120 i->path(), i->is_default(), i->is_list(), num_values, data_size, (void **)&values);
121 if (i->is_list()) {
122 std::vector<int> c_values = i->get_ints();
123 for (uint16_t j = 0; j < num_values; ++j)
124 values[j] = c_values[j];
125 } else {
126 values[0] = i->get_int();
127 }
128 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INT_VALUE, m, data_size);
129 } catch (Exception &e) {
130 LibLogger::log_warn("ConfigNetworkHandler",
131 "send_value: Value %s could not be sent",
132 i->path());
133 LibLogger::log_warn("ConfigNetworkHandler", e);
134 }
135 } else if (i->is_bool()) {
136 try {
137 int32_t *values;
138 int16_t num_values = i->is_list() ? i->get_list_size() : 0;
139 size_t data_size = 0;
140 void * m = prepare_value_msg<int32_t>(
141 i->path(), i->is_default(), i->is_list(), num_values, data_size, (void **)&values);
142 if (i->is_list()) {
143 std::vector<bool> c_values = i->get_bools();
144 for (uint16_t j = 0; j < num_values; ++j)
145 values[j] = (c_values[j] ? 1 : 0);
146 } else {
147 values[0] = i->get_bool() ? 1 : 0;
148 }
149 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_BOOL_VALUE, m, data_size);
150 } catch (Exception &e) {
151 LibLogger::log_warn("ConfigNetworkHandler",
152 "send_value: Value %s could not be sent",
153 i->path());
154 LibLogger::log_warn("ConfigNetworkHandler", e);
155 }
156 } else if (i->is_float()) {
157 try {
158 float * values;
159 uint16_t num_values = i->is_list() ? i->get_list_size() : 0;
160 size_t data_size = 0;
161 void * m = prepare_value_msg<float>(
162 i->path(), i->is_default(), i->is_list(), num_values, data_size, (void **)&values);
163 if (i->is_list()) {
164 std::vector<float> c_values = i->get_floats();
165 for (uint16_t j = 0; j < num_values; ++j)
166 values[j] = c_values[j];
167 } else {
168 values[0] = i->get_float();
169 }
170 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_FLOAT_VALUE, m, data_size);
171 } catch (Exception &e) {
172 LibLogger::log_warn("ConfigNetworkHandler",
173 "send_value: Value %s could not be sent",
174 i->path());
175 LibLogger::log_warn("ConfigNetworkHandler", e);
176 }
177 } else if (i->is_string()) {
178 try {
179 if (i->is_list()) {
180 std::vector<std::string> s = i->get_strings();
181 size_t data_size = sizeof(config_descriptor_t);
182
183 for (unsigned int j = 0; j < s.size(); ++j) {
184 data_size += sizeof(config_string_value_t) + s[j].length() + 1;
185 }
186 void *m = calloc(1, data_size);
187
188 config_descriptor_t *cd = (config_descriptor_t *)m;
189 strncpy(cd->path, i->path(), CONFIG_MSG_PATH_LENGTH - 1);
190 cd->is_default = i->is_default();
191 cd->num_values = s.size();
192
193 char *tmp = ((char *)m + sizeof(config_descriptor_t));
194 for (unsigned int j = 0; j < s.size(); ++j) {
195 config_string_value_t *sv = (config_string_value_t *)tmp;
196 char * msg_string = tmp + sizeof(config_string_value_t);
197 sv->s_length = s[j].length();
198 strcpy(msg_string, s[j].c_str());
199 tmp += sizeof(config_string_value_t) + sv->s_length + 1;
200 }
201
202 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_STRING_VALUE, m, data_size);
203 } else {
204 std::string s = i->get_string();
205 size_t data_size =
206 sizeof(config_descriptor_t) + sizeof(config_string_value_t) + s.length() + 1;
207 void * m = calloc(1, data_size);
208 config_descriptor_t *cd = (config_descriptor_t *)m;
209 strncpy(cd->path, i->path(), CONFIG_MSG_PATH_LENGTH - 1);
210 cd->is_default = i->is_default();
211 cd->num_values = 0;
212
213 config_string_value_t *sv =
214 (config_string_value_t *)((char *)m + sizeof(config_descriptor_t));
215 char *msg_string = (char *)sv + sizeof(config_string_value_t);
216
217 sv->s_length = s.length();
218 strcpy(msg_string, s.c_str());
219
220 hub_->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_STRING_VALUE, m, data_size);
221 }
222 } catch (Exception &e) {
223 LibLogger::log_warn("ConfigNetworkHandler",
224 "send_value: Value %s could not be sent",
225 i->path());
226 LibLogger::log_warn("ConfigNetworkHandler", e);
227 }
228 } else {
229 LibLogger::log_warn("ConfigNetworkHandler", "send_value: unknown type of value %s", i->path());
230 }
231}
232
233/** Process all network messages that have been received. */
234void
236{
237 while (!inbound_queue_.empty()) {
238 FawkesNetworkMessage *msg = inbound_queue_.front();
239
240 // printf("Received message of type %u\n", msg->msgid());
241
242 if (msg->msgid() == MSG_CONFIG_SUBSCRIBE) {
243 subscribers_.push_back_locked(msg->clid());
244 subscribers_.sort();
245 subscribers_.unique();
246
247 config_->lock();
248 ConfigListContent * content = new ConfigListContent();
250 while (i->next()) {
251 if (i->is_default()) {
252 content->append(i);
253 }
254 }
255 delete i;
256 i = config_->iterator();
257 while (i->next()) {
258 if (!i->is_default()) {
259 content->append(i);
260 }
261 }
262 delete i;
263 hub_->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_LIST, content);
264 config_->unlock();
265
266 } else if (msg->msgid() == MSG_CONFIG_ERASE_VALUE) {
267 try {
269 char path[CONFIG_MSG_PATH_LENGTH];
270 path[CONFIG_MSG_PATH_LENGTH - 1] = 0;
271 memcpy(path, m->cp.path, CONFIG_MSG_PATH_LENGTH);
272
273 if (m->cp.is_default == 1) {
274 config_->erase_default(path);
275 } else {
276 config_->erase(path);
277 }
278
280 prepare_msg<config_value_erased_msg_t>(path, (m->cp.is_default == 1));
281 hub_->send(msg->clid(),
282 FAWKES_CID_CONFIGMANAGER,
283 MSG_CONFIG_VALUE_ERASED,
284 r,
286
287 } catch (Exception &e) {
288 send_inv_value(msg->clid(), "?");
289 e.append("Failed to erase value");
290 LibLogger::log_warn("ConfigNetworkHandler", "Failed to erase value");
291 LibLogger::log_warn("ConfigNetworkHandler", e);
292 }
293
294 } else if ((msg->msgid() >= MSG_CONFIG_GET_BEGIN) && (msg->msgid() <= MSG_CONFIG_GET_END)) {
295 if (msg->payload_size() != sizeof(config_getval_msg_t)) {
296 LibLogger::log_warn("ConfigNetworkHandler",
297 "CONFIG_GET_FLOAT: invalid payload size "
298 "(received %zu instead of %zu bytes",
299 msg->payload_size(),
300 sizeof(config_getval_msg_t));
301 } else {
303 char path[CONFIG_MSG_PATH_LENGTH + 1];
304 path[CONFIG_MSG_PATH_LENGTH] = 0;
305 strncpy(path, m->cp.path, CONFIG_MSG_PATH_LENGTH);
306
307 switch (msg->msgid()) {
308 case MSG_CONFIG_GET_FLOAT:
309 case MSG_CONFIG_GET_UINT:
310 case MSG_CONFIG_GET_INT:
311 case MSG_CONFIG_GET_BOOL:
312 case MSG_CONFIG_GET_STRING:
313 case MSG_CONFIG_GET_VALUE:
314 try {
315 Configuration::ValueIterator *i = config_->get_value(path);
316 if (i->next()) {
317 send_value(msg->clid(), i);
318 } else {
319 send_inv_value(msg->clid(), path);
320 }
321 delete i;
322 } catch (ConfigurationException &e) {
323 LibLogger::log_warn("ConfigNetworkHandler",
324 "get value: Value %s could not be found",
325 path);
326 LibLogger::log_warn("ConfigNetworkHandler", e);
327 }
328 break;
329 }
330 }
331 } else if ((msg->msgid() >= MSG_CONFIG_SET_BEGIN) && (msg->msgid() <= MSG_CONFIG_SET_END)) {
332 bool success = false;
333
334 char path[CONFIG_MSG_PATH_LENGTH + 1];
335 if (msg->payload_size() < sizeof(config_descriptor_t)) {
336 LibLogger::log_warn("ConfigNetworkHandler",
337 "inbound set: payload is too small"
338 "(%zu is less than %zu bytes",
339 msg->payload_size(),
340 sizeof(config_descriptor_t));
341 send_inv_value(msg->clid(), "?");
342 } else {
344 path[CONFIG_MSG_PATH_LENGTH] = 0;
345 strncpy(path, cd->path, CONFIG_MSG_PATH_LENGTH);
346
347 switch (msg->msgid()) {
348 case MSG_CONFIG_SET_FLOAT:
349 case MSG_CONFIG_SET_DEFAULT_FLOAT:
350 try {
351 float *vs = (float *)((char *)msg->payload() + sizeof(config_descriptor_t));
352 if (cd->num_values > 0) {
353 std::vector<float> values(cd->num_values);
354 for (unsigned int i = 0; i < cd->num_values; ++i) {
355 values[i] = vs[i];
356 }
357 config_->set_floats(path, values);
358 } else {
359 if (msg->msgid() == MSG_CONFIG_SET_FLOAT) {
360 config_->set_float(path, *vs);
361 } else {
362 config_->set_default_float(path, *vs);
363 }
364 }
365 success = true;
366 } catch (Exception &e) {
367 send_inv_value(msg->clid(), path);
368 LibLogger::log_warn("ConfigNetworkHandler",
369 "set float: Value %s could not be set",
370 path);
371 LibLogger::log_warn("ConfigNetworkHandler", e);
372 }
373 break;
374
375 case MSG_CONFIG_SET_UINT:
376 case MSG_CONFIG_SET_DEFAULT_UINT:
377 try {
378 uint32_t *vs = (uint32_t *)((char *)msg->payload() + sizeof(config_descriptor_t));
379 if (cd->num_values > 0) {
380 std::vector<unsigned int> values(cd->num_values);
381 for (unsigned int i = 0; i < cd->num_values; ++i) {
382 values[i] = vs[i];
383 }
384 config_->set_uints(path, values);
385 } else {
386 if (msg->msgid() == MSG_CONFIG_SET_UINT) {
387 config_->set_uint(path, *vs);
388 } else {
389 config_->set_default_uint(path, *vs);
390 }
391 }
392 success = true;
393 } catch (Exception &e) {
394 send_inv_value(msg->clid(), path);
395 LibLogger::log_warn("ConfigNetworkHandler",
396 "set uint: Value %s could not be set",
397 path);
398 LibLogger::log_warn("ConfigNetworkHandler", e);
399 }
400 break;
401
402 case MSG_CONFIG_SET_INT:
403 case MSG_CONFIG_SET_DEFAULT_INT:
404 try {
405 int32_t *vs = (int32_t *)((char *)msg->payload() + sizeof(config_descriptor_t));
406 if (cd->num_values > 0) {
407 std::vector<int> values(cd->num_values);
408 for (unsigned int i = 0; i < cd->num_values; ++i) {
409 values[i] = vs[i];
410 }
411 config_->set_ints(path, values);
412 } else {
413 if (msg->msgid() == MSG_CONFIG_SET_INT) {
414 config_->set_int(path, *vs);
415 } else {
416 config_->set_default_int(path, *vs);
417 }
418 }
419 success = true;
420 } catch (Exception &e) {
421 send_inv_value(msg->clid(), path);
422 LibLogger::log_warn("ConfigNetworkHandler", "set int: Value %s could not be set", path);
423 LibLogger::log_warn("ConfigNetworkHandler", e);
424 }
425 break;
426
427 case MSG_CONFIG_SET_BOOL:
428 case MSG_CONFIG_SET_DEFAULT_BOOL:
429 try {
430 int32_t *vs = (int32_t *)((char *)msg->payload() + sizeof(config_descriptor_t));
431 if (cd->num_values > 0) {
432 std::vector<bool> values(cd->num_values);
433 for (unsigned int i = 0; i < cd->num_values; ++i) {
434 values[i] = (vs[i] != 0);
435 }
436 config_->set_bools(path, values);
437 } else {
438 if (msg->msgid() == MSG_CONFIG_SET_INT) {
439 config_->set_bool(path, (*vs != 0));
440 } else {
441 config_->set_default_bool(path, (*vs != 0));
442 }
443 }
444 success = true;
445 } catch (Exception &e) {
446 send_inv_value(msg->clid(), path);
447 LibLogger::log_warn("ConfigNetworkHandler",
448 "set bool: Value %s could not be set",
449 path);
450 LibLogger::log_warn("ConfigNetworkHandler", e);
451 }
452 break;
453
454 case MSG_CONFIG_SET_STRING:
455 case MSG_CONFIG_SET_DEFAULT_STRING:
456 try {
457 char *tmp = ((char *)msg->payload() + sizeof(config_descriptor_t));
458
459 if (cd->num_values > 0) {
460 std::vector<std::string> values(cd->num_values);
461 for (unsigned int i = 0; i < cd->num_values; ++i) {
463 char * msg_string = tmp + sizeof(config_string_value_t);
464 tmp += sizeof(config_string_value_t) + sv->s_length + 1;
465 values[i] = std::string(msg_string, sv->s_length);
466 }
467 config_->set_strings(path, values);
468 } else {
470 char * msg_string = tmp + sizeof(config_string_value_t);
471 std::string value = std::string(msg_string, sv->s_length);
472 if (msg->msgid() == MSG_CONFIG_SET_INT) {
473 config_->set_string(path, value);
474 } else {
475 config_->set_default_string(path, value);
476 }
477 }
478 success = true;
479 } catch (Exception &e) {
480 send_inv_value(msg->clid(), path);
481 LibLogger::log_warn("ConfigNetworkHandler",
482 "set string: Value %s could not be set",
483 path);
484 LibLogger::log_warn("ConfigNetworkHandler", e);
485 }
486 break;
487 }
488 }
489
490 if (success) {
491 try {
492 Configuration::ValueIterator *i = config_->get_value(path);
493 if (i->next()) {
494 send_value(msg->clid(), i);
495 } else {
496 send_inv_value(msg->clid(), path);
497 }
498 delete i;
499 } catch (ConfigurationException &e) {
500 LibLogger::log_warn("ConfigNetworkHandler",
501 "get value: Value %s could not be found",
502 path);
503 LibLogger::log_warn("ConfigNetworkHandler", e);
504 }
505 }
506 }
507
508 msg->unref();
509 inbound_queue_.pop_locked();
510 }
511}
512
513/** Handle network message.
514 * The message is put into the inbound queue and processed in processAfterLoop().
515 * @param msg message
516 */
517void
519{
520 msg->ref();
521 inbound_queue_.push_locked(msg);
522 wakeup();
523}
524
525/** Client connected.
526 * Ignored.
527 * @param clid client ID
528 */
529void
531{
532}
533
534/** Client disconnected.
535 * If the client was a subscriber it is removed.
536 * @param clid client ID
537 */
538void
540{
541 subscribers_.lock();
542 if (find(subscribers_.begin(), subscribers_.end(), clid) != subscribers_.end()) {
544 "ConfigNetworkHandler",
545 "Client %u disconnected without closing the config, removing from list of subscribers",
546 clid);
547 subscribers_.remove(clid);
548 }
549 subscribers_.unlock();
550}
551
552/** Tag changed.
553 * Ignored.
554 * @param new_tag new tag
555 */
556void
558{
559}
560
561void
563{
564 const char *path = v->path();
565
566 subscribers_.lock();
567 for (sit_ = subscribers_.begin(); sit_ != subscribers_.end(); ++sit_) {
568 try {
569 send_value(*sit_, v);
570 } catch (Exception &e) {
571 LibLogger::log_warn("ConfigNetworkHandler",
572 "config_value_changed: Value for %s could not be sent "
573 "to client %u",
574 path,
575 *sit_);
576 LibLogger::log_warn("ConfigNetworkHandler", e);
577 }
578 }
579 subscribers_.unlock();
580}
581
582void
584{
585}
586
587void
589{
590 subscribers_.lock();
591 for (sit_ = subscribers_.begin(); sit_ != subscribers_.end(); ++sit_) {
592 try {
593 config_value_erased_msg_t *r = prepare_msg<config_value_erased_msg_t>(path, false);
594 hub_->send(*sit_,
595 FAWKES_CID_CONFIGMANAGER,
596 MSG_CONFIG_VALUE_ERASED,
597 r,
599 } catch (Exception &e) {
600 LibLogger::log_warn("ConfigNetworkHandler",
601 "configValueErased: Value for %s could not be sent "
602 "to client %u",
603 path,
604 *sit_);
605 }
606 }
607 subscribers_.unlock();
608}
609
610} // end namespace fawkes
Config list content.
void append(Configuration::ValueIterator *i)
Append from iterator.
ConfigNetworkHandler(Configuration *config, FawkesNetworkHub *hub)
Constructor.
Definition: net_handler.cpp:51
virtual void loop()
Process all network messages that have been received.
virtual void config_value_erased(const char *path)
Called whenever a value has been erased from the config.
~ConfigNetworkHandler()
Destructor.
Definition: net_handler.cpp:66
virtual void client_disconnected(unsigned int clid)
Client disconnected.
virtual void client_connected(unsigned int clid)
Client connected.
virtual void config_value_changed(const Configuration::ValueIterator *v)
Called whenever a watched value has changed.
virtual void config_tag_changed(const char *new_location)
Tag changed.
virtual void config_comment_changed(const Configuration::ValueIterator *v)
Called whenever a comment of a watched value has changed.
virtual void handle_network_message(FawkesNetworkMessage *msg)
Handle network message.
Interface for configuration change handling.
Generic configuration exception.
Definition: config.h:40
Iterator interface to iterate over config values.
Definition: config.h:75
virtual const char * path() const =0
Path of value.
virtual bool next()=0
Check if there is another element and advance to this if possible.
virtual bool is_default() const =0
Check if current value was read from the default config.
Interface for configuration handling.
Definition: config.h:68
virtual void set_bools(const char *path, std::vector< bool > &b)=0
Set new value in configuration of type bool.
virtual void set_uint(const char *path, unsigned int uint)=0
Set new value in configuration of type unsigned int.
virtual void set_ints(const char *path, std::vector< int > &i)=0
Set new value in configuration of type int.
virtual void set_bool(const char *path, bool b)=0
Set new value in configuration of type bool.
virtual ValueIterator * iterator()=0
Iterator for all values.
virtual void rem_change_handler(ConfigurationChangeHandler *h)
Remove a configuration change handler.
Definition: config.cpp:619
virtual void set_default_float(const char *path, float f)=0
Set new default value in configuration of type float.
virtual void set_float(const char *path, float f)=0
Set new value in configuration of type float.
virtual void set_default_string(const char *path, std::string &s)=0
Set new default value in configuration of type string.
virtual ValueIterator * get_value(const char *path)=0
Get value from configuration.
virtual void set_string(const char *path, std::string &s)=0
Set new value in configuration of type string.
virtual void set_uints(const char *path, std::vector< unsigned int > &uint)=0
Set new value in configuration of type unsigned int.
virtual void erase_default(const char *path)=0
Erase the given default value from the configuration.
virtual void set_floats(const char *path, std::vector< float > &f)=0
Set new value in configuration of type float.
virtual void lock()=0
Lock the config.
virtual void unlock()=0
Unlock the config.
virtual void set_default_bool(const char *path, bool b)=0
Set new default value in configuration of type bool.
virtual void set_int(const char *path, int i)=0
Set new value in configuration of type int.
virtual void set_default_uint(const char *path, unsigned int uint)=0
Set new default value in configuration of type unsigned int.
virtual void set_default_int(const char *path, int i)=0
Set new default value in configuration of type int.
virtual void set_strings(const char *path, std::vector< std::string > &s)=0
Set new value in configuration of type string.
virtual void add_change_handler(ConfigurationChangeHandler *h)
Add a configuration change handler.
Definition: config.cpp:603
virtual void erase(const char *path)=0
Erase the given value from the configuration.
Base class for exceptions in Fawkes.
Definition: exception.h:36
void append(const char *format,...) noexcept
Append messages to the message list.
Definition: exception.cpp:333
Network handler abstract base class.
Definition: handler.h:32
Fawkes Network Hub.
Definition: hub.h:34
virtual void send(FawkesNetworkMessage *msg)=0
Method to send a message to a specific client.
virtual void remove_handler(FawkesNetworkHandler *handler)=0
Remove a message handler.
virtual void add_handler(FawkesNetworkHandler *handler)=0
Add a message handler.
Representation of a message that is sent over the network.
Definition: message.h:77
unsigned short int msgid() const
Get message type ID.
Definition: message.cpp:294
MT * msg() const
Get correctly casted payload.
Definition: message.h:120
unsigned int clid() const
Get client ID.
Definition: message.cpp:276
void * payload() const
Get payload buffer.
Definition: message.cpp:312
size_t payload_size() const
Get payload size.
Definition: message.cpp:303
static void log_warn(const char *component, const char *format,...)
Log warning message.
Definition: liblogger.cpp:156
virtual void unlock() const
Unlock list.
Definition: lock_list.h:138
void push_back_locked(const Type &x)
Push element to list at back with lock protection.
Definition: lock_list.h:145
virtual void lock() const
Lock list.
Definition: lock_list.h:124
void clear()
Clear the queue.
Definition: lock_queue.h:153
void pop_locked()
Pop element from queue with lock protection.
Definition: lock_queue.h:144
void push_locked(const Type &x)
Push element to queue with lock protection.
Definition: lock_queue.h:135
void unref()
Decrement reference count and conditionally delete this instance.
Definition: refcount.cpp:95
void ref()
Increment reference count.
Definition: refcount.cpp:67
Thread class encapsulation of pthreads.
Definition: thread.h:46
void start(bool wait=true)
Call this method to start the thread.
Definition: thread.cpp:499
void join()
Join the thread.
Definition: thread.cpp:597
void wakeup()
Wake up thread.
Definition: thread.cpp:995
void cancel()
Cancel a thread.
Definition: thread.cpp:646
Fawkes library namespace.
Basic config descriptor.
Definition: net_messages.h:93
uint16_t num_values
Number of valus in list.
Definition: net_messages.h:98
uint16_t is_default
1 if value is a default value, 0 otherwise, only for get response
Definition: net_messages.h:95
char path[CONFIG_MSG_PATH_LENGTH]
path to config value.
Definition: net_messages.h:94
config_descriptor_t cp
value descriptor
Definition: net_messages.h:116
Get value message.
Definition: net_messages.h:103
config_descriptor_t cp
value descriptor
Definition: net_messages.h:104
Invalid value request message.
Definition: net_messages.h:109
String value header indicating the string length.
Definition: net_messages.h:127
uint16_t s_length
Length of following string.
Definition: net_messages.h:128