mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
fix userdata saverestore (#133)
* * fix for save/restore of userdata * change declaration of restore() in knx_facade.h to "const uint8_t* restore(const uint8_t* buffer)" to avoid calling default implementation in save_restore.h * change typedefs to separate SaveCallback and RestoreCallback * fix BME60 example, knx.setRestoreCallback() needs to use const uint8_t* as well * fix commitToEeprom for ESP32 * trigger dirty flag for ESP32 to make sure data is committed
This commit is contained in:
parent
1343ed0b7d
commit
14162fb1a4
@ -25,7 +25,7 @@
|
||||
void checkIaqSensorStatus(void);
|
||||
void errLeds(void);
|
||||
uint8_t* saveBme680State(uint8_t* buffer);
|
||||
uint8_t* loadBme680State(uint8_t* buffer);
|
||||
const uint8_t* loadBme680State(const uint8_t* buffer);
|
||||
void triggerCallback(GroupObject& go);
|
||||
void updateState();
|
||||
|
||||
@ -214,7 +214,7 @@ void errLeds(void)
|
||||
delay(100);
|
||||
}
|
||||
|
||||
uint8_t* loadBme680State(uint8_t* buffer)
|
||||
const uint8_t* loadBme680State(const uint8_t* buffer)
|
||||
{
|
||||
// Existing state in EEPROM
|
||||
Serial.println("Reading state from EEPROM");
|
||||
|
@ -104,6 +104,7 @@ uint8_t * Esp32Platform::getEepromBuffer(uint16_t size)
|
||||
|
||||
void Esp32Platform::commitToEeprom()
|
||||
{
|
||||
EEPROM.getDataPtr(); // trigger dirty flag in EEPROM lib to make sure data will be written to flash
|
||||
EEPROM.commit();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef uint8_t* (*SaveRestoreCallback)(uint8_t* buffer);
|
||||
typedef const uint8_t* (*RestoreCallback)(const uint8_t* buffer);
|
||||
typedef uint8_t* (*SaveCallback)(uint8_t* buffer);
|
||||
typedef void (*IsrFunctionPtr)();
|
||||
|
||||
template <class P, class B> class KnxFacade : private SaveRestore
|
||||
@ -266,12 +267,12 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
||||
_progButtonISRFuncPtr = progButtonISRFuncPtr;
|
||||
}
|
||||
|
||||
void setSaveCallback(SaveRestoreCallback func)
|
||||
void setSaveCallback(SaveCallback func)
|
||||
{
|
||||
_saveCallback = func;
|
||||
}
|
||||
|
||||
void setRestoreCallback(SaveRestoreCallback func)
|
||||
void setRestoreCallback(RestoreCallback func)
|
||||
{
|
||||
_restoreCallback = func;
|
||||
}
|
||||
@ -336,8 +337,8 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
||||
uint32_t _ledPin = LED_BUILTIN;
|
||||
uint32_t _buttonPinInterruptOn = RISING;
|
||||
uint32_t _buttonPin = 0;
|
||||
SaveRestoreCallback _saveCallback = 0;
|
||||
SaveRestoreCallback _restoreCallback = 0;
|
||||
SaveCallback _saveCallback = 0;
|
||||
RestoreCallback _restoreCallback = 0;
|
||||
volatile bool _toggleProgMode = false;
|
||||
bool _progLedState = false;
|
||||
uint16_t _saveSize = 0;
|
||||
@ -351,7 +352,7 @@ template <class P, class B> class KnxFacade : private SaveRestore
|
||||
return buffer;
|
||||
}
|
||||
|
||||
uint8_t* restore(uint8_t* buffer)
|
||||
const uint8_t* restore(const uint8_t* buffer)
|
||||
{
|
||||
if (_restoreCallback != 0)
|
||||
return _restoreCallback(buffer);
|
||||
|
Loading…
Reference in New Issue
Block a user