mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
add default noop implementations for most stuff of platform.
This commit is contained in:
parent
5d8264555a
commit
d6db6a9673
@ -52,6 +52,7 @@ add_executable(knx-linux
|
||||
../src/knx/network_layer.h
|
||||
../src/knx/npdu.cpp
|
||||
../src/knx/npdu.h
|
||||
../src/knx/platform.cpp
|
||||
../src/knx/platform.h
|
||||
../src/knx/rf_data_link_layer.cpp
|
||||
../src/knx/rf_data_link_layer.h
|
||||
|
@ -145,6 +145,7 @@
|
||||
<ClCompile Include="..\src\knx\memory.cpp" />
|
||||
<ClCompile Include="..\src\knx\network_layer.cpp" />
|
||||
<ClCompile Include="..\src\knx\npdu.cpp" />
|
||||
<ClCompile Include="..\src\knx\platform.cpp" />
|
||||
<ClCompile Include="..\src\knx\rf_data_link_layer.cpp" />
|
||||
<ClCompile Include="..\src\knx\rf_medium_object.cpp" />
|
||||
<ClCompile Include="..\src\knx\rf_physical_layer.cpp" />
|
||||
|
@ -262,5 +262,8 @@
|
||||
<ClCompile Include="..\src\knx\rf_physical_layer.cpp">
|
||||
<Filter>Source files\knx</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\knx\platform.cpp">
|
||||
<Filter>Source files\knx</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -10,30 +10,6 @@ ArduinoPlatform::ArduinoPlatform(HardwareSerial* knxSerial) : _knxSerial(knxSeri
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t ArduinoPlatform::currentIpAddress()
|
||||
{
|
||||
// not needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t ArduinoPlatform::currentSubnetMask()
|
||||
{
|
||||
// not needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t ArduinoPlatform::currentDefaultGateway()
|
||||
{
|
||||
// not needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ArduinoPlatform::macAddress(uint8_t * addr)
|
||||
{
|
||||
// not needed
|
||||
}
|
||||
|
||||
|
||||
void ArduinoPlatform::fatalError()
|
||||
{
|
||||
const int period = 200;
|
||||
@ -48,28 +24,6 @@ void ArduinoPlatform::fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
void ArduinoPlatform::setupMultiCast(uint32_t addr, uint16_t port)
|
||||
{
|
||||
//not needed
|
||||
}
|
||||
|
||||
void ArduinoPlatform::closeMultiCast()
|
||||
{
|
||||
//not needed
|
||||
}
|
||||
|
||||
bool ArduinoPlatform::sendBytes(uint8_t * buffer, uint16_t len)
|
||||
{
|
||||
//not needed
|
||||
return false;
|
||||
}
|
||||
|
||||
int ArduinoPlatform::readBytes(uint8_t * buffer, uint16_t maxLen)
|
||||
{
|
||||
//not needed
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ArduinoPlatform::knxUart( HardwareSerial* serial )
|
||||
{
|
||||
closeUart();
|
||||
|
@ -9,21 +9,9 @@ class ArduinoPlatform : public Platform
|
||||
public:
|
||||
ArduinoPlatform(HardwareSerial* knxSerial);
|
||||
|
||||
// ip stuff
|
||||
uint32_t currentIpAddress();
|
||||
uint32_t currentSubnetMask();
|
||||
uint32_t currentDefaultGateway();
|
||||
void macAddress(uint8_t* addr);
|
||||
|
||||
// basic stuff
|
||||
void fatalError();
|
||||
|
||||
//multicast
|
||||
void setupMultiCast(uint32_t addr, uint16_t port);
|
||||
void closeMultiCast();
|
||||
bool sendBytes(uint8_t* buffer, uint16_t len);
|
||||
int readBytes(uint8_t* buffer, uint16_t maxLen);
|
||||
|
||||
//uart
|
||||
virtual void knxUart( HardwareSerial* serial);
|
||||
virtual HardwareSerial* knxUart();
|
||||
@ -43,7 +31,5 @@ class ArduinoPlatform : public Platform
|
||||
static Stream* SerialDebug;
|
||||
|
||||
protected:
|
||||
uint32_t _mulitcastAddr;
|
||||
uint16_t _mulitcastPort;
|
||||
HardwareSerial* _knxSerial;
|
||||
};
|
||||
|
@ -42,9 +42,7 @@ void Esp32Platform::restart()
|
||||
|
||||
void Esp32Platform::setupMultiCast(uint32_t addr, uint16_t port)
|
||||
{
|
||||
_mulitcastAddr = htonl(addr);
|
||||
_mulitcastPort = port;
|
||||
IPAddress mcastaddr(_mulitcastAddr);
|
||||
IPAddress mcastaddr(htonl(addr));
|
||||
|
||||
Serial.printf("setup multicast addr: %s port: %d ip: %s\n", mcastaddr.toString().c_str(), port,
|
||||
WiFi.localIP().toString().c_str());
|
||||
|
@ -33,6 +33,8 @@ class EspPlatform : public ArduinoPlatform
|
||||
void commitToEeprom();
|
||||
private:
|
||||
WiFiUDP _udp;
|
||||
uint32_t _mulitcastAddr;
|
||||
uint16_t _mulitcastPort;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
89
src/knx/platform.cpp
Normal file
89
src/knx/platform.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include "platform.h"
|
||||
|
||||
|
||||
NvMemoryType Platform::NonVolatileMemoryType()
|
||||
{
|
||||
return _memoryType;
|
||||
}
|
||||
|
||||
|
||||
void Platform::NonVolatileMemoryType(NvMemoryType type)
|
||||
{
|
||||
_memoryType = type;
|
||||
}
|
||||
|
||||
void Platform::setupSpi()
|
||||
{}
|
||||
|
||||
void Platform::closeSpi()
|
||||
{}
|
||||
|
||||
int Platform::readWriteSpi(uint8_t *data, size_t len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Platform::readBytesUart(uint8_t *buffer, size_t length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Platform::readUart()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t Platform::writeUart(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Platform::writeUart(const uint8_t data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Platform::uartAvailable()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Platform::closeUart()
|
||||
{}
|
||||
|
||||
void Platform::setupUart()
|
||||
{}
|
||||
|
||||
uint32_t Platform::currentIpAddress()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Platform::currentSubnetMask()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Platform::currentDefaultGateway()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Platform::macAddress(uint8_t *data)
|
||||
{}
|
||||
|
||||
void Platform::setupMultiCast(uint32_t addr, uint16_t port)
|
||||
{}
|
||||
|
||||
void Platform::closeMultiCast()
|
||||
{}
|
||||
|
||||
bool Platform::sendBytes(uint8_t *buffer, uint16_t len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Platform::readBytes(uint8_t *buffer, uint16_t maxLen)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -4,38 +4,45 @@
|
||||
#include <stddef.h>
|
||||
#include "save_restore.h"
|
||||
|
||||
enum NvMemoryType
|
||||
{
|
||||
Eeprom,
|
||||
Flash
|
||||
};
|
||||
|
||||
class Platform
|
||||
{
|
||||
public:
|
||||
virtual ~Platform() {}
|
||||
// ip config
|
||||
virtual uint32_t currentIpAddress() = 0;
|
||||
virtual uint32_t currentSubnetMask() = 0;
|
||||
virtual uint32_t currentDefaultGateway() = 0;
|
||||
virtual void macAddress(uint8_t* data) = 0;
|
||||
virtual uint32_t currentIpAddress();
|
||||
virtual uint32_t currentSubnetMask();
|
||||
virtual uint32_t currentDefaultGateway();
|
||||
virtual void macAddress(uint8_t* data);
|
||||
|
||||
// basic stuff
|
||||
virtual void restart() = 0;
|
||||
virtual void fatalError() = 0;
|
||||
|
||||
//multicast socket
|
||||
virtual void setupMultiCast(uint32_t addr, uint16_t port) = 0;
|
||||
virtual void closeMultiCast() = 0;
|
||||
virtual bool sendBytes(uint8_t* buffer, uint16_t len) = 0;
|
||||
virtual int readBytes(uint8_t* buffer, uint16_t maxLen) = 0;
|
||||
virtual void setupMultiCast(uint32_t addr, uint16_t port);
|
||||
virtual void closeMultiCast();
|
||||
virtual bool sendBytes(uint8_t* buffer, uint16_t len);
|
||||
virtual int readBytes(uint8_t* buffer, uint16_t maxLen);
|
||||
|
||||
//UART
|
||||
virtual void setupUart() = 0;
|
||||
virtual void closeUart() = 0;
|
||||
virtual int uartAvailable() = 0;
|
||||
virtual size_t writeUart(const uint8_t data) = 0;
|
||||
virtual size_t writeUart(const uint8_t* buffer, size_t size) = 0;
|
||||
virtual int readUart() = 0;
|
||||
virtual size_t readBytesUart(uint8_t* buffer, size_t length) = 0;
|
||||
virtual void setupUart();
|
||||
virtual void closeUart();
|
||||
virtual int uartAvailable();
|
||||
virtual size_t writeUart(const uint8_t data);
|
||||
virtual size_t writeUart(const uint8_t* buffer, size_t size);
|
||||
virtual int readUart();
|
||||
virtual size_t readBytesUart(uint8_t* buffer, size_t length);
|
||||
|
||||
// SPI
|
||||
virtual void setupSpi() = 0;
|
||||
virtual void closeSpi() = 0;
|
||||
virtual int readWriteSpi (uint8_t *data, size_t len) = 0;
|
||||
virtual void setupSpi();
|
||||
virtual void closeSpi();
|
||||
virtual int readWriteSpi(uint8_t *data, size_t len);
|
||||
#if 0
|
||||
// Flash memory
|
||||
virtual size_t flashEraseBlockSize(); // in pages
|
||||
@ -47,4 +54,10 @@ class Platform
|
||||
#endif
|
||||
virtual uint8_t* getEepromBuffer(uint16_t size) = 0;
|
||||
virtual void commitToEeprom() = 0;
|
||||
|
||||
NvMemoryType NonVolatileMemoryType();
|
||||
void NonVolatileMemoryType(NvMemoryType type);
|
||||
|
||||
protected:
|
||||
NvMemoryType _memoryType = Eeprom;
|
||||
};
|
@ -42,20 +42,6 @@ LinuxPlatform::~LinuxPlatform()
|
||||
delete[] _args;
|
||||
}
|
||||
|
||||
uint32_t LinuxPlatform::currentIpAddress()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t LinuxPlatform::currentSubnetMask()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t LinuxPlatform::currentDefaultGateway()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t millis()
|
||||
{
|
||||
@ -73,16 +59,7 @@ void delay(uint32_t millis)
|
||||
nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
void LinuxPlatform::macAddress(uint8_t* data)
|
||||
{
|
||||
// hardcode some address
|
||||
data[0] = 0x08;
|
||||
data[1] = 0x00;
|
||||
data[2] = 0x27;
|
||||
data[3] = 0x6c;
|
||||
data[4] = 0xa8;
|
||||
data[5] = 0x2a;
|
||||
}
|
||||
|
||||
|
||||
void LinuxPlatform::restart()
|
||||
{
|
||||
@ -262,45 +239,6 @@ void LinuxPlatform::doMemoryMapping()
|
||||
_mappedFile = addr;
|
||||
}
|
||||
|
||||
size_t LinuxPlatform::readBytesUart(uint8_t *buffer, size_t length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int LinuxPlatform::readUart()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
size_t LinuxPlatform::writeUart(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
size_t LinuxPlatform::writeUart(const uint8_t data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int LinuxPlatform::uartAvailable()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void LinuxPlatform::closeUart()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LinuxPlatform::setupUart()
|
||||
{
|
||||
}
|
||||
|
||||
void LinuxPlatform::closeSpi()
|
||||
{
|
||||
close(_spiFd);
|
||||
|
@ -22,12 +22,6 @@ public:
|
||||
std::string flashFilePath();
|
||||
void flashFilePath(const std::string path);
|
||||
|
||||
// ip stuff
|
||||
uint32_t currentIpAddress() override;
|
||||
uint32_t currentSubnetMask() override;
|
||||
uint32_t currentDefaultGateway() override;
|
||||
void macAddress(uint8_t* addr) override;
|
||||
|
||||
// basic stuff
|
||||
void restart() override;
|
||||
void fatalError() override;
|
||||
@ -38,15 +32,6 @@ public:
|
||||
bool sendBytes(uint8_t* buffer, uint16_t len) override;
|
||||
int readBytes(uint8_t* buffer, uint16_t maxLen) override;
|
||||
|
||||
//uart
|
||||
void setupUart() override;
|
||||
void closeUart() override;
|
||||
int uartAvailable() override;
|
||||
size_t writeUart(const uint8_t data) override;
|
||||
size_t writeUart(const uint8_t *buffer, size_t size) override;
|
||||
int readUart() override;
|
||||
size_t readBytesUart(uint8_t *buffer, size_t length) override;
|
||||
|
||||
//spi
|
||||
void setupSpi() override;
|
||||
void closeSpi() override;
|
||||
|
Loading…
Reference in New Issue
Block a user