Skip to content
Nico Weichbrodt edited this page Mar 3, 2018 · 6 revisions

Types

callback_fptr_t

typedef void (*callback_fptr_t)(message_t const &msg, void *arg);

This type spedifies the signature of callback functions. A callback function shall return void and take two arguments:

  • message_t const &msg A reference to a message_t.
  • void *arg If during registration with register_callback the optional arg parameter was set, then this value will be passed into the function.

message_t

typedef struct __message
{
  knx_command_type_t ct;
  address_t received_on;
  uint8_t data_len;
  uint8_t *data;
} message_t;

A struct representing a received KNX telegram. A reference to an instance of this type is passed to callbacks.

Members:

  • ct The command type of the message, see knx_command_type_t.
  • received_on The group address this message was received on.
  • data_len The length of the data array.
  • data A uint8_t array containing the message payload.

knx_command_type_t

typedef enum __knx_command_type
{
  KNX_CT_READ                     = 0x00,
  KNX_CT_ANSWER                   = 0x01,
  KNX_CT_WRITE                    = 0x02,
  // ...
} knx_command_type_t;

KNX message command types. The most common are shown above.

feedback_action_fptr_t

typedef void (*feedback_action_fptr_t)(void *arg);

enable_condition_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.

option_entry_t

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 option_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);
Clone this wiki locally