mirror of
https://github.com/thelsing/knx.git
synced 2025-07-30 13:46:26 +02:00
Merge pull request #316 from thewhobox/fix/unloading
Permanently unload device
This commit is contained in:
commit
e2642b64ca
5
examples/knx-demo/.gitignore
vendored
Normal file
5
examples/knx-demo/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
@ -49,6 +49,7 @@ void BauSystemBDevice::loop()
|
||||
#ifdef USE_DATASECURE
|
||||
_appLayer.loop();
|
||||
#endif
|
||||
_memory.loop();
|
||||
}
|
||||
|
||||
void BauSystemBDevice::sendNextGroupTelegram()
|
||||
|
@ -301,10 +301,15 @@ void Memory::freeMemory(uint8_t* ptr)
|
||||
|
||||
removeFromUsedList(block);
|
||||
addToFreeList(block);
|
||||
_saveTimeout = millis();
|
||||
}
|
||||
|
||||
void Memory::writeMemory(uint32_t relativeAddress, size_t size, uint8_t* data)
|
||||
{
|
||||
if(_saveTimeout != 0)
|
||||
{
|
||||
_saveTimeout = millis();
|
||||
}
|
||||
_platform.writeNonVolatileMemory(relativeAddress, data, size);
|
||||
}
|
||||
|
||||
@ -541,3 +546,13 @@ VersionCheckCallback Memory::versionCheckCallback()
|
||||
{
|
||||
return _versionCheckCallback;
|
||||
}
|
||||
|
||||
void Memory::loop()
|
||||
{
|
||||
if(_saveTimeout != 0 && millis() - _saveTimeout > 5000)
|
||||
{
|
||||
println("saveMemory timeout");
|
||||
_saveTimeout = 0;
|
||||
writeMemory();
|
||||
}
|
||||
}
|
@ -46,6 +46,7 @@ class Memory
|
||||
void clearMemory();
|
||||
void addSaveRestore(SaveRestore* obj);
|
||||
void addSaveRestore(TableObject* obj);
|
||||
void loop();
|
||||
|
||||
uint8_t* allocMemory(size_t size);
|
||||
void freeMemory(uint8_t* ptr);
|
||||
@ -82,4 +83,5 @@ class Memory
|
||||
MemoryBlock* _freeList = nullptr;
|
||||
MemoryBlock* _usedList = nullptr;
|
||||
uint16_t _metadataSize = 6 + LEN_HARDWARE_TYPE; // accounting for 3x pushWord and pushByteArray of length LEN_HARDWARE_TYPE
|
||||
unsigned long _saveTimeout = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user