Merge branch 'master' into feat_datasecure

This commit is contained in:
Nanosonde 2020-07-01 21:51:43 +02:00
commit 0dc98b2a30
6 changed files with 38 additions and 19 deletions

View File

@ -39,7 +39,7 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
#define getbyte(x,n) (*(((uint8_t*)&(x))+n)) #define getbyte(x,n) (*(((uint8_t*)&(x))+n))
#define htons(x) ( (getbyte(x,0)<<8) | getbyte(x,1) ) #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 ntohs(x) htons(x)
#define ntohl(x) htonl(x) #define ntohl(x) htonl(x)

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#ifndef NO_KNX_CONFIG
#ifdef ARDUINO_ARCH_SAMD #ifdef ARDUINO_ARCH_SAMD
#define SPI_SS_PIN 10 #define SPI_SS_PIN 10
#define GPIO_GDO2_PIN 9 #define GPIO_GDO2_PIN 9
@ -21,3 +23,5 @@
#endif #endif
#define USE_DATASECURE #define USE_DATASECURE
#endif

View File

@ -19,7 +19,15 @@ enum ComFlag
class GroupObject; 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> #include <functional>
typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler; typedef std::function<void(GroupObject&)> GroupObjectUpdatedHandler;
#else #else

View File

@ -203,12 +203,12 @@ template <class P, class B> class KnxFacade : private SaveRestore
_bau.deviceObject().bauNumber(value); _bau.deviceObject().bauNumber(value);
} }
void orderNumber(const char* value) void orderNumber(const uint8_t* value)
{ {
_bau.deviceObject().orderNumber(value); _bau.deviceObject().orderNumber(value);
} }
void hardwareType(uint8_t* value) void hardwareType(const uint8_t* value)
{ {
_bau.deviceObject().hardwareType(value); _bau.deviceObject().hardwareType(value);
} }

View File

@ -1,20 +1,20 @@
#include "stm32_platform.h" #include "stm32_platform.h"
#ifdef ARDUINO_ARCH_STM32 #ifdef ARDUINO_ARCH_STM32
#include <EEPROM.h> #include <stm32_eeprom.h>
#include "knx/bits.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() Stm32Platform::~Stm32Platform()
{ {
delete [] eepromPtr; delete [] _eepromPtr;
} }
void Stm32Platform::restart() void Stm32Platform::restart()
@ -24,19 +24,26 @@ void Stm32Platform::restart()
uint8_t * Stm32Platform::getEepromBuffer(uint16_t size) uint8_t * Stm32Platform::getEepromBuffer(uint16_t size)
{ {
delete [] eepromPtr; if (size > E2END + 1)
eepromPtr = new uint8_t[size]; {
for (uint16_t i = 0; i < size; ++i) fatalError();
eepromPtr[i] = EEPROM[i]; }
return eepromPtr; _eepromSize = size;
delete [] _eepromPtr;
_eepromPtr = new uint8_t[size];
eeprom_buffer_fill();
for (uint16_t i = 0; i < size; ++i)
_eepromPtr[i] = eeprom_buffered_read_byte(i);
return _eepromPtr;
} }
void Stm32Platform::commitToEeprom() void Stm32Platform::commitToEeprom()
{ {
if(eepromPtr == nullptr) if(_eepromPtr == nullptr || _eepromSize == 0)
return; return;
for (uint16_t i = 0; i < eepromSize; ++i) for (uint16_t i = 0; i < _eepromSize; ++i)
EEPROM.update(i, eepromPtr[i]); eeprom_buffered_write_byte(i, _eepromPtr[i]);
eeprom_buffer_flush();
} }
#endif #endif

View File

@ -15,8 +15,8 @@ public:
uint8_t* getEepromBuffer(uint16_t size); uint8_t* getEepromBuffer(uint16_t size);
void commitToEeprom(); void commitToEeprom();
private: private:
uint8_t *eepromPtr; uint8_t *_eepromPtr = nullptr;
uint16_t eepromSize; uint16_t _eepromSize = 0;
}; };
#endif #endif