-
Notifications
You must be signed in to change notification settings - Fork 49
Types
typedef void (*callback_fptr_t)(message_t const &msg, void *arg);
typedef struct __message
{
knx_command_type_t ct;
address_t received_on;
uint8_t data_len;
uint8_t *data;
} message_t;
typedef bool (*enable_condition_t)(void);
Some functions have an optional argument of type enable_condition_t
, normally called cond
.
This argument can point to a function with signature bool (*)()
to control if
- the callback shall be enabled.
- the config option shall be enabled.
- the feedback value shall be shown.
Essentially, everytime the web UI is rendered, the library checks if a enable condition function has been set and, if true, calls the function.
If the function returns true
, the callback/config option/feedback is shown. If it returns false
, it is hidden.
In the case of callbacks, the condition is also checked when receiving a KNX telegram and, if disabled, will not call the callback.
typedef struct __option_entry
{
char *name;
uint8_t value;
} option_entry_t;
It is possible to register a config option of type option
that presents the user a set of predefined option values to choose from instead of the free text fields presented normally.
config_register_options
expects a pointer to an array of type options_entry_t
that describes the available options.
All items have a name and a integer representation.
Please notice, how the function does not need to know the length of the array. It expects the last item in the array to have name
pointing to nullptr
(or NULL
or 0
).
An example:
option_entry_t my_options[] = {
{"My first option", 1},
{"My second option", 2},
{"My third option", 42}, // The values can be arbitrary and don't need to be consecutive. They only need to be unique in this array.
{"My fourth option", 21},
{nullptr, 0} // This item represents the end of the array.
}
Registering is then done so:
knx.config_register_options("My Options", my_options, 1);