mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
add config.h and USE_IP USE_TP USE_RF macros
This commit is contained in:
parent
4cc8b2bb36
commit
d2b6653d68
@ -25,8 +25,10 @@ add_executable(knx-linux
|
||||
../src/knx/bits.cpp
|
||||
../src/knx/bits.h
|
||||
../src/knx/callback_property.h
|
||||
../src/knx/cemi_frame.cpp
|
||||
../src/knx/cemi_frame.cpp
|
||||
../src/knx/cemi_frame.h
|
||||
../src/knx/cemi_server.cpp
|
||||
../src/knx/cemi_server_object.cpp
|
||||
../src/knx/data_link_layer.cpp
|
||||
../src/knx/data_link_layer.h
|
||||
../src/knx/data_property.cpp
|
||||
@ -47,6 +49,7 @@ add_executable(knx-linux
|
||||
../src/knx/ip_data_link_layer.h
|
||||
../src/knx/ip_parameter_object.cpp
|
||||
../src/knx/ip_parameter_object.h
|
||||
../src/knx/knx_ip_frame.cpp
|
||||
../src/knx/knx_value.cpp
|
||||
../src/knx/knx_value.h
|
||||
../src/knx/memory.cpp
|
||||
@ -57,14 +60,14 @@ add_executable(knx-linux
|
||||
../src/knx/npdu.h
|
||||
../src/knx/platform.cpp
|
||||
../src/knx/platform.h
|
||||
../src/knx/property.cpp
|
||||
../src/knx/property.h
|
||||
../src/knx/rf_data_link_layer.cpp
|
||||
../src/knx/rf_data_link_layer.h
|
||||
../src/knx/rf_medium_object.cpp
|
||||
../src/knx/rf_medium_object.h
|
||||
../src/knx/rf_physical_layer.cpp
|
||||
../src/knx/rf_physical_layer.h
|
||||
../src/knx/property.cpp
|
||||
../src/knx/property.h
|
||||
../src/knx/table_object.cpp
|
||||
../src/knx/table_object.h
|
||||
../src/knx/tpdu.cpp
|
||||
@ -73,6 +76,7 @@ add_executable(knx-linux
|
||||
../src/knx/tpuart_data_link_layer.h
|
||||
../src/knx/transport_layer.cpp
|
||||
../src/knx/transport_layer.h
|
||||
../src/knx/usb_tunnel_interface.cpp
|
||||
../src/knx_facade.cpp
|
||||
../src/knx_facade.h
|
||||
../src/linux_platform.cpp
|
||||
|
@ -111,7 +111,7 @@
|
||||
<ImportedPropertySheets />
|
||||
<CodeSense>
|
||||
<Enabled>True</Enabled>
|
||||
<CXXFLAGS>-DMEDIUM_TYPE=5 -DUSE_CEMI_SERVER</CXXFLAGS>
|
||||
<CXXFLAGS>-DMEDIUM_TYPE=5</CXXFLAGS>
|
||||
<ExtraSettings>
|
||||
<HideErrorsInSystemHeaders>true</HideErrorsInSystemHeaders>
|
||||
<SupportLightweightReferenceAnalysis>true</SupportLightweightReferenceAnalysis>
|
||||
|
@ -86,6 +86,7 @@
|
||||
<ClInclude Include="..\src\knx\cemi_frame.h" />
|
||||
<ClInclude Include="..\src\knx\cemi_server.h" />
|
||||
<ClInclude Include="..\src\knx\cemi_server_object.h" />
|
||||
<ClInclude Include="..\src\knx\config.h" />
|
||||
<ClInclude Include="..\src\knx\datapoint_types.h" />
|
||||
<ClInclude Include="..\src\knx\data_link_layer.h" />
|
||||
<ClInclude Include="..\src\knx\data_property.h" />
|
||||
|
@ -170,6 +170,9 @@
|
||||
<ClInclude Include="..\src\knx\callback_property.h">
|
||||
<Filter>Header files\knx</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\knx\config.h">
|
||||
<Filter>Header files\knx</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\knx\address_table_object.cpp">
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "knx_facade.h"
|
||||
#if MEDIUM_TYPE == 5
|
||||
|
||||
#include "knx/bau57B0.h"
|
||||
#elif MEDIUM_TYPE == 2
|
||||
#include "knx/bau27B0.h"
|
||||
#else
|
||||
#error Only MEDIUM_TYPE IP and RF supported
|
||||
#endif
|
||||
#include "knx/bau07B0.h"
|
||||
|
||||
#include "knx/group_object_table_object.h"
|
||||
#include "knx/bits.h"
|
||||
#include <time.h>
|
||||
@ -25,6 +23,14 @@ void signalHandler(int sig)
|
||||
loopActive = 0;
|
||||
}
|
||||
|
||||
bool sendHidReport(uint8_t* data, uint16_t length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool isSendHidReportPossible()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#if MEDIUM_TYPE == 5
|
||||
KnxFacade<LinuxPlatform, Bau57B0> knx;
|
||||
#elif MEDIUM_TYPE == 2
|
||||
@ -60,7 +66,6 @@ void measureTemp()
|
||||
if (currentValue > max)
|
||||
MAX.value(currentValue);
|
||||
|
||||
double min = MIN.value();
|
||||
if (currentValue < (double)MIN.value())
|
||||
MIN.value(currentValue);
|
||||
}
|
||||
@ -142,9 +147,10 @@ int main(int argc, char **argv)
|
||||
// opens the "value" sysfs file to read or write the GPIO pin value.
|
||||
// The following calls will close the "value" sysfs fiel for the pin
|
||||
// and unexport the GPIO pin.
|
||||
#ifdef USE_RF
|
||||
gpio_unexport(SPI_SS_PIN);
|
||||
gpio_unexport(GPIO_GDO2_PIN);
|
||||
gpio_unexport(GPIO_GDO0_PIN);
|
||||
|
||||
#endif
|
||||
printf("main() exit.\n");
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_TP
|
||||
|
||||
using namespace std;
|
||||
|
||||
Bau07B0::Bau07B0(Platform& platform)
|
||||
@ -98,4 +100,6 @@ void Bau07B0::loop()
|
||||
#ifdef USE_CEMI_SERVER
|
||||
_cemiServer.loop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "bau_systemB.h"
|
||||
#include "tpuart_data_link_layer.h"
|
||||
#include "cemi_server.h"
|
||||
#include "cemi_server_object.h"
|
||||
|
||||
#ifdef USE_TP
|
||||
|
||||
class Bau07B0 : public BauSystemB
|
||||
{
|
||||
public:
|
||||
@ -32,4 +35,5 @@ class Bau07B0 : public BauSystemB
|
||||
const uint32_t _ifObjs[6] = { 5, // length
|
||||
OT_DEVICE, OT_ADDR_TABLE, OT_ASSOC_TABLE, OT_GRP_OBJ_TABLE, OT_APPLICATION_PROG};
|
||||
#endif
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
#include "bau_systemB.h"
|
||||
#include "rf_medium_object.h"
|
||||
#include "rf_physical_layer.h"
|
||||
@ -42,4 +44,5 @@ class Bau27B0 : public BauSystemB
|
||||
void individualAddressSerialNumberWriteIndication(Priority priority, HopCountType hopType, uint16_t newIndividualAddress,
|
||||
uint8_t* knxSerialNumber);
|
||||
void individualAddressSerialNumberReadIndication(Priority priority, HopCountType hopType, uint8_t* knxSerialNumber);
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,8 +1,11 @@
|
||||
#include "config.h"
|
||||
#include "bau57B0.h"
|
||||
#include "bits.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_IP
|
||||
|
||||
using namespace std;
|
||||
|
||||
Bau57B0::Bau57B0(Platform& platform)
|
||||
@ -80,4 +83,6 @@ uint8_t* Bau57B0::descriptor()
|
||||
DataLinkLayer& Bau57B0::dataLinkLayer()
|
||||
{
|
||||
return _dlLayer;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_IP
|
||||
#include "bau_systemB.h"
|
||||
#include "ip_parameter_object.h"
|
||||
#include "ip_data_link_layer.h"
|
||||
@ -21,4 +23,5 @@ class Bau57B0 : public BauSystemB
|
||||
uint8_t _descriptor[2] = {0x57, 0xb0};
|
||||
const uint32_t _ifObjs[7] = { 6, // length
|
||||
OT_DEVICE, OT_ADDR_TABLE, OT_ASSOC_TABLE, OT_GRP_OBJ_TABLE, OT_APPLICATION_PROG, OT_IP_PARAMETER};
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "bau.h"
|
||||
#include "device_object.h"
|
||||
#include "address_table_object.h"
|
||||
@ -9,7 +10,7 @@
|
||||
#include "application_layer.h"
|
||||
#include "transport_layer.h"
|
||||
#include "network_layer.h"
|
||||
#include "tpuart_data_link_layer.h"
|
||||
#include "data_link_layer.h"
|
||||
#include "platform.h"
|
||||
#include "memory.h"
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "config.h"
|
||||
#ifdef USE_CEMI_SERVER
|
||||
|
||||
#include "cemi_server.h"
|
||||
@ -146,7 +147,7 @@ void CemiServer::frameReceived(CemiFrame& frame)
|
||||
popWord(objectType, &frame.data()[1]);
|
||||
uint8_t objectInstance = frame.data()[3];
|
||||
uint8_t propertyId = frame.data()[4];
|
||||
uint32_t numberOfElements = frame.data()[5] >> 4;
|
||||
uint8_t numberOfElements = frame.data()[5] >> 4;
|
||||
uint16_t startIndex = frame.data()[6] | ((frame.data()[5]&0x0F)<<8);
|
||||
uint8_t* data = nullptr;
|
||||
uint32_t dataSize = 0;
|
||||
@ -225,7 +226,7 @@ void CemiServer::frameReceived(CemiFrame& frame)
|
||||
popWord(objectType, &frame.data()[1]);
|
||||
uint8_t objectInstance = frame.data()[3];
|
||||
uint8_t propertyId = frame.data()[4];
|
||||
uint32_t numberOfElements = frame.data()[5] >> 4;
|
||||
uint8_t numberOfElements = frame.data()[5] >> 4;
|
||||
uint16_t startIndex = frame.data()[6] | ((frame.data()[5]&0x0F)<<8);
|
||||
uint8_t* requestData = &frame.data()[7];
|
||||
uint32_t requestDataSize = frame.dataLength() - 7;
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_CEMI_SERVER
|
||||
|
||||
#include <stdint.h>
|
||||
#include "knx_types.h"
|
||||
#include "usb_tunnel_interface.h"
|
||||
@ -48,3 +51,5 @@ class CemiServer
|
||||
BauSystemB& _bau;
|
||||
UsbTunnelInterface _usbTunnelInterface;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,3 +1,4 @@
|
||||
#include "config.h"
|
||||
#ifdef USE_CEMI_SERVER
|
||||
|
||||
#include <cstring>
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_CEMI_SERVER
|
||||
|
||||
#include "interface_object.h"
|
||||
|
||||
class CemiServerObject: public InterfaceObject
|
||||
@ -21,3 +24,4 @@ private:
|
||||
uint8_t _commMode = 0x00;
|
||||
|
||||
};
|
||||
#endif
|
6
src/knx/config.h
Normal file
6
src/knx/config.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define USE_CEMI_SERVER
|
||||
#define USE_RF
|
||||
#define USE_TP
|
||||
#define USE_IP
|
@ -1,5 +1,7 @@
|
||||
#include "ip_data_link_layer.h"
|
||||
|
||||
#ifdef USE_IP
|
||||
|
||||
#include "bits.h"
|
||||
#include "platform.h"
|
||||
#include "device_object.h"
|
||||
@ -103,3 +105,4 @@ bool IpDataLinkLayer::sendBytes(uint8_t* bytes, uint16_t length)
|
||||
|
||||
return _platform.sendBytesMultiCast(bytes, length);
|
||||
}
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_IP
|
||||
#include <stdint.h>
|
||||
#include "data_link_layer.h"
|
||||
#include "ip_parameter_object.h"
|
||||
@ -22,4 +24,5 @@ class IpDataLinkLayer : public DataLinkLayer
|
||||
bool sendBytes(uint8_t* buffer, uint16_t length);
|
||||
|
||||
IpParameterObject& _ipParameters;
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#include "ip_parameter_object.h"
|
||||
#ifdef USE_IP
|
||||
#include "device_object.h"
|
||||
#include "platform.h"
|
||||
#include "bits.h"
|
||||
@ -109,7 +110,12 @@ uint32_t IpParameterObject::multicastAddress() const
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t IpParameterObject::saveSize()
|
||||
uint8_t IpParameterObject::ttl() const
|
||||
{
|
||||
return 51;
|
||||
}
|
||||
const Property* prop = property(PID_TTL);
|
||||
|
||||
uint8_t data[1];
|
||||
prop->read(1, 1, data);
|
||||
return data[0];
|
||||
}
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_IP
|
||||
#include "interface_object.h"
|
||||
#include "device_object.h"
|
||||
#include "platform.h"
|
||||
@ -8,35 +10,17 @@ class IpParameterObject : public InterfaceObject
|
||||
{
|
||||
public:
|
||||
IpParameterObject(DeviceObject& deviceObject, Platform& platform);
|
||||
void readProperty(PropertyID id, uint16_t start, uint8_t& count, uint8_t* data) override;
|
||||
void writeProperty(PropertyID id, uint16_t start, uint8_t* data, uint8_t& count) override;
|
||||
uint8_t propertySize(PropertyID id) override;
|
||||
|
||||
ObjectType objectType() override
|
||||
{
|
||||
return OT_IP_PARAMETER;
|
||||
}
|
||||
|
||||
uint8_t* save(uint8_t* buffer) override;
|
||||
uint8_t* restore(uint8_t* buffer) override;
|
||||
uint16_t saveSize() override;
|
||||
|
||||
uint32_t multicastAddress() const;
|
||||
uint8_t ttl() const { return _ttl; }
|
||||
|
||||
protected:
|
||||
uint8_t propertyDescriptionCount() override;
|
||||
PropertyDescription* propertyDescriptions() override;
|
||||
uint8_t ttl() const;
|
||||
|
||||
private:
|
||||
uint16_t _projectInstallationId = 0;
|
||||
uint8_t _ipAssignmentMethod = 0;
|
||||
uint8_t _ipCapabilities = 0;
|
||||
uint32_t _ipAddress = 0;
|
||||
uint32_t _subnetMask = 0;
|
||||
uint32_t _defaultGateway = 0;
|
||||
uint32_t _multicastAddress = 0;
|
||||
uint8_t _ttl = 60;
|
||||
char _friendlyName[30] = {0};
|
||||
DeviceObject& _deviceObject;
|
||||
Platform& _platform;
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,4 +1,6 @@
|
||||
#include "knx_ip_frame.h"
|
||||
|
||||
#ifdef USE_IP
|
||||
#include "bits.h"
|
||||
|
||||
#define KNXIP_HEADER_LEN 0x6
|
||||
@ -32,6 +34,7 @@ void KnxIpFrame::protocolVersion(KnxIpVersion version)
|
||||
|
||||
uint16_t KnxIpFrame::serviceTypeIdentifier() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KnxIpFrame::serviceTypeIdentifier(uint16_t identifier)
|
||||
@ -46,4 +49,5 @@ uint16_t KnxIpFrame::totalLength() const
|
||||
void KnxIpFrame::totalLength(uint16_t length)
|
||||
{
|
||||
pushWord(length, _data + 2);
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "cemi_frame.h"
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_IP
|
||||
enum KnxIpVersion
|
||||
{
|
||||
KnxIp1_0
|
||||
@ -45,4 +46,5 @@ class KnxIpFrame
|
||||
|
||||
private:
|
||||
uint8_t* _data = 0;
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#if MEDIUM_TYPE == 2
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
|
||||
#include "rf_physical_layer.h"
|
||||
#include "rf_data_link_layer.h"
|
||||
@ -376,4 +377,4 @@ void RfDataLinkLayer::loadNextTxFrame(uint8_t** sendBuffer, uint16_t* sendBuffer
|
||||
delete tx_frame;
|
||||
}
|
||||
|
||||
#endif // #if MEDIUM_TYPE == 2
|
||||
#endif
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
|
||||
#include <stdint.h>
|
||||
#include "data_link_layer.h"
|
||||
|
||||
@ -56,3 +59,5 @@ class RfDataLinkLayer : public DataLinkLayer
|
||||
void frameBytesReceived(uint8_t* buffer, uint16_t length);
|
||||
uint16_t calcCrcRF(uint8_t* buffer, uint32_t offset, uint32_t len);
|
||||
};
|
||||
|
||||
#endif
|
@ -2,6 +2,9 @@
|
||||
#include "rf_medium_object.h"
|
||||
#include "bits.h"
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
|
||||
void RfMediumObject::readProperty(PropertyID propertyId, uint16_t start, uint8_t& count, uint8_t* data)
|
||||
{
|
||||
switch (propertyId)
|
||||
@ -135,3 +138,4 @@ PropertyDescription* RfMediumObject::propertyDescriptions()
|
||||
{
|
||||
return _propertyDescriptions;
|
||||
}
|
||||
#endif
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
#include "interface_object.h"
|
||||
|
||||
class RfMediumObject: public InterfaceObject
|
||||
@ -23,4 +25,5 @@ private:
|
||||
uint8_t _rfDomainAddress[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; // see KNX RF S-Mode AN160 p.11
|
||||
uint8_t _rfDiagSourceAddressFilterTable[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
|
||||
uint8_t _rfDiagLinkBudgetTable[24] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
|
||||
};
|
||||
};
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#if MEDIUM_TYPE == 2
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
|
||||
#include "rf_physical_layer.h"
|
||||
#include "rf_data_link_layer.h"
|
||||
@ -796,4 +797,4 @@ void RfPhysicalLayer::loop()
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if MEDIUM_TYPE == 2
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef RF_PHYSICAL_LAYER_H
|
||||
#define RF_PHYSICAL_LAYER_H
|
||||
#include "config.h"
|
||||
#ifdef USE_RF
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_TP
|
||||
#include <stdint.h>
|
||||
#include "data_link_layer.h"
|
||||
|
||||
@ -59,3 +62,4 @@ class TpUartDataLinkLayer : public DataLinkLayer
|
||||
bool resetChip();
|
||||
void stopChip();
|
||||
};
|
||||
#endif
|
@ -1,3 +1,4 @@
|
||||
#include "config.h"
|
||||
#ifdef USE_CEMI_SERVER
|
||||
|
||||
#include "bits.h"
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#ifdef USE_CEMI_SERVER
|
||||
#include <stdint.h>
|
||||
|
||||
class CemiServer;
|
||||
@ -91,3 +93,4 @@ class UsbTunnelInterface
|
||||
void handleBusAccessServerProtocol(ServiceIdType servId, const uint8_t* requestData, uint16_t packetLength);
|
||||
void sendKnxHidReport(ProtocolIdType protId, ServiceIdType servId, uint8_t* data, uint16_t length);
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user