#include <stdio.h>
#include <stdlib.h>
#define ERROR_MESSAGE_LEN (128)
#define ADDR_DPT_1 (0x0901)
#define ADDR_DPT_2 (0x090A)
#define ADDR_DPT_3 ((ADDR_DPT_2) + 1)
#define ADDR_DPT_4 ((ADDR_DPT_3) + 1)
#define ADDR_DPT_5 ((ADDR_DPT_4) + 1)
#define ADDR_DPT_6 ((ADDR_DPT_5) + 1)
#define ADDR_DPT_7 ((ADDR_DPT_6) + 1)
#define ADDR_DPT_8 ((ADDR_DPT_7) + 1)
#define ADDR_DPT_9 ((ADDR_DPT_8) + 1)
#define ADDR_DPT_10_LOCAL ((ADDR_DPT_9) + 1)
#define ADDR_DPT_10_UTC ((ADDR_DPT_10_LOCAL) + 1)
#define ADDR_DPT_10 ((ADDR_DPT_10_UTC) + 1)
#define ADDR_DPT_11_LOCAL ((ADDR_DPT_10) + 1)
#define ADDR_DPT_11_UTC ((ADDR_DPT_11_LOCAL) + 1)
#define ADDR_DPT_11 ((ADDR_DPT_11_UTC) + 1)
#define ADDR_DPT_12 ((ADDR_DPT_11) + 1)
#define ADDR_DPT_13 ((ADDR_DPT_12) + 1)
#define ADDR_DPT_14 ((ADDR_DPT_13) + 1)
#define ADDR_DPT_15 ((ADDR_DPT_14) + 1)
#define ADDR_DPT_16 ((ADDR_DPT_15) + 1)
static void send_telegrams(
int32_t ap);
static void on_telegram_callback(
const uint8_t* telegram,
uint32_t telegram_len,
void* user_data);
static void error_callback(
error_t e,
void* user_data);
int main(int argc, char* argv[])
{
{
while (1)
{
;
}
}
{
send_telegrams(ap);
getchar();
}
return 0;
}
{
}
void on_telegram_callback(
const uint8_t* telegram,
uint32_t telegram_len,
void* user_data)
{
{
switch (address)
{
case ADDR_DPT_1:
{
}
break;
case ADDR_DPT_2:
{
}
break;
case ADDR_DPT_3:
{
}
break;
case ADDR_DPT_4:
{
}
break;
case ADDR_DPT_5:
{
}
break;
case ADDR_DPT_6:
{
}
break;
case ADDR_DPT_7:
{
}
break;
case ADDR_DPT_8:
{
}
break;
case ADDR_DPT_9:
{
}
break;
case ADDR_DPT_10_LOCAL:
case ADDR_DPT_10_UTC:
case ADDR_DPT_10:
{
}
break;
case ADDR_DPT_11_LOCAL:
case ADDR_DPT_11_UTC:
case ADDR_DPT_11:
{
}
break;
case ADDR_DPT_12:
{
}
break;
case ADDR_DPT_13:
{
}
break;
case ADDR_DPT_14:
{
}
break;
case ADDR_DPT_15:
{
accessCode, error, permission, direction, encrypted, index);
}
break;
case ADDR_DPT_16:
{
}
break;
default:
}
}
}
void error_callback(
error_t e,
void* user_data)
{
{
static char error_message[ERROR_MESSAGE_LEN];
}
}
kdriveExpress_API error_t kdrive_ap_get_group_data(const uint8_t telegram[], uint32_t telegram_len, uint8_t *data, uint32_t *data_len)
Extracts the Group Value data from the KNX telegram.
kdriveExpress_API error_t kdrive_ap_group_write(int32_t ap, uint16_t address, const uint8_t *value, uint32_t bits)
Sends a GroupValue_Write Telegram The length is specified in bits to enable values less than one byte...
kdriveExpress_API uint32_t kdrive_ap_enum_usb(int32_t ap)
Scan for all KNX USB Interface devices.
kdriveExpress_API bool_t kdrive_ap_is_group_write(const uint8_t telegram[], uint32_t telegram_len)
Determines if the specified telegram is a GroupValue_Write telegram.
kdriveExpress_API bool_t kdrive_ap_release(int32_t ap)
Releases the AccessPort interface.
kdriveExpress_API int32_t kdrive_ap_create(void)
Creates an internal AccessPort interface This should be the first function called when working with t...
kdriveExpress_API error_t kdrive_ap_close(int32_t ap)
Closes the access port If the access port is not open nothing happens.
kdriveExpress_API error_t kdrive_ap_open_usb(int32_t ap, uint32_t iface_index)
Opens a connection to a KNX USB Interface device iface_index should be in the range 0....
kdriveExpress_API error_t kdrive_ap_get_dest(const uint8_t telegram[], uint32_t telegram_len, uint16_t *address)
Extracts the Destination Address from the Telegram.
kdriveExpress_API error_t kdrive_ap_register_telegram_callback(int32_t ap, kdrive_ap_telegram_callback c, void *user_data, uint32_t *key)
Registers a callback function.
kdriveExpress_API error_t kdrive_dpt_decode_dpt9(const uint8_t *data, uint32_t length, float32_t *value)
Gets DPT-9: 2 byte float value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt11(const uint8_t *data, uint32_t length, int32_t *year, int32_t *month, int32_t *day)
Gets DPT-11: date in KNX format NOTE: The year is in KNX DPT11 format: 0..99; >=90 : 20th century; <9...
kdriveExpress_API error_t kdrive_dpt_decode_dpt14(const uint8_t *data, uint32_t length, float32_t *value)
Gets DPT-14: 4 byte float value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt2(const uint8_t *data, uint32_t length, bool_t *control, bool_t *value)
Gets DPT-2: 1 bit controlled.
kdriveExpress_API error_t kdrive_dpt_encode_dpt1(uint8_t *data, uint32_t *length, bool_t value)
Sets DPT-1 (1 bit)
kdriveExpress_API error_t kdrive_dpt_decode_dpt4(const uint8_t *data, uint32_t length, uint8_t *character)
Gets DPT-4: Character.
kdriveExpress_API error_t kdrive_dpt_encode_dpt7(uint8_t *data, uint32_t *length, uint16_t value)
Sets DPT-7: 2 byte unsigned value.
kdriveExpress_API error_t kdrive_dpt_encode_dpt3(uint8_t *data, uint32_t *length, bool_t control, uint8_t value)
Sets DPT-3: 3 bit controlled.
kdriveExpress_API error_t kdrive_dpt_encode_dpt2(uint8_t *data, uint32_t *length, bool_t control, bool_t value)
Sets DPT-2: 1 bit controlled.
kdriveExpress_API error_t kdrive_dpt_decode_dpt6(const uint8_t *data, uint32_t length, int8_t *value)
Gets DPT-6: 8 bit signed value.
kdriveExpress_API error_t kdrive_dpt_encode_dpt11_local(uint8_t *data, uint32_t *length)
Sets DPT-11: current local date.
kdriveExpress_API error_t kdrive_dpt_encode_dpt16(uint8_t *data, uint32_t *length, const char value[KDRIVE_DPT16_LENGTH+1])
Sets DPT-16: Character string.
kdriveExpress_API error_t kdrive_dpt_encode_dpt10_local(uint8_t *data, uint32_t *length)
Sets DPT-10: local time.
kdriveExpress_API error_t kdrive_dpt_encode_dpt5(uint8_t *data, uint32_t *length, uint8_t value)
Sets DPT-5: 8 bit unsigned value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt16(const uint8_t *data, uint32_t length, char value[KDRIVE_DPT16_LENGTH+1])
Gets DPT-16: Character string The out value string is null terminated.
kdriveExpress_API error_t kdrive_dpt_encode_dpt4(uint8_t *data, uint32_t *length, uint8_t character)
Sets DPT-4: Character.
kdriveExpress_API error_t kdrive_dpt_encode_dpt14(uint8_t *data, uint32_t *length, float32_t value)
Sets DPT-14: 4 byte float value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt8(const uint8_t *data, uint32_t length, int16_t *value)
Gets DPT-8: 2 byte signed value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt15(const uint8_t *data, uint32_t length, int32_t *accessCode, bool_t *error, bool_t *permission, bool_t *direction, bool_t *encrypted, int32_t *index)
Gets DPT-15: Entrance access.
kdriveExpress_API error_t kdrive_dpt_encode_dpt13(uint8_t *data, uint32_t *length, int32_t value)
Sets DPT-13: 4 byte signed value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt1(const uint8_t *data, uint32_t length, bool_t *value)
Gets DPT-1 (1 bit)
kdriveExpress_API error_t kdrive_dpt_encode_dpt6(uint8_t *data, uint32_t *length, int8_t value)
Sets DPT-6: 8 bit signed value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt13(const uint8_t *data, uint32_t length, int32_t *value)
Gets DPT-13: 4 byte signed value.
kdriveExpress_API error_t kdrive_dpt_encode_dpt15(uint8_t *data, uint32_t *length, int32_t accessCode, bool_t error, bool_t permission, bool_t direction, bool_t encrypted, int32_t index)
Sets DPT-15: Entrance access.
kdriveExpress_API error_t kdrive_dpt_decode_dpt7(const uint8_t *data, uint32_t length, uint16_t *value)
Gets DPT-7: 2 byte unsigned value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt10(const uint8_t *data, uint32_t length, int32_t *day, int32_t *hour, int32_t *minute, int32_t *second)
Gets DPT-10: time.
kdriveExpress_API error_t kdrive_dpt_decode_dpt3(const uint8_t *data, uint32_t length, bool_t *control, uint8_t *value)
Gets DPT-3: 3 bit controlled.
kdriveExpress_API error_t kdrive_dpt_encode_dpt9(uint8_t *data, uint32_t *length, float32_t value)
Sets DPT-9: 2 byte float value.
kdriveExpress_API error_t kdrive_dpt_encode_dpt11_utc(uint8_t *data, uint32_t *length)
Sets DPT-11: current UTC date.
kdriveExpress_API error_t kdrive_dpt_decode_dpt12(const uint8_t *data, uint32_t length, uint32_t *value)
Gets DPT-12: 4 byte unsigned value.
kdriveExpress_API error_t kdrive_dpt_encode_dpt12(uint8_t *data, uint32_t *length, uint32_t value)
Sets DPT-12: 4 byte unsigned value.
kdriveExpress_API error_t kdrive_dpt_decode_dpt5(const uint8_t *data, uint32_t length, uint8_t *value)
Gets DPT-5: 8 bit unsigned value.
kdriveExpress_API error_t kdrive_dpt_encode_dpt11_yyyy(uint8_t *data, uint32_t *length, int32_t year, int32_t month, int32_t day)
Sets DPT-11: date in "normal" format.
kdriveExpress_API error_t kdrive_dpt_encode_dpt10_utc(uint8_t *data, uint32_t *length)
Sets DPT-10: UTC time.
kdriveExpress_API error_t kdrive_dpt_encode_dpt10(uint8_t *data, uint32_t *length, int32_t day, int32_t hour, int32_t minute, int32_t second)
Sets DPT-10: time.
kdriveExpress_API error_t kdrive_dpt_encode_dpt8(uint8_t *data, uint32_t *length, int16_t value)
Sets DPT-8: 2 byte signed value.
kdriveExpress_API void kdrive_logger(uint8_t level, const char *message)
Writes to the kdrive express logger.
kdriveExpress_API void kdrive_logger_dump(uint8_t level, const char *message, const void *buffer, uint32_t buffer_len)
Logs the given message, followed by the data in buffer.
kdriveExpress_API void kdrive_logger_console(void)
Sets the logger to write to the console.
kdriveExpress_API void kdrive_logger_ex(uint8_t level, const char *fmt,...)
Writes to the kdrive express logger.
kdriveExpress_API void kdrive_logger_set_level(uint8_t level)
Sets the root logger level This is once of:
unsigned short uint16_t
16 bit unsigned char
Definition: kdrive_express_config.h:31
bool bool_t
Definition: kdrive_express_config.h:58
int int32_t
32 bit signed int
Definition: kdrive_express_config.h:35
unsigned int uint32_t
32 bit unsigned char
Definition: kdrive_express_config.h:32
float float32_t
32 bit single precision float
Definition: kdrive_express_config.h:36
int32_t error_t
Definition: kdrive_express_config.h:47
short int16_t
16 bit signed int
Definition: kdrive_express_config.h:34
unsigned char uint8_t
8 bit unsigned char
Definition: kdrive_express_config.h:30
signed char int8_t
8 bit signed char
Definition: kdrive_express_config.h:33
#define KDRIVE_SN_LEN
The Length of a KNX Serial Number.
Definition: kdrive_express_defs.h:34
#define KDRIVE_INVALID_DESCRIPTOR
Indicates an invalid descriptor.
Definition: kdrive_express_defs.h:39
#define KDRIVE_MAX_GROUP_VALUE_LEN
The Maximum Length of a Datapoint Value in a GroupValue Telegram.
Definition: kdrive_express_defs.h:33
#define KDRIVE_DPT16_LENGTH
The length of a KNX character string for DPT-16 is 112 bits or 14 bytes.
Definition: kdrive_express_defs.h:40
kdriveExpress_API void kdrive_register_error_callback(kdrive_error_callback c, void *user_data)
Registers the error callback function.
#define KDRIVE_TIMEOUT_ERROR
Timeout.
Definition: kdrive_express_error.h:26
#define KDRIVE_ERROR_NONE
No Error, Everything OK.
Definition: kdrive_express_error.h:22
kdriveExpress_API void kdrive_get_error_message(error_t e, char *str, uint32_t str_len)
Gets the error message.
#define KDRIVE_LOGGER_FATAL
A fatal error.
Definition: kdrive_express_logger.h:26
#define KDRIVE_LOGGER_ERROR
An error.
Definition: kdrive_express_logger.h:28
#define KDRIVE_LOGGER_INFORMATION
An informational message, usually denoting the successful completion of an operation.
Definition: kdrive_express_logger.h:31