try to build less to reduce firmware sizes

This commit is contained in:
Thomas Kunze 2024-08-17 00:46:23 +02:00
parent b59b37a462
commit 74036bad07
58 changed files with 190 additions and 29 deletions

View File

@ -187,4 +187,4 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-unknown-pragmas -
add_library(knx ${SOURCES})
target_include_directories(knx PUBLIC .)
set_property(TARGET knx PROPERTY CXX_STANDARD 11)
target_compile_definitions(knx PUBLIC -DUSE_RF -DUSE_USB -DUSE_CEMI_SERVER -DKNX_TUNNELING=1)
target_compile_definitions(knx PUBLIC -DUSE_RF -DUSE_USB -DUSE_TP -D_USE_IP -DUSE_CEMI_SERVER -DKNX_TUNNELING=1 -DUSE_DATASECURE -DALL_MASKS)

View File

@ -1,4 +1,5 @@
#include "config.h"
#if (MASK_VERSION == 0x07B0) || defined(ALL_MASKS)
#include "bau07B0.h"
#include "bits.h"
@ -174,3 +175,4 @@ TpUartDataLinkLayer* Bau07B0::getDataLinkLayer()
{
return (TpUartDataLinkLayer*)&_dlLayer;
}
#endif

View File

@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x091A || defined(ALL_MASKS)
#include "bau091A.h"
#include "bits.h"
@ -253,3 +254,4 @@ TpUartDataLinkLayer* Bau091A::getSecondaryDataLinkLayer()
{
return (TpUartDataLinkLayer*)&_dlLayerSecondary;
}
#endif

View File

@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x27B0 || defined(ALL_MASKS)
#include "bau27B0.h"
#include "bits.h"
@ -203,3 +204,4 @@ RfDataLinkLayer* Bau27B0::getDataLinkLayer()
{
return (RfDataLinkLayer*)&_dlLayer;
}
#endif

View File

@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x2920 || defined(ALL_MASKS)
#include "bau2920.h"
#include "bits.h"
@ -177,3 +178,4 @@ RfDataLinkLayer* Bau2920::getSecondaryDataLinkLayer()
{
return (RfDataLinkLayer*)&_dlLayerSecondary;
}
#endif

View File

@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x57B0 || defined(ALL_MASKS)
#include "bau57B0.h"
#include "bits.h"
@ -165,3 +166,4 @@ IpDataLinkLayer* Bau57B0::getDataLinkLayer()
{
return (IpDataLinkLayer*)&_dlLayer;
}
#endif

View File

@ -1,3 +1,4 @@
#if ((MASK_VERSION != 0x07B0) && (MASK_VERSION != 0x27B0) && (MASK_VERSION != 0x57B0)) || defined(ALL_MASKS)
#include "bau_systemB_coupler.h"
#include "bits.h"
#include <string.h>
@ -58,3 +59,4 @@ void BauSystemBCoupler::doMasterReset(EraseCode eraseCode, uint8_t channel)
_secIfObj.masterReset(eraseCode, channel);
#endif
}
#endif

View File

@ -1,3 +1,4 @@
#if (MASK_VERSION == 0x07B0) || (MASK_VERSION == 0x27B0) || (MASK_VERSION == 0x57B0) || defined(ALL_MASKS)
#include "bau_systemB_device.h"
#include "bits.h"
#include <string.h>
@ -259,3 +260,4 @@ void BauSystemBDevice::groupValueWriteIndication(uint16_t asap, Priority priorit
updateGroupObject(go, data, dataLength);
}
#endif

View File

@ -6,9 +6,15 @@
#if defined(__linux__)
#include <arpa/inet.h>
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32) || defined (DeviceFamily_CC13X0)
#define getbyte(x,n) (*(((uint8_t*)&(x))+n))
#define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) )
#define htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )
#define htons(x) ( ((x)<< 8 & 0xFF00) | \
((x)>> 8 & 0x00FF) )
#define ntohs(x) htons(x)
#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
((x)<< 8 & 0x00FF0000UL) | \
((x)>> 8 & 0x0000FF00UL) | \
((x)>>24 & 0x000000FFUL) )
#define ntohl(x) htonl(x)
#define ntohs(x) htons(x)
#define ntohl(x) htonl(x)
#endif

View File

@ -29,9 +29,7 @@ class CemiServer
CemiServer(BauSystemB& bau);
void dataLinkLayer(DataLinkLayer& layer);
#ifdef KNX_TUNNELING
void dataLinkLayerPrimary(DataLinkLayer& layer);
#endif
// from data link layer
// Only L_Data service
@ -56,9 +54,7 @@ class CemiServer
void handleMReset(CemiFrame& frame);
DataLinkLayer* _dataLinkLayer = nullptr;
#ifdef KNX_TUNNELING
DataLinkLayer* _dataLinkLayerPrimary = nullptr;
#endif
BauSystemB& _bau;
#ifdef USE_USB
UsbTunnelInterface _usbTunnelInterface;

View File

@ -27,21 +27,56 @@
//#define MASK_VERSION 0x2920
// Data Linklayer Driver Options
#if MASK_VERSION == 0x27B0 && !defined(USE_RF)
#define USE_RF
#if MASK_VERSION == 0x07B0
#ifndef USE_IP
#define USE_IP
#endif
#endif
#if MASK_VERSION == 0x2920 && !defined(USE_RF)
#if MASK_VERSION == 0x27B0
#ifndef USE_RF
#define USE_RF
#endif
#endif
#if MASK_VERSION == 0x57B0
#ifndef USE_IP
#define USE_IP
#endif
#endif
#if MASK_VERSION == 0x091A
#ifndef USE_TP
#define USE_TP
#endif
#ifndef USE_IP
#define USE_IP
#endif
#endif
#if MASK_VERSION == 0x2920
#ifndef USE_TP
#define USE_TP
#endif
#ifndef USE_RF
#define USE_RF
#endif
#endif
// cEMI options
//#define USE_USB
//#define USE_CEMI_SERVER
#if (defined(USE_USB) || defined(KNX_TUNNELING)) && !defined(USE_CEMI_SERVER)
#if defined(USE_USB) || defined(KNX_TUNNELING)
#ifndef USE_CEMI_SERVER
#define USE_CEMI_SERVER
#endif
#endif
#if defined(KNX_TUNNELING)
#ifndef USE_IP
#define USE_IP
#endif
#endif
// KNX Data Secure Options
// Define via a compiler -D flag if required

View File

@ -1,3 +1,6 @@
#include "../config.h"
#ifdef USE_IP
#include "ip_data_link_layer.h"
#include "../bits.h"
@ -1184,3 +1187,4 @@ bool IpDataLinkLayer::isSendLimitReached()
return false;
}
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "ip_host_protocol_address_information.h"
#include "../bits.h"
@ -45,3 +47,4 @@ void IpHostProtocolAddressInformation::ipPortNumber(uint16_t value)
{
pushWord(value, _data + 6);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "ip_parameter_object.h"
#include "../bits.h"
@ -137,3 +139,4 @@ uint16_t* IpParameterObject::additionalIndivualAddresses(uint8_t& numAddresses)
#endif
return (uint16_t*) propertyData(PID_ADDITIONAL_INDIVIDUAL_ADDRESSES);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_ch.h"
KnxIpCH::KnxIpCH(uint8_t* data) : _data(data)
@ -45,3 +47,4 @@ uint8_t KnxIpCH::status() const
{
return _data[3];
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_config_dib.h"
KnxIpConfigDIB::KnxIpConfigDIB(uint8_t* data, bool isCurrent) : KnxIpDIB(data)
@ -90,3 +92,4 @@ void KnxIpConfigDIB::info2(uint8_t addr)
else
_data[19] = addr;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_config_request.h"
KnxIpConfigRequest::KnxIpConfigRequest(uint8_t* data, uint16_t length)
@ -14,3 +16,4 @@ KnxIpCH& KnxIpConfigRequest::connectionHeader()
{
return _ch;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_connect_request.h"
KnxIpConnectRequest::KnxIpConnectRequest(uint8_t* data, uint16_t length)
@ -18,3 +20,4 @@ KnxIpCRI& KnxIpConnectRequest::cri()
{
return _cri;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_connect_response.h"
KnxIpConnectResponse::KnxIpConnectResponse(IpParameterObject& parameters, uint16_t address, uint16_t port, uint8_t channel, uint8_t type)
@ -40,3 +42,4 @@ KnxIpCRD& KnxIpConnectResponse::crd()
{
return _crd;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_crd.h"
KnxIpCRD::KnxIpCRD(uint8_t* data) : _data(data)
@ -38,3 +40,4 @@ void KnxIpCRD::address(uint16_t value)
_data[2] = value >> 8;
_data[3] = value & 0xFF;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_cri.h"
KnxIpCRI::KnxIpCRI(uint8_t* data) : _data(data)
@ -35,3 +37,4 @@ void KnxIpCRI::layer(uint8_t value)
{
_data[2] = value;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_description_request.h"
KnxIpDescriptionRequest::KnxIpDescriptionRequest(uint8_t* data, uint16_t length)
@ -10,3 +12,4 @@ IpHostProtocolAddressInformation& KnxIpDescriptionRequest::hpaiCtrl()
{
return _hpaiCtrl;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_description_response.h"
#define LEN_SERVICE_FAMILIES 2
@ -68,3 +70,4 @@ KnxIpSupportedServiceDIB& KnxIpDescriptionResponse::supportedServices()
{
return _supportedServices;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_device_information_dib.h"
#include "../bits.h"
@ -98,3 +100,4 @@ void KnxIpDeviceInformationDIB::friendlyName(const uint8_t* value)
{
pushByteArray(value, LEN_FRIENDLY_NAME, _data + 24);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_dib.h"
KnxIpDIB::KnxIpDIB(uint8_t* data) : _data(data)
@ -25,3 +27,4 @@ void KnxIpDIB::code(DescriptionTypeCode value)
{
_data[1] = value;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_disconnect_request.h"
KnxIpDisconnectRequest::KnxIpDisconnectRequest(uint8_t* data, uint16_t length)
@ -23,3 +25,4 @@ void KnxIpDisconnectRequest::channelId(uint8_t channelId)
{
_data[LEN_KNXIP_HEADER] = channelId;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_disconnect_response.h"
KnxIpDisconnectResponse::KnxIpDisconnectResponse(uint8_t channel, uint8_t status)
@ -8,3 +10,4 @@ KnxIpDisconnectResponse::KnxIpDisconnectResponse(uint8_t channel, uint8_t status
_data[LEN_KNXIP_HEADER] = channel;
_data[LEN_KNXIP_HEADER + 1] = status;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_extended_device_information_dib.h"
#include "../bits.h"
@ -38,3 +40,4 @@ void KnxIpExtendedDeviceInformationDIB::deviceDescriptor(uint16_t value)
{
pushWord(value, _data + 6);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_frame.h"
#include <cstring>
@ -76,3 +78,4 @@ KnxIpFrame::KnxIpFrame(uint16_t length)
protocolVersion(KnxIp1_0);
totalLength(length);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_knx_addresses_dib.h"
KnxIpKnxAddressesDIB::KnxIpKnxAddressesDIB(uint8_t* data) : KnxIpDIB(data)
@ -23,3 +25,4 @@ void KnxIpKnxAddressesDIB::additional(uint16_t addr)
currentPos += 2;
length(currentPos - _data);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_routing_indication.h"
#include <cstring>
@ -18,3 +20,4 @@ KnxIpRoutingIndication::KnxIpRoutingIndication(CemiFrame frame)
serviceTypeIdentifier(RoutingIndication);
memcpy(_data + LEN_KNXIP_HEADER, frame.data(), frame.totalLenght());
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_search_request.h"
KnxIpSearchRequest::KnxIpSearchRequest(uint8_t* data, uint16_t length)
@ -10,3 +12,4 @@ IpHostProtocolAddressInformation& KnxIpSearchRequest::hpai()
{
return _hpai;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_search_request_extended.h"
#include "../bits.h"
#include "service_families.h"
@ -64,3 +66,4 @@ bool KnxIpSearchRequestExtended::requestedDIB(uint8_t code)
return requestedDIBs[code];
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_search_response.h"
#define LEN_SERVICE_FAMILIES 2
@ -80,3 +82,4 @@ KnxIpSupportedServiceDIB& KnxIpSearchResponse::supportedServices()
{
return _supportedServices;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_search_response_extended.h"
#include "service_families.h"
@ -224,3 +226,4 @@ uint8_t* KnxIpSearchResponseExtended::DIBs()
{
return _data + LEN_KNXIP_HEADER + LEN_IPHPAI;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_state_request.h"
KnxIpStateRequest::KnxIpStateRequest(uint8_t* data, uint16_t length)
@ -13,3 +15,4 @@ uint8_t KnxIpStateRequest::channelId()
{
return _data[LEN_KNXIP_HEADER];
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_state_response.h"
#define LEN_SERVICE_FAMILIES 2
@ -22,3 +24,4 @@ KnxIpStateResponse::KnxIpStateResponse(uint8_t channelId, uint8_t errorCode)
_data[LEN_KNXIP_HEADER] = channelId;
_data[LEN_KNXIP_HEADER + 1] = errorCode;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_supported_service_dib.h"
KnxIpSupportedServiceDIB::KnxIpSupportedServiceDIB(uint8_t* data) : KnxIpDIB(data)
@ -40,3 +42,4 @@ void KnxIpSupportedServiceDIB::serviceVersion(ServiceFamily family, uint8_t ver
}
}
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_tunnel_connection.h"
KnxIpTunnelConnection::KnxIpTunnelConnection()
@ -17,3 +19,4 @@ void KnxIpTunnelConnection::Reset()
IndividualAddress = 0;
IsConfig = false;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_tunneling_ack.h"
#include <cstring>
@ -16,3 +18,4 @@ KnxIpCH& KnxIpTunnelingAck::connectionHeader()
{
return _ch;
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_tunneling_info_dib.h"
#include "service_families.h"
@ -25,3 +27,4 @@ void KnxIpTunnelingInfoDIB::tunnelingSlot(uint16_t addr, uint16_t state)
currentPos += 4;
length(currentPos - _data);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_tunneling_request.h"
#include <cstring>
@ -22,3 +24,4 @@ KnxIpCH& KnxIpTunnelingRequest::connectionHeader()
{
return _ch;
}
#endif

View File

@ -1,3 +1,4 @@
#if ((MASK_VERSION != 0x07B0) && (MASK_VERSION != 0x27B0) && (MASK_VERSION != 0x57B0)) || defined(ALL_MASKS)
#include "network_layer_coupler.h"
#include "data_link_layer.h"
#include "device_object.h"
@ -654,3 +655,4 @@ bool NetworkLayerCoupler::isTunnelAddress(uint16_t destination)
return _netLayerEntities[kPrimaryIfIndex].dataLinkLayer().isTunnelAddress(destination);
}
#endif
#endif

View File

@ -1,3 +1,4 @@
#if (MASK_VERSION == 0x07B0) || (MASK_VERSION == 0x27B0) || (MASK_VERSION == 0x57B0) || defined(ALL_MASKS)
#include "network_layer_device.h"
#include "device_object.h"
#include "tpdu.h"
@ -148,3 +149,4 @@ void NetworkLayerDevice::systemBroadcastConfirm(AckType ack, FrameFormat format,
HopCountType hopType = npdu.hopCount() == 7 ? UnlimitedRouting : NetworkLayerParameter;
_transportLayer.dataSystemBroadcastConfirm(ack, hopType, npdu.tpdu(), priority, status);
}
#endif

View File

@ -1,6 +1,6 @@
#ifdef ARDUINO_ARCH_ESP32
#include "esp32_platform.h"
#ifdef ARDUINO_ARCH_ESP32
#include <Arduino.h>
#include <EEPROM.h>

View File

@ -1,6 +1,7 @@
#ifdef ARDUINO_ARCH_ESP8266
#include "esp_platform.h"
#ifdef ARDUINO_ARCH_ESP8266
#include <user_interface.h>
#include <Arduino.h>
#include <EEPROM.h>

View File

@ -1,5 +1,6 @@
#include "linux_platform.h"
#ifdef __linux__
#include "linux_platform.h"
#include <cstdio>
#include <string>
#include <cstring>

View File

@ -22,10 +22,9 @@ For usage of KNX-IP you have to define either
- KNX_IP_WIFI (use the arduino-pico core's PiPicoW lwip stack)
----------------------------------------------------*/
#ifdef ARDUINO_ARCH_RP2040
#include "rp2040_arduino_platform.h"
#ifdef ARDUINO_ARCH_RP2040
#include "knx/bits.h"
#include <Arduino.h>

View File

@ -1,6 +1,6 @@
#ifdef ARDUINO_ARCH_SAMD
#include "samd_platform.h"
#ifdef ARDUINO_ARCH_SAMD
#include <knx/bits.h>
#include <Arduino.h>

View File

@ -1,6 +1,6 @@
#ifdef ARDUINO_ARCH_STM32
#include "stm32_platform.h"
#ifdef ARDUINO_ARCH_STM32
#include <EEPROM.h>
#include "knx/bits.h"

View File

@ -1,4 +1,5 @@
#include "../config.h"
#ifdef USE_RF
#if defined(DeviceFamily_CC13X0)
#include "rf_physical_layer_cc1310.h"
@ -380,3 +381,4 @@ void RfDataLinkLayer::loadNextTxFrame(uint8_t** sendBuffer, uint16_t* sendBuffer
delete tx_frame;
}
#endif

View File

@ -1,4 +1,5 @@
#include "../config.h"
#ifdef USE_RF
#include <cstring>
#include "rf_medium_object.h"
@ -56,3 +57,4 @@ void RfMediumObject::rfDomainAddress(const uint8_t* value)
Property* prop = property(PID_RF_DOMAIN_ADDRESS);
prop->write(value);
}
#endif

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_RF
#ifndef DeviceFamily_CC13X0
#include "rf_physical_layer_cc1101.h"
@ -778,3 +780,4 @@ void RfPhysicalLayerCC1101::loop()
}
#endif // DeviceFamily_CC13X0
#endif

View File

@ -122,7 +122,7 @@
#define VERSION 0xF1 // Current version number
#define FREQEST 0xF2 // Frequency offset estimate
#define LQI 0xF3 // Demodulator estimate for link quality
#define RSSI 0xF4 // Received signal strength indication
#define RF_RSSI 0xF4 // Received signal strength indication
#define MARCSTATE 0xF5 // Control state machine state
#define WORTIME1 0xF6 // High byte of WOR timer
#define WORTIME0 0xF7 // Low byte of WOR timer

View File

@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_RF
#ifdef DeviceFamily_CC13X0
@ -371,3 +373,4 @@ void RfPhysicalLayerCC1310::loop()
}
#endif // DeviceFamily_CC13X0
#endif

View File

@ -1,4 +1,5 @@
#include "config.h"
#if ((MASK_VERSION != 0x07B0) && (MASK_VERSION != 0x27B0) && (MASK_VERSION != 0x57B0)) || defined(ALL_MASKS)
#include <cstring>
#include "router_object.h"
@ -601,3 +602,4 @@ bool RouterObject::isGroupAddressInFilterTable(uint16_t groupAddress)
return false;
}
#endif

View File

@ -17,7 +17,7 @@
#define CBC 1
#define CTR 1
#define ECB 0
#include "aes.hpp"
#include "util/aes.hpp"
static constexpr uint8_t kSecureDataPdu = 0;
static constexpr uint8_t kSecureSyncRequest = 2;

View File

@ -1,4 +1,3 @@
#include "config.h"
#pragma GCC optimize("O3")
#include "address_table_object.h"