diff --git a/src/knx/address_table_object.cpp b/src/knxold/address_table_object.cpp similarity index 100% rename from src/knx/address_table_object.cpp rename to src/knxold/address_table_object.cpp diff --git a/src/knx/address_table_object.h b/src/knxold/address_table_object.h similarity index 100% rename from src/knx/address_table_object.h rename to src/knxold/address_table_object.h diff --git a/src/knx/aes.c b/src/knxold/aes.c similarity index 100% rename from src/knx/aes.c rename to src/knxold/aes.c diff --git a/src/knx/aes.h b/src/knxold/aes.h similarity index 100% rename from src/knx/aes.h rename to src/knxold/aes.h diff --git a/src/knx/aes.hpp b/src/knxold/aes.hpp similarity index 100% rename from src/knx/aes.hpp rename to src/knxold/aes.hpp diff --git a/src/knx/apdu.cpp b/src/knxold/apdu.cpp similarity index 100% rename from src/knx/apdu.cpp rename to src/knxold/apdu.cpp diff --git a/src/knx/apdu.h b/src/knxold/apdu.h similarity index 100% rename from src/knx/apdu.h rename to src/knxold/apdu.h diff --git a/src/knx/application_layer.cpp b/src/knxold/application_layer.cpp similarity index 100% rename from src/knx/application_layer.cpp rename to src/knxold/application_layer.cpp diff --git a/src/knx/application_layer.h b/src/knxold/application_layer.h similarity index 100% rename from src/knx/application_layer.h rename to src/knxold/application_layer.h diff --git a/src/knx/application_program_object.cpp b/src/knxold/application_program_object.cpp similarity index 100% rename from src/knx/application_program_object.cpp rename to src/knxold/application_program_object.cpp diff --git a/src/knx/application_program_object.h b/src/knxold/application_program_object.h similarity index 100% rename from src/knx/application_program_object.h rename to src/knxold/application_program_object.h diff --git a/src/knx/association_table_object.cpp b/src/knxold/association_table_object.cpp similarity index 100% rename from src/knx/association_table_object.cpp rename to src/knxold/association_table_object.cpp diff --git a/src/knx/association_table_object.h b/src/knxold/association_table_object.h similarity index 100% rename from src/knx/association_table_object.h rename to src/knxold/association_table_object.h diff --git a/src/knx/bau.cpp b/src/knxold/bau.cpp similarity index 100% rename from src/knx/bau.cpp rename to src/knxold/bau.cpp diff --git a/src/knx/bau.h b/src/knxold/bau.h similarity index 100% rename from src/knx/bau.h rename to src/knxold/bau.h diff --git a/src/knx/bau07B0.cpp b/src/knxold/bau07B0.cpp similarity index 100% rename from src/knx/bau07B0.cpp rename to src/knxold/bau07B0.cpp diff --git a/src/knx/bau07B0.h b/src/knxold/bau07B0.h similarity index 100% rename from src/knx/bau07B0.h rename to src/knxold/bau07B0.h diff --git a/src/knx/bau091A.cpp b/src/knxold/bau091A.cpp similarity index 100% rename from src/knx/bau091A.cpp rename to src/knxold/bau091A.cpp diff --git a/src/knx/bau091A.h b/src/knxold/bau091A.h similarity index 100% rename from src/knx/bau091A.h rename to src/knxold/bau091A.h diff --git a/src/knx/bau27B0.cpp b/src/knxold/bau27B0.cpp similarity index 100% rename from src/knx/bau27B0.cpp rename to src/knxold/bau27B0.cpp diff --git a/src/knx/bau27B0.h b/src/knxold/bau27B0.h similarity index 100% rename from src/knx/bau27B0.h rename to src/knxold/bau27B0.h diff --git a/src/knx/bau2920.cpp b/src/knxold/bau2920.cpp similarity index 100% rename from src/knx/bau2920.cpp rename to src/knxold/bau2920.cpp diff --git a/src/knx/bau2920.h b/src/knxold/bau2920.h similarity index 100% rename from src/knx/bau2920.h rename to src/knxold/bau2920.h diff --git a/src/knx/bau57B0.cpp b/src/knxold/bau57B0.cpp similarity index 100% rename from src/knx/bau57B0.cpp rename to src/knxold/bau57B0.cpp diff --git a/src/knx/bau57B0.h b/src/knxold/bau57B0.h similarity index 100% rename from src/knx/bau57B0.h rename to src/knxold/bau57B0.h diff --git a/src/knx/bau_systemB.cpp b/src/knxold/bau_systemB.cpp similarity index 100% rename from src/knx/bau_systemB.cpp rename to src/knxold/bau_systemB.cpp diff --git a/src/knx/bau_systemB.h b/src/knxold/bau_systemB.h similarity index 100% rename from src/knx/bau_systemB.h rename to src/knxold/bau_systemB.h diff --git a/src/knx/bau_systemB_coupler.cpp b/src/knxold/bau_systemB_coupler.cpp similarity index 100% rename from src/knx/bau_systemB_coupler.cpp rename to src/knxold/bau_systemB_coupler.cpp diff --git a/src/knx/bau_systemB_coupler.h b/src/knxold/bau_systemB_coupler.h similarity index 100% rename from src/knx/bau_systemB_coupler.h rename to src/knxold/bau_systemB_coupler.h diff --git a/src/knx/bau_systemB_device.cpp b/src/knxold/bau_systemB_device.cpp similarity index 100% rename from src/knx/bau_systemB_device.cpp rename to src/knxold/bau_systemB_device.cpp diff --git a/src/knx/bau_systemB_device.h b/src/knxold/bau_systemB_device.h similarity index 100% rename from src/knx/bau_systemB_device.h rename to src/knxold/bau_systemB_device.h diff --git a/src/knx/bits.cpp b/src/knxold/bits.cpp similarity index 100% rename from src/knx/bits.cpp rename to src/knxold/bits.cpp diff --git a/src/knx/bits.h b/src/knxold/bits.h similarity index 100% rename from src/knx/bits.h rename to src/knxold/bits.h diff --git a/src/knx/callback_property.h b/src/knxold/callback_property.h similarity index 100% rename from src/knx/callback_property.h rename to src/knxold/callback_property.h diff --git a/src/knx/cemi_frame.cpp b/src/knxold/cemi_frame.cpp similarity index 100% rename from src/knx/cemi_frame.cpp rename to src/knxold/cemi_frame.cpp diff --git a/src/knx/cemi_frame.h b/src/knxold/cemi_frame.h similarity index 100% rename from src/knx/cemi_frame.h rename to src/knxold/cemi_frame.h diff --git a/src/knx/cemi_server.cpp b/src/knxold/cemi_server.cpp similarity index 100% rename from src/knx/cemi_server.cpp rename to src/knxold/cemi_server.cpp diff --git a/src/knx/cemi_server.h b/src/knxold/cemi_server.h similarity index 100% rename from src/knx/cemi_server.h rename to src/knxold/cemi_server.h diff --git a/src/knx/cemi_server_object.cpp b/src/knxold/cemi_server_object.cpp similarity index 100% rename from src/knx/cemi_server_object.cpp rename to src/knxold/cemi_server_object.cpp diff --git a/src/knx/cemi_server_object.h b/src/knxold/cemi_server_object.h similarity index 100% rename from src/knx/cemi_server_object.h rename to src/knxold/cemi_server_object.h diff --git a/src/knx/config.h b/src/knxold/config.h similarity index 100% rename from src/knx/config.h rename to src/knxold/config.h diff --git a/src/knx/data_link_layer.cpp b/src/knxold/data_link_layer.cpp similarity index 100% rename from src/knx/data_link_layer.cpp rename to src/knxold/data_link_layer.cpp diff --git a/src/knx/data_link_layer.h b/src/knxold/data_link_layer.h similarity index 100% rename from src/knx/data_link_layer.h rename to src/knxold/data_link_layer.h diff --git a/src/knx/data_property.cpp b/src/knxold/data_property.cpp similarity index 100% rename from src/knx/data_property.cpp rename to src/knxold/data_property.cpp diff --git a/src/knx/data_property.h b/src/knxold/data_property.h similarity index 100% rename from src/knx/data_property.h rename to src/knxold/data_property.h diff --git a/src/knx/datapoint_types.cpp b/src/knxold/datapoint_types.cpp similarity index 100% rename from src/knx/datapoint_types.cpp rename to src/knxold/datapoint_types.cpp diff --git a/src/knx/datapoint_types.h b/src/knxold/datapoint_types.h similarity index 100% rename from src/knx/datapoint_types.h rename to src/knxold/datapoint_types.h diff --git a/src/knx/device_object.cpp b/src/knxold/device_object.cpp similarity index 100% rename from src/knx/device_object.cpp rename to src/knxold/device_object.cpp diff --git a/src/knx/device_object.h b/src/knxold/device_object.h similarity index 100% rename from src/knx/device_object.h rename to src/knxold/device_object.h diff --git a/src/knx/dpt.cpp b/src/knxold/dpt.cpp similarity index 100% rename from src/knx/dpt.cpp rename to src/knxold/dpt.cpp diff --git a/src/knx/dpt.h b/src/knxold/dpt.h similarity index 100% rename from src/knx/dpt.h rename to src/knxold/dpt.h diff --git a/src/knx/dptconvert.cpp b/src/knxold/dptconvert.cpp similarity index 100% rename from src/knx/dptconvert.cpp rename to src/knxold/dptconvert.cpp diff --git a/src/knx/dptconvert.h b/src/knxold/dptconvert.h similarity index 100% rename from src/knx/dptconvert.h rename to src/knxold/dptconvert.h diff --git a/src/knx/function_property.h b/src/knxold/function_property.h similarity index 100% rename from src/knx/function_property.h rename to src/knxold/function_property.h diff --git a/src/knx/group_object.cpp b/src/knxold/group_object.cpp similarity index 100% rename from src/knx/group_object.cpp rename to src/knxold/group_object.cpp diff --git a/src/knx/group_object.h b/src/knxold/group_object.h similarity index 100% rename from src/knx/group_object.h rename to src/knxold/group_object.h diff --git a/src/knx/group_object_table_object.cpp b/src/knxold/group_object_table_object.cpp similarity index 100% rename from src/knx/group_object_table_object.cpp rename to src/knxold/group_object_table_object.cpp diff --git a/src/knx/group_object_table_object.h b/src/knxold/group_object_table_object.h similarity index 100% rename from src/knx/group_object_table_object.h rename to src/knxold/group_object_table_object.h diff --git a/src/knx/interface_object.cpp b/src/knxold/interface_object.cpp similarity index 100% rename from src/knx/interface_object.cpp rename to src/knxold/interface_object.cpp diff --git a/src/knx/interface_object.h b/src/knxold/interface_object.h similarity index 100% rename from src/knx/interface_object.h rename to src/knxold/interface_object.h diff --git a/src/knx/ip_data_link_layer.cpp b/src/knxold/ip_data_link_layer.cpp similarity index 100% rename from src/knx/ip_data_link_layer.cpp rename to src/knxold/ip_data_link_layer.cpp diff --git a/src/knx/ip_data_link_layer.h b/src/knxold/ip_data_link_layer.h similarity index 100% rename from src/knx/ip_data_link_layer.h rename to src/knxold/ip_data_link_layer.h diff --git a/src/knx/ip_host_protocol_address_information.cpp b/src/knxold/ip_host_protocol_address_information.cpp similarity index 100% rename from src/knx/ip_host_protocol_address_information.cpp rename to src/knxold/ip_host_protocol_address_information.cpp diff --git a/src/knx/ip_host_protocol_address_information.h b/src/knxold/ip_host_protocol_address_information.h similarity index 100% rename from src/knx/ip_host_protocol_address_information.h rename to src/knxold/ip_host_protocol_address_information.h diff --git a/src/knx/ip_parameter_object.cpp b/src/knxold/ip_parameter_object.cpp similarity index 100% rename from src/knx/ip_parameter_object.cpp rename to src/knxold/ip_parameter_object.cpp diff --git a/src/knx/ip_parameter_object.h b/src/knxold/ip_parameter_object.h similarity index 100% rename from src/knx/ip_parameter_object.h rename to src/knxold/ip_parameter_object.h diff --git a/src/knx/knx_ip_device_information_dib.cpp b/src/knxold/knx_ip_device_information_dib.cpp similarity index 100% rename from src/knx/knx_ip_device_information_dib.cpp rename to src/knxold/knx_ip_device_information_dib.cpp diff --git a/src/knx/knx_ip_device_information_dib.h b/src/knxold/knx_ip_device_information_dib.h similarity index 100% rename from src/knx/knx_ip_device_information_dib.h rename to src/knxold/knx_ip_device_information_dib.h diff --git a/src/knx/knx_ip_dib.cpp b/src/knxold/knx_ip_dib.cpp similarity index 100% rename from src/knx/knx_ip_dib.cpp rename to src/knxold/knx_ip_dib.cpp diff --git a/src/knx/knx_ip_dib.h b/src/knxold/knx_ip_dib.h similarity index 100% rename from src/knx/knx_ip_dib.h rename to src/knxold/knx_ip_dib.h diff --git a/src/knx/knx_ip_frame.cpp b/src/knxold/knx_ip_frame.cpp similarity index 100% rename from src/knx/knx_ip_frame.cpp rename to src/knxold/knx_ip_frame.cpp diff --git a/src/knx/knx_ip_frame.h b/src/knxold/knx_ip_frame.h similarity index 100% rename from src/knx/knx_ip_frame.h rename to src/knxold/knx_ip_frame.h diff --git a/src/knx/knx_ip_routing_indication.cpp b/src/knxold/knx_ip_routing_indication.cpp similarity index 100% rename from src/knx/knx_ip_routing_indication.cpp rename to src/knxold/knx_ip_routing_indication.cpp diff --git a/src/knx/knx_ip_routing_indication.h b/src/knxold/knx_ip_routing_indication.h similarity index 100% rename from src/knx/knx_ip_routing_indication.h rename to src/knxold/knx_ip_routing_indication.h diff --git a/src/knx/knx_ip_search_request.cpp b/src/knxold/knx_ip_search_request.cpp similarity index 100% rename from src/knx/knx_ip_search_request.cpp rename to src/knxold/knx_ip_search_request.cpp diff --git a/src/knx/knx_ip_search_request.h b/src/knxold/knx_ip_search_request.h similarity index 100% rename from src/knx/knx_ip_search_request.h rename to src/knxold/knx_ip_search_request.h diff --git a/src/knx/knx_ip_search_response.cpp b/src/knxold/knx_ip_search_response.cpp similarity index 100% rename from src/knx/knx_ip_search_response.cpp rename to src/knxold/knx_ip_search_response.cpp diff --git a/src/knx/knx_ip_search_response.h b/src/knxold/knx_ip_search_response.h similarity index 100% rename from src/knx/knx_ip_search_response.h rename to src/knxold/knx_ip_search_response.h diff --git a/src/knx/knx_ip_supported_service_dib.cpp b/src/knxold/knx_ip_supported_service_dib.cpp similarity index 100% rename from src/knx/knx_ip_supported_service_dib.cpp rename to src/knxold/knx_ip_supported_service_dib.cpp diff --git a/src/knx/knx_ip_supported_service_dib.h b/src/knxold/knx_ip_supported_service_dib.h similarity index 100% rename from src/knx/knx_ip_supported_service_dib.h rename to src/knxold/knx_ip_supported_service_dib.h diff --git a/src/knx/knx_types.h b/src/knxold/knx_types.h similarity index 100% rename from src/knx/knx_types.h rename to src/knxold/knx_types.h diff --git a/src/knx/knx_value.cpp b/src/knxold/knx_value.cpp similarity index 95% rename from src/knx/knx_value.cpp rename to src/knxold/knx_value.cpp index c8d9f54..d255c88 100644 --- a/src/knx/knx_value.cpp +++ b/src/knxold/knx_value.cpp @@ -1,562 +1,562 @@ -#include "knx_value.h" - -#include -#include -#include - -KNXValue::KNXValue(bool value) -{ - _value.boolValue = value; - _type = BoolType; -} - -KNXValue::KNXValue(uint8_t value) -{ - _value.ucharValue = value; - _type = UCharType; -} - -KNXValue::KNXValue(uint16_t value) -{ - _value.ushortValue = value; - _type = UShortType; -} - -KNXValue::KNXValue(uint32_t value) -{ - _value.uintValue = value; - _type = UIntType; -} - -KNXValue::KNXValue(uint64_t value) -{ - _value.ulongValue = value; - _type = ULongType; -} - -KNXValue::KNXValue(int8_t value) -{ - _value.charValue = value; - _type = CharType; -} - -KNXValue::KNXValue(int16_t value) -{ - _value.shortValue = value; - _type = ShortType; -} - -KNXValue::KNXValue(int32_t value) -{ - _value.intValue = value; - _type = IntType; -} - -KNXValue::KNXValue(int64_t value) -{ - _value.longValue = value; - _type = LongType; -} - -KNXValue::KNXValue(double value) -{ - _value.doubleValue = value; - _type = DoubleType; -} - -KNXValue::KNXValue(const char* value) -{ - _value.stringValue = value; - _type = StringType; -} - -KNXValue::KNXValue(struct tm value) -{ - _value.timeValue = value; - _type = TimeType; -} - -KNXValue::operator bool() const -{ - return boolValue(); -} - -KNXValue::operator uint8_t() const -{ - return ucharValue(); -} - -KNXValue::operator uint16_t() const -{ - return ushortValue(); -} - -KNXValue::operator uint32_t() const -{ - return uintValue(); -} - -KNXValue::operator uint64_t() const -{ - return ulongValue(); -} - -KNXValue::operator int8_t() const -{ - return charValue(); -} - -KNXValue::operator int16_t() const -{ - return shortValue(); -} - -KNXValue::operator int32_t() const -{ - return intValue(); -} - -KNXValue::operator int64_t() const -{ - return longValue(); -} - -KNXValue::operator double() const -{ - return doubleValue(); -} - -KNXValue::operator const char*() const -{ - return stringValue(); -} - -KNXValue::operator struct tm() const -{ - return timeValue(); -} - -KNXValue& KNXValue::operator=(const bool value) -{ - _value.boolValue = value; - _type = BoolType; - return *this; -} - -KNXValue& KNXValue::operator=(const uint8_t value) -{ - _value.ucharValue = value; - _type = UCharType; - return *this; -} - -KNXValue& KNXValue::operator=(const uint16_t value) -{ - _value.ushortValue = value; - _type = UShortType; - return *this; -} - -KNXValue& KNXValue::operator=(const uint32_t value) -{ - _value.uintValue = value; - _type = UIntType; - return *this; -} - -KNXValue& KNXValue::operator=(const uint64_t value) -{ - _value.ulongValue = value; - _type = ULongType; - return *this; -} - -KNXValue& KNXValue::operator=(const int8_t value) -{ - _value.charValue = value; - _type = CharType; - return *this; -} - -KNXValue& KNXValue::operator=(const int16_t value) -{ - _value.shortValue = value; - _type = ShortType; - return *this; -} - -KNXValue& KNXValue::operator=(const int32_t value) -{ - _value.intValue = value; - _type = IntType; - return *this; -} - -KNXValue& KNXValue::operator=(const int64_t value) -{ - _value.longValue = value; - _type = LongType; - return *this; -} - -KNXValue& KNXValue::operator=(const double value) -{ - _value.doubleValue = value; - _type = DoubleType; - return *this; -} - -KNXValue& KNXValue::operator=(const char* value) -{ - _value.stringValue = value; - _type = StringType; - return *this; -} - -KNXValue& KNXValue::operator=(const struct tm value) -{ - _value.timeValue = value; - _type = TimeType; - return *this; -} - -bool KNXValue::boolValue() const -{ - switch (_type) - { - case BoolType: - return _value.boolValue; - case UCharType: - case UShortType: - case UIntType: - case ULongType: - case CharType: - case ShortType: - case IntType: - case LongType: - case TimeType: - return longValue() != 0; - case DoubleType: - return _value.doubleValue != 0; - case StringType: - return strcmp(_value.stringValue, "true") == 0 || strcmp(_value.stringValue, "True") == 0 || longValue() != 0 || doubleValue() != 0; - } - return 0; -} - -uint8_t KNXValue::ucharValue() const -{ - switch (_type) - { - case UCharType: - return _value.ucharValue; - case BoolType: - case UShortType: - case UIntType: - case ULongType: - case TimeType: - return (uint8_t)ulongValue(); - case CharType: - case ShortType: - case IntType: - case LongType: - case DoubleType: - case StringType: - return (uint8_t)longValue(); - } - return 0; -} - -uint16_t KNXValue::ushortValue() const -{ - switch (_type) - { - case UShortType: - return _value.ushortValue; - case BoolType: - case UCharType: - case UIntType: - case ULongType: - case TimeType: - return (uint16_t)ulongValue(); - case CharType: - case ShortType: - case IntType: - case LongType: - case DoubleType: - case StringType: - return (uint16_t)longValue(); - } - return 0; -} - -uint32_t KNXValue::uintValue() const -{ - switch (_type) - { - case UIntType: - return _value.uintValue; - case BoolType: - case UCharType: - case UShortType: - case ULongType: - case TimeType: - return (uint32_t)ulongValue(); - case CharType: - case ShortType: - case IntType: - case LongType: - case DoubleType: - case StringType: - return (uint32_t)longValue(); - } - return 0; -} - -uint64_t KNXValue::ulongValue() const -{ - switch (_type) - { - case ULongType: - return _value.ulongValue; - case BoolType: - return _value.boolValue ? 1 : 0; - case UCharType: - return (uint64_t)_value.ucharValue; - case UShortType: - return (uint64_t)_value.ushortValue; - case UIntType: - return (uint64_t)_value.uintValue; - case TimeType: - { - struct tm* timeptr = const_cast(&_value.timeValue); - return (uint64_t)mktime(timeptr); - } - case CharType: - return (uint64_t)_value.charValue; - case ShortType: - return (uint64_t)_value.shortValue; - case IntType: - return (uint64_t)_value.intValue; - case LongType: - return (uint64_t)_value.longValue; - case DoubleType: - return (uint64_t)_value.doubleValue; - case StringType: -#ifndef KNX_NO_STRTOx_CONVERSION - return (uint64_t)strtoul(_value.stringValue, NULL, 0); -#else - return 0; -#endif - } - return 0; -} - -int8_t KNXValue::charValue() const -{ - switch (_type) - { - case CharType: - return _value.charValue; - case BoolType: - case UCharType: - case UShortType: - case UIntType: - case ULongType: - case TimeType: - return (int8_t)ulongValue(); - case ShortType: - case IntType: - case LongType: - case DoubleType: - case StringType: - return (int8_t)longValue(); - } - return 0; -} - -int16_t KNXValue::shortValue() const -{ - switch (_type) - { - case ShortType: - return _value.shortValue; - case BoolType: - case UCharType: - case UShortType: - case UIntType: - case ULongType: - case TimeType: - return (int16_t)ulongValue(); - case CharType: - case IntType: - case LongType: - case DoubleType: - case StringType: - return (int16_t)longValue(); - } - return 0; -} - -int32_t KNXValue::intValue() const -{ - switch (_type) - { - case IntType: - return _value.shortValue; - case BoolType: - case UCharType: - case UShortType: - case UIntType: - case ULongType: - case TimeType: - return (int32_t)ulongValue(); - case CharType: - case ShortType: - case LongType: - case DoubleType: - case StringType: - return (int32_t)longValue(); - } - return 0; -} - -int64_t KNXValue::longValue() const -{ - switch (_type) - { - case LongType: - return _value.longValue; - case BoolType: - return _value.boolValue ? 1 : 0; - case UCharType: - return (int64_t)_value.ucharValue; - case UShortType: - return (int64_t)_value.ushortValue; - case UIntType: - return (int64_t)_value.uintValue; - case ULongType: - return (int64_t)_value.uintValue; - case TimeType: - return (int64_t)ulongValue(); - case CharType: - return (int64_t)_value.charValue; - case ShortType: - return (int64_t)_value.shortValue; - case IntType: - return (int64_t)_value.intValue; - case DoubleType: - return (int64_t)_value.doubleValue; - case StringType: -#ifndef KNX_NO_STRTOx_CONVERSION - return strtol(_value.stringValue, NULL, 0); -#else - return 0; -#endif - } - return 0; -} - -double KNXValue::doubleValue() const -{ - switch (_type) - { - case DoubleType: - return _value.doubleValue; - case BoolType: - return _value.boolValue ? 1 : 0; - case UCharType: - return _value.ucharValue; - case UShortType: - return _value.ushortValue; - case UIntType: - return _value.uintValue; - case ULongType: - return _value.uintValue; - case TimeType: - return ulongValue(); - case CharType: - return _value.charValue; - case ShortType: - return _value.shortValue; - case IntType: - return _value.intValue; - case LongType: - return _value.longValue; - case StringType: -#ifndef KNX_NO_STRTOx_CONVERSION - return strtod(_value.stringValue, NULL); -#else - return 0; -#endif - } - return 0; -} - -const char* KNXValue::stringValue() const -{ - switch (_type) - { - case DoubleType: - case BoolType: - case UCharType: - case UShortType: - case UIntType: - case ULongType: - case TimeType: - case CharType: - case ShortType: - case IntType: - case LongType: - return ""; // we would have to manage the memory for the string otherwise. Maybe later. - case StringType: - return _value.stringValue; - } - return 0; -} - -struct tm KNXValue::timeValue() const -{ - switch (_type) - { - case TimeType: - return _value.timeValue; - case BoolType: - case UCharType: - case UShortType: - case UIntType: - case ULongType: - case CharType: - case ShortType: - case IntType: - case LongType: - case DoubleType: - case StringType: - { - time_t timeVal = ulongValue(); - struct tm timeStruct; - gmtime_r(&timeVal, &timeStruct); - return timeStruct; - } - } - struct tm tmp = {0}; - return tmp; -} - -KNXValue::KNXValue(float value) -{ - _value.doubleValue = value; - _type = DoubleType; -} - -KNXValue& KNXValue::operator=(const float value) -{ - _value.doubleValue = value; - _type = DoubleType; - return *this; -} - -KNXValue::operator float() const -{ - return doubleValue(); +#include "knx_value.h" + +#include +#include +#include + +KNXValue::KNXValue(bool value) +{ + _value.boolValue = value; + _type = BoolType; +} + +KNXValue::KNXValue(uint8_t value) +{ + _value.ucharValue = value; + _type = UCharType; +} + +KNXValue::KNXValue(uint16_t value) +{ + _value.ushortValue = value; + _type = UShortType; +} + +KNXValue::KNXValue(uint32_t value) +{ + _value.uintValue = value; + _type = UIntType; +} + +KNXValue::KNXValue(uint64_t value) +{ + _value.ulongValue = value; + _type = ULongType; +} + +KNXValue::KNXValue(int8_t value) +{ + _value.charValue = value; + _type = CharType; +} + +KNXValue::KNXValue(int16_t value) +{ + _value.shortValue = value; + _type = ShortType; +} + +KNXValue::KNXValue(int32_t value) +{ + _value.intValue = value; + _type = IntType; +} + +KNXValue::KNXValue(int64_t value) +{ + _value.longValue = value; + _type = LongType; +} + +KNXValue::KNXValue(double value) +{ + _value.doubleValue = value; + _type = DoubleType; +} + +KNXValue::KNXValue(const char* value) +{ + _value.stringValue = value; + _type = StringType; +} + +KNXValue::KNXValue(struct tm value) +{ + _value.timeValue = value; + _type = TimeType; +} + +KNXValue::operator bool() const +{ + return boolValue(); +} + +KNXValue::operator uint8_t() const +{ + return ucharValue(); +} + +KNXValue::operator uint16_t() const +{ + return ushortValue(); +} + +KNXValue::operator uint32_t() const +{ + return uintValue(); +} + +KNXValue::operator uint64_t() const +{ + return ulongValue(); +} + +KNXValue::operator int8_t() const +{ + return charValue(); +} + +KNXValue::operator int16_t() const +{ + return shortValue(); +} + +KNXValue::operator int32_t() const +{ + return intValue(); +} + +KNXValue::operator int64_t() const +{ + return longValue(); +} + +KNXValue::operator double() const +{ + return doubleValue(); +} + +KNXValue::operator const char*() const +{ + return stringValue(); +} + +KNXValue::operator struct tm() const +{ + return timeValue(); +} + +KNXValue& KNXValue::operator=(const bool value) +{ + _value.boolValue = value; + _type = BoolType; + return *this; +} + +KNXValue& KNXValue::operator=(const uint8_t value) +{ + _value.ucharValue = value; + _type = UCharType; + return *this; +} + +KNXValue& KNXValue::operator=(const uint16_t value) +{ + _value.ushortValue = value; + _type = UShortType; + return *this; +} + +KNXValue& KNXValue::operator=(const uint32_t value) +{ + _value.uintValue = value; + _type = UIntType; + return *this; +} + +KNXValue& KNXValue::operator=(const uint64_t value) +{ + _value.ulongValue = value; + _type = ULongType; + return *this; +} + +KNXValue& KNXValue::operator=(const int8_t value) +{ + _value.charValue = value; + _type = CharType; + return *this; +} + +KNXValue& KNXValue::operator=(const int16_t value) +{ + _value.shortValue = value; + _type = ShortType; + return *this; +} + +KNXValue& KNXValue::operator=(const int32_t value) +{ + _value.intValue = value; + _type = IntType; + return *this; +} + +KNXValue& KNXValue::operator=(const int64_t value) +{ + _value.longValue = value; + _type = LongType; + return *this; +} + +KNXValue& KNXValue::operator=(const double value) +{ + _value.doubleValue = value; + _type = DoubleType; + return *this; +} + +KNXValue& KNXValue::operator=(const char* value) +{ + _value.stringValue = value; + _type = StringType; + return *this; +} + +KNXValue& KNXValue::operator=(const struct tm value) +{ + _value.timeValue = value; + _type = TimeType; + return *this; +} + +bool KNXValue::boolValue() const +{ + switch (_type) + { + case BoolType: + return _value.boolValue; + case UCharType: + case UShortType: + case UIntType: + case ULongType: + case CharType: + case ShortType: + case IntType: + case LongType: + case TimeType: + return longValue() != 0; + case DoubleType: + return _value.doubleValue != 0; + case StringType: + return strcmp(_value.stringValue, "true") == 0 || strcmp(_value.stringValue, "True") == 0 || longValue() != 0 || doubleValue() != 0; + } + return 0; +} + +uint8_t KNXValue::ucharValue() const +{ + switch (_type) + { + case UCharType: + return _value.ucharValue; + case BoolType: + case UShortType: + case UIntType: + case ULongType: + case TimeType: + return (uint8_t)ulongValue(); + case CharType: + case ShortType: + case IntType: + case LongType: + case DoubleType: + case StringType: + return (uint8_t)longValue(); + } + return 0; +} + +uint16_t KNXValue::ushortValue() const +{ + switch (_type) + { + case UShortType: + return _value.ushortValue; + case BoolType: + case UCharType: + case UIntType: + case ULongType: + case TimeType: + return (uint16_t)ulongValue(); + case CharType: + case ShortType: + case IntType: + case LongType: + case DoubleType: + case StringType: + return (uint16_t)longValue(); + } + return 0; +} + +uint32_t KNXValue::uintValue() const +{ + switch (_type) + { + case UIntType: + return _value.uintValue; + case BoolType: + case UCharType: + case UShortType: + case ULongType: + case TimeType: + return (uint32_t)ulongValue(); + case CharType: + case ShortType: + case IntType: + case LongType: + case DoubleType: + case StringType: + return (uint32_t)longValue(); + } + return 0; +} + +uint64_t KNXValue::ulongValue() const +{ + switch (_type) + { + case ULongType: + return _value.ulongValue; + case BoolType: + return _value.boolValue ? 1 : 0; + case UCharType: + return (uint64_t)_value.ucharValue; + case UShortType: + return (uint64_t)_value.ushortValue; + case UIntType: + return (uint64_t)_value.uintValue; + case TimeType: + { + struct tm* timeptr = const_cast(&_value.timeValue); + return (uint64_t)mktime(timeptr); + } + case CharType: + return (uint64_t)_value.charValue; + case ShortType: + return (uint64_t)_value.shortValue; + case IntType: + return (uint64_t)_value.intValue; + case LongType: + return (uint64_t)_value.longValue; + case DoubleType: + return (uint64_t)_value.doubleValue; + case StringType: +#ifndef KNX_NO_STRTOx_CONVERSION + return (uint64_t)strtoul(_value.stringValue, NULL, 0); +#else + return 0; +#endif + } + return 0; +} + +int8_t KNXValue::charValue() const +{ + switch (_type) + { + case CharType: + return _value.charValue; + case BoolType: + case UCharType: + case UShortType: + case UIntType: + case ULongType: + case TimeType: + return (int8_t)ulongValue(); + case ShortType: + case IntType: + case LongType: + case DoubleType: + case StringType: + return (int8_t)longValue(); + } + return 0; +} + +int16_t KNXValue::shortValue() const +{ + switch (_type) + { + case ShortType: + return _value.shortValue; + case BoolType: + case UCharType: + case UShortType: + case UIntType: + case ULongType: + case TimeType: + return (int16_t)ulongValue(); + case CharType: + case IntType: + case LongType: + case DoubleType: + case StringType: + return (int16_t)longValue(); + } + return 0; +} + +int32_t KNXValue::intValue() const +{ + switch (_type) + { + case IntType: + return _value.shortValue; + case BoolType: + case UCharType: + case UShortType: + case UIntType: + case ULongType: + case TimeType: + return (int32_t)ulongValue(); + case CharType: + case ShortType: + case LongType: + case DoubleType: + case StringType: + return (int32_t)longValue(); + } + return 0; +} + +int64_t KNXValue::longValue() const +{ + switch (_type) + { + case LongType: + return _value.longValue; + case BoolType: + return _value.boolValue ? 1 : 0; + case UCharType: + return (int64_t)_value.ucharValue; + case UShortType: + return (int64_t)_value.ushortValue; + case UIntType: + return (int64_t)_value.uintValue; + case ULongType: + return (int64_t)_value.uintValue; + case TimeType: + return (int64_t)ulongValue(); + case CharType: + return (int64_t)_value.charValue; + case ShortType: + return (int64_t)_value.shortValue; + case IntType: + return (int64_t)_value.intValue; + case DoubleType: + return (int64_t)_value.doubleValue; + case StringType: +#ifndef KNX_NO_STRTOx_CONVERSION + return strtol(_value.stringValue, NULL, 0); +#else + return 0; +#endif + } + return 0; +} + +double KNXValue::doubleValue() const +{ + switch (_type) + { + case DoubleType: + return _value.doubleValue; + case BoolType: + return _value.boolValue ? 1 : 0; + case UCharType: + return _value.ucharValue; + case UShortType: + return _value.ushortValue; + case UIntType: + return _value.uintValue; + case ULongType: + return _value.uintValue; + case TimeType: + return ulongValue(); + case CharType: + return _value.charValue; + case ShortType: + return _value.shortValue; + case IntType: + return _value.intValue; + case LongType: + return _value.longValue; + case StringType: +#ifndef KNX_NO_STRTOx_CONVERSION + return strtod(_value.stringValue, NULL); +#else + return 0; +#endif + } + return 0; +} + +const char* KNXValue::stringValue() const +{ + switch (_type) + { + case DoubleType: + case BoolType: + case UCharType: + case UShortType: + case UIntType: + case ULongType: + case TimeType: + case CharType: + case ShortType: + case IntType: + case LongType: + return ""; // we would have to manage the memory for the string otherwise. Maybe later. + case StringType: + return _value.stringValue; + } + return 0; +} + +struct tm KNXValue::timeValue() const +{ + switch (_type) + { + case TimeType: + return _value.timeValue; + case BoolType: + case UCharType: + case UShortType: + case UIntType: + case ULongType: + case CharType: + case ShortType: + case IntType: + case LongType: + case DoubleType: + case StringType: + { + time_t timeVal = ulongValue(); + struct tm timeStruct; + gmtime_r(&timeVal, &timeStruct); + return timeStruct; + } + } + struct tm tmp = {0}; + return tmp; +} + +KNXValue::KNXValue(float value) +{ + _value.doubleValue = value; + _type = DoubleType; +} + +KNXValue& KNXValue::operator=(const float value) +{ + _value.doubleValue = value; + _type = DoubleType; + return *this; +} + +KNXValue::operator float() const +{ + return doubleValue(); } \ No newline at end of file diff --git a/src/knx/knx_value.h b/src/knxold/knx_value.h similarity index 100% rename from src/knx/knx_value.h rename to src/knxold/knx_value.h diff --git a/src/knx/memory.cpp b/src/knxold/memory.cpp similarity index 100% rename from src/knx/memory.cpp rename to src/knxold/memory.cpp diff --git a/src/knx/memory.h b/src/knxold/memory.h similarity index 100% rename from src/knx/memory.h rename to src/knxold/memory.h diff --git a/src/knx/network_layer.cpp b/src/knxold/network_layer.cpp similarity index 100% rename from src/knx/network_layer.cpp rename to src/knxold/network_layer.cpp diff --git a/src/knx/network_layer.h b/src/knxold/network_layer.h similarity index 100% rename from src/knx/network_layer.h rename to src/knxold/network_layer.h diff --git a/src/knx/network_layer_coupler.cpp b/src/knxold/network_layer_coupler.cpp similarity index 100% rename from src/knx/network_layer_coupler.cpp rename to src/knxold/network_layer_coupler.cpp diff --git a/src/knx/network_layer_coupler.h b/src/knxold/network_layer_coupler.h similarity index 100% rename from src/knx/network_layer_coupler.h rename to src/knxold/network_layer_coupler.h diff --git a/src/knx/network_layer_device.cpp b/src/knxold/network_layer_device.cpp similarity index 100% rename from src/knx/network_layer_device.cpp rename to src/knxold/network_layer_device.cpp diff --git a/src/knx/network_layer_device.h b/src/knxold/network_layer_device.h similarity index 100% rename from src/knx/network_layer_device.h rename to src/knxold/network_layer_device.h diff --git a/src/knx/network_layer_entity.cpp b/src/knxold/network_layer_entity.cpp similarity index 100% rename from src/knx/network_layer_entity.cpp rename to src/knxold/network_layer_entity.cpp diff --git a/src/knx/network_layer_entity.h b/src/knxold/network_layer_entity.h similarity index 100% rename from src/knx/network_layer_entity.h rename to src/knxold/network_layer_entity.h diff --git a/src/knx/npdu.cpp b/src/knxold/npdu.cpp similarity index 100% rename from src/knx/npdu.cpp rename to src/knxold/npdu.cpp diff --git a/src/knx/npdu.h b/src/knxold/npdu.h similarity index 100% rename from src/knx/npdu.h rename to src/knxold/npdu.h diff --git a/src/knx/platform.cpp b/src/knxold/platform.cpp similarity index 100% rename from src/knx/platform.cpp rename to src/knxold/platform.cpp diff --git a/src/knx/platform.h b/src/knxold/platform.h similarity index 100% rename from src/knx/platform.h rename to src/knxold/platform.h diff --git a/src/knx/property.cpp b/src/knxold/property.cpp similarity index 100% rename from src/knx/property.cpp rename to src/knxold/property.cpp diff --git a/src/knx/property.h b/src/knxold/property.h similarity index 100% rename from src/knx/property.h rename to src/knxold/property.h diff --git a/src/knx/rf_data_link_layer.cpp b/src/knxold/rf_data_link_layer.cpp similarity index 100% rename from src/knx/rf_data_link_layer.cpp rename to src/knxold/rf_data_link_layer.cpp diff --git a/src/knx/rf_data_link_layer.h b/src/knxold/rf_data_link_layer.h similarity index 100% rename from src/knx/rf_data_link_layer.h rename to src/knxold/rf_data_link_layer.h diff --git a/src/knx/rf_medium_object.cpp b/src/knxold/rf_medium_object.cpp similarity index 100% rename from src/knx/rf_medium_object.cpp rename to src/knxold/rf_medium_object.cpp diff --git a/src/knx/rf_medium_object.h b/src/knxold/rf_medium_object.h similarity index 100% rename from src/knx/rf_medium_object.h rename to src/knxold/rf_medium_object.h diff --git a/src/knx/rf_physical_layer.h b/src/knxold/rf_physical_layer.h similarity index 100% rename from src/knx/rf_physical_layer.h rename to src/knxold/rf_physical_layer.h diff --git a/src/knx/rf_physical_layer_cc1101.cpp b/src/knxold/rf_physical_layer_cc1101.cpp similarity index 100% rename from src/knx/rf_physical_layer_cc1101.cpp rename to src/knxold/rf_physical_layer_cc1101.cpp diff --git a/src/knx/rf_physical_layer_cc1101.h b/src/knxold/rf_physical_layer_cc1101.h similarity index 100% rename from src/knx/rf_physical_layer_cc1101.h rename to src/knxold/rf_physical_layer_cc1101.h diff --git a/src/knx/rf_physical_layer_cc1310.cpp b/src/knxold/rf_physical_layer_cc1310.cpp similarity index 100% rename from src/knx/rf_physical_layer_cc1310.cpp rename to src/knxold/rf_physical_layer_cc1310.cpp diff --git a/src/knx/rf_physical_layer_cc1310.h b/src/knxold/rf_physical_layer_cc1310.h similarity index 100% rename from src/knx/rf_physical_layer_cc1310.h rename to src/knxold/rf_physical_layer_cc1310.h diff --git a/src/knx/router_object.cpp b/src/knxold/router_object.cpp similarity index 100% rename from src/knx/router_object.cpp rename to src/knxold/router_object.cpp diff --git a/src/knx/router_object.h b/src/knxold/router_object.h similarity index 100% rename from src/knx/router_object.h rename to src/knxold/router_object.h diff --git a/src/knx/save_restore.h b/src/knxold/save_restore.h similarity index 100% rename from src/knx/save_restore.h rename to src/knxold/save_restore.h diff --git a/src/knx/secure_application_layer.cpp b/src/knxold/secure_application_layer.cpp similarity index 100% rename from src/knx/secure_application_layer.cpp rename to src/knxold/secure_application_layer.cpp diff --git a/src/knx/secure_application_layer.h b/src/knxold/secure_application_layer.h similarity index 100% rename from src/knx/secure_application_layer.h rename to src/knxold/secure_application_layer.h diff --git a/src/knx/security_interface_object.cpp b/src/knxold/security_interface_object.cpp similarity index 100% rename from src/knx/security_interface_object.cpp rename to src/knxold/security_interface_object.cpp diff --git a/src/knx/security_interface_object.h b/src/knxold/security_interface_object.h similarity index 100% rename from src/knx/security_interface_object.h rename to src/knxold/security_interface_object.h diff --git a/src/knx/simple_map.h b/src/knxold/simple_map.h similarity index 100% rename from src/knx/simple_map.h rename to src/knxold/simple_map.h diff --git a/src/knx/table_object.cpp b/src/knxold/table_object.cpp similarity index 100% rename from src/knx/table_object.cpp rename to src/knxold/table_object.cpp diff --git a/src/knx/table_object.h b/src/knxold/table_object.h similarity index 100% rename from src/knx/table_object.h rename to src/knxold/table_object.h diff --git a/src/knx/tpdu.cpp b/src/knxold/tpdu.cpp similarity index 100% rename from src/knx/tpdu.cpp rename to src/knxold/tpdu.cpp diff --git a/src/knx/tpdu.h b/src/knxold/tpdu.h similarity index 100% rename from src/knx/tpdu.h rename to src/knxold/tpdu.h diff --git a/src/knx/tpuart_data_link_layer.cpp b/src/knxold/tpuart_data_link_layer.cpp similarity index 100% rename from src/knx/tpuart_data_link_layer.cpp rename to src/knxold/tpuart_data_link_layer.cpp diff --git a/src/knx/tpuart_data_link_layer.h b/src/knxold/tpuart_data_link_layer.h similarity index 100% rename from src/knx/tpuart_data_link_layer.h rename to src/knxold/tpuart_data_link_layer.h diff --git a/src/knx/transport_layer.cpp b/src/knxold/transport_layer.cpp similarity index 100% rename from src/knx/transport_layer.cpp rename to src/knxold/transport_layer.cpp diff --git a/src/knx/transport_layer.h b/src/knxold/transport_layer.h similarity index 100% rename from src/knx/transport_layer.h rename to src/knxold/transport_layer.h diff --git a/src/knx/usb_tunnel_interface.cpp b/src/knxold/usb_tunnel_interface.cpp similarity index 100% rename from src/knx/usb_tunnel_interface.cpp rename to src/knxold/usb_tunnel_interface.cpp diff --git a/src/knx/usb_tunnel_interface.h b/src/knxold/usb_tunnel_interface.h similarity index 100% rename from src/knx/usb_tunnel_interface.h rename to src/knxold/usb_tunnel_interface.h