Skip to content

Commit

Permalink
try to build less to reduce firmware sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
thelsing committed Aug 16, 2024
1 parent b59b37a commit 74036ba
Show file tree
Hide file tree
Showing 58 changed files with 189 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions src/knx/bau07B0.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#if (MASK_VERSION == 0x07B0) || defined(ALL_MASKS)

#include "bau07B0.h"
#include "bits.h"
Expand Down Expand Up @@ -174,3 +175,4 @@ TpUartDataLinkLayer* Bau07B0::getDataLinkLayer()
{
return (TpUartDataLinkLayer*)&_dlLayer;
}
#endif
2 changes: 2 additions & 0 deletions src/knx/bau091A.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x091A || defined(ALL_MASKS)

#include "bau091A.h"
#include "bits.h"
Expand Down Expand Up @@ -253,3 +254,4 @@ TpUartDataLinkLayer* Bau091A::getSecondaryDataLinkLayer()
{
return (TpUartDataLinkLayer*)&_dlLayerSecondary;
}
#endif
2 changes: 2 additions & 0 deletions src/knx/bau27B0.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x27B0 || defined(ALL_MASKS)

#include "bau27B0.h"
#include "bits.h"
Expand Down Expand Up @@ -203,3 +204,4 @@ RfDataLinkLayer* Bau27B0::getDataLinkLayer()
{
return (RfDataLinkLayer*)&_dlLayer;
}
#endif
2 changes: 2 additions & 0 deletions src/knx/bau2920.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x2920 || defined(ALL_MASKS)

#include "bau2920.h"
#include "bits.h"
Expand Down Expand Up @@ -177,3 +178,4 @@ RfDataLinkLayer* Bau2920::getSecondaryDataLinkLayer()
{
return (RfDataLinkLayer*)&_dlLayerSecondary;
}
#endif
2 changes: 2 additions & 0 deletions src/knx/bau57B0.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "config.h"
#if MASK_VERSION == 0x57B0 || defined(ALL_MASKS)

#include "bau57B0.h"
#include "bits.h"
Expand Down Expand Up @@ -165,3 +166,4 @@ IpDataLinkLayer* Bau57B0::getDataLinkLayer()
{
return (IpDataLinkLayer*)&_dlLayer;
}
#endif
2 changes: 2 additions & 0 deletions src/knx/bau_systemB_coupler.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -58,3 +59,4 @@ void BauSystemBCoupler::doMasterReset(EraseCode eraseCode, uint8_t channel)
_secIfObj.masterReset(eraseCode, channel);
#endif
}
#endif
2 changes: 2 additions & 0 deletions src/knx/bau_systemB_device.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -259,3 +260,4 @@ void BauSystemBDevice::groupValueWriteIndication(uint16_t asap, Priority priorit

updateGroupObject(go, data, dataLength);
}
#endif
12 changes: 9 additions & 3 deletions src/knx/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/knx/cemi_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
49 changes: 42 additions & 7 deletions src/knx/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,55 @@
//#define MASK_VERSION 0x2920

// Data Linklayer Driver Options
#if MASK_VERSION == 0x07B0
#ifndef USE_IP
#define USE_IP
#endif
#endif

#if MASK_VERSION == 0x27B0
#ifndef USE_RF
#define USE_RF
#endif
#endif

#if MASK_VERSION == 0x27B0 && !defined(USE_RF)
#define USE_RF
#if MASK_VERSION == 0x57B0
#ifndef USE_IP
#define USE_IP
#endif
#endif

#if MASK_VERSION == 0x2920 && !defined(USE_RF)
#define USE_RF
#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)
#define 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
Expand All @@ -63,4 +98,4 @@
// (combined with other flags (HWSERIAL_NONE for stm32) - avoid allocation of RX/TX buffers for all serial lines)
//#define KNX_NO_DEFAULT_UART

#endif
#endif
4 changes: 4 additions & 0 deletions src/knx/ip/ip_data_link_layer.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "../config.h"
#ifdef USE_IP

#include "ip_data_link_layer.h"

#include "../bits.h"
Expand Down Expand Up @@ -1184,3 +1187,4 @@ bool IpDataLinkLayer::isSendLimitReached()
return false;
}
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/ip_host_protocol_address_information.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "ip_host_protocol_address_information.h"
#include "../bits.h"

Expand Down Expand Up @@ -45,3 +47,4 @@ void IpHostProtocolAddressInformation::ipPortNumber(uint16_t value)
{
pushWord(value, _data + 6);
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/ip_parameter_object.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "ip_parameter_object.h"

#include "../bits.h"
Expand Down Expand Up @@ -137,3 +139,4 @@ uint16_t* IpParameterObject::additionalIndivualAddresses(uint8_t& numAddresses)
#endif
return (uint16_t*) propertyData(PID_ADDITIONAL_INDIVIDUAL_ADDRESSES);
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_ch.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_ch.h"

KnxIpCH::KnxIpCH(uint8_t* data) : _data(data)
Expand Down Expand Up @@ -45,3 +47,4 @@ uint8_t KnxIpCH::status() const
{
return _data[3];
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_config_dib.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -90,3 +92,4 @@ void KnxIpConfigDIB::info2(uint8_t addr)
else
_data[19] = addr;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_config_request.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_config_request.h"

KnxIpConfigRequest::KnxIpConfigRequest(uint8_t* data, uint16_t length)
Expand All @@ -14,3 +16,4 @@ KnxIpCH& KnxIpConfigRequest::connectionHeader()
{
return _ch;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_connect_request.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_connect_request.h"

KnxIpConnectRequest::KnxIpConnectRequest(uint8_t* data, uint16_t length)
Expand All @@ -18,3 +20,4 @@ KnxIpCRI& KnxIpConnectRequest::cri()
{
return _cri;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_connect_response.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -40,3 +42,4 @@ KnxIpCRD& KnxIpConnectResponse::crd()
{
return _crd;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_crd.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_crd.h"

KnxIpCRD::KnxIpCRD(uint8_t* data) : _data(data)
Expand Down Expand Up @@ -38,3 +40,4 @@ void KnxIpCRD::address(uint16_t value)
_data[2] = value >> 8;
_data[3] = value & 0xFF;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_cri.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_cri.h"

KnxIpCRI::KnxIpCRI(uint8_t* data) : _data(data)
Expand Down Expand Up @@ -35,3 +37,4 @@ void KnxIpCRI::layer(uint8_t value)
{
_data[2] = value;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_description_request.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_description_request.h"

KnxIpDescriptionRequest::KnxIpDescriptionRequest(uint8_t* data, uint16_t length)
Expand All @@ -10,3 +12,4 @@ IpHostProtocolAddressInformation& KnxIpDescriptionRequest::hpaiCtrl()
{
return _hpaiCtrl;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_description_response.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_description_response.h"

#define LEN_SERVICE_FAMILIES 2
Expand Down Expand Up @@ -68,3 +70,4 @@ KnxIpSupportedServiceDIB& KnxIpDescriptionResponse::supportedServices()
{
return _supportedServices;
}
#endif
5 changes: 4 additions & 1 deletion src/knx/ip/knx_ip_device_information_dib.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_device_information_dib.h"
#include "../bits.h"

Expand Down Expand Up @@ -97,4 +99,5 @@ const uint8_t* KnxIpDeviceInformationDIB::friendlyName() const
void KnxIpDeviceInformationDIB::friendlyName(const uint8_t* value)
{
pushByteArray(value, LEN_FRIENDLY_NAME, _data + 24);
}
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_dib.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_dib.h"

KnxIpDIB::KnxIpDIB(uint8_t* data) : _data(data)
Expand Down Expand Up @@ -25,3 +27,4 @@ void KnxIpDIB::code(DescriptionTypeCode value)
{
_data[1] = value;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_disconnect_request.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_disconnect_request.h"

KnxIpDisconnectRequest::KnxIpDisconnectRequest(uint8_t* data, uint16_t length)
Expand All @@ -23,3 +25,4 @@ void KnxIpDisconnectRequest::channelId(uint8_t channelId)
{
_data[LEN_KNXIP_HEADER] = channelId;
}
#endif
3 changes: 3 additions & 0 deletions src/knx/ip/knx_ip_disconnect_response.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "../config.h"
#ifdef USE_IP
#include "knx_ip_disconnect_response.h"

KnxIpDisconnectResponse::KnxIpDisconnectResponse(uint8_t channel, uint8_t status)
Expand All @@ -8,3 +10,4 @@ KnxIpDisconnectResponse::KnxIpDisconnectResponse(uint8_t channel, uint8_t status
_data[LEN_KNXIP_HEADER] = channel;
_data[LEN_KNXIP_HEADER + 1] = status;
}
#endif
Loading

0 comments on commit 74036ba

Please sign in to comment.