mirror of
https://github.com/thelsing/knx.git
synced 2025-02-04 00:16:20 +01:00
Merge branch 'master' into feat_datasecure
This commit is contained in:
commit
0dc98b2a30
@ -39,7 +39,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
|
||||
|
||||
#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 htonl(x) ( (getbyte(x,0)<<24) | (getbyte(x,1)<<16) | (getbyte(x,2)<<8) | getbyte(x,3) )
|
||||
#define ntohs(x) htons(x)
|
||||
#define ntohl(x) htonl(x)
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NO_KNX_CONFIG
|
||||
|
||||
#ifdef ARDUINO_ARCH_SAMD
|
||||
#define SPI_SS_PIN 10
|
||||
#define GPIO_GDO2_PIN 9
|
||||
@ -21,3 +23,5 @@
|
||||
#endif
|
||||
|
||||
#define USE_DATASECURE
|
||||
|
||||
#endif
|
||||
|
@ -19,7 +19,15 @@ enum ComFlag
|
||||
|
||||
class GroupObject;
|
||||
|
||||
#ifdef __linux__
|
||||
#ifndef HAS_FUNCTIONAL
|
||||
# if defined(__linux__) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_STM32)
|
||||
# define HAS_FUNCTIONAL 1
|
||||
# else
|
||||
# define HAS_FUNCTIONAL 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAS_FUNCTIONAL
|
||||
#include <functional>
|
||||
typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler;
|
||||
#else
|
||||
|
@ -203,12 +203,12 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
||||
_bau.deviceObject().bauNumber(value);
|
||||
}
|
||||
|
||||
void orderNumber(const char* value)
|
||||
void orderNumber(const uint8_t* value)
|
||||
{
|
||||
_bau.deviceObject().orderNumber(value);
|
||||
}
|
||||
|
||||
void hardwareType(uint8_t* value)
|
||||
void hardwareType(const uint8_t* value)
|
||||
{
|
||||
_bau.deviceObject().hardwareType(value);
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
#include "stm32_platform.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_STM32
|
||||
#include <EEPROM.h>
|
||||
#include <stm32_eeprom.h>
|
||||
#include "knx/bits.h"
|
||||
|
||||
Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2), eepromPtr(nullptr), eepromSize(0)
|
||||
Stm32Platform::Stm32Platform() : ArduinoPlatform(&Serial2)
|
||||
{
|
||||
}
|
||||
|
||||
Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s), eepromPtr(nullptr), eepromSize(0)
|
||||
Stm32Platform::Stm32Platform( HardwareSerial* s) : ArduinoPlatform(s)
|
||||
{
|
||||
}
|
||||
|
||||
Stm32Platform::~Stm32Platform()
|
||||
{
|
||||
delete [] eepromPtr;
|
||||
delete [] _eepromPtr;
|
||||
}
|
||||
|
||||
void Stm32Platform::restart()
|
||||
@ -24,19 +24,26 @@ void Stm32Platform::restart()
|
||||
|
||||
uint8_t * Stm32Platform::getEepromBuffer(uint16_t size)
|
||||
{
|
||||
delete [] eepromPtr;
|
||||
eepromPtr = new uint8_t[size];
|
||||
if (size > E2END + 1)
|
||||
{
|
||||
fatalError();
|
||||
}
|
||||
_eepromSize = size;
|
||||
delete [] _eepromPtr;
|
||||
_eepromPtr = new uint8_t[size];
|
||||
eeprom_buffer_fill();
|
||||
for (uint16_t i = 0; i < size; ++i)
|
||||
eepromPtr[i] = EEPROM[i];
|
||||
return eepromPtr;
|
||||
_eepromPtr[i] = eeprom_buffered_read_byte(i);
|
||||
return _eepromPtr;
|
||||
}
|
||||
|
||||
void Stm32Platform::commitToEeprom()
|
||||
{
|
||||
if(eepromPtr == nullptr)
|
||||
if(_eepromPtr == nullptr || _eepromSize == 0)
|
||||
return;
|
||||
for (uint16_t i = 0; i < eepromSize; ++i)
|
||||
EEPROM.update(i, eepromPtr[i]);
|
||||
for (uint16_t i = 0; i < _eepromSize; ++i)
|
||||
eeprom_buffered_write_byte(i, _eepromPtr[i]);
|
||||
eeprom_buffer_flush();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -15,8 +15,8 @@ public:
|
||||
uint8_t* getEepromBuffer(uint16_t size);
|
||||
void commitToEeprom();
|
||||
private:
|
||||
uint8_t *eepromPtr;
|
||||
uint16_t eepromSize;
|
||||
uint8_t *_eepromPtr = nullptr;
|
||||
uint16_t _eepromSize = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user