save work

This commit is contained in:
Nanosonde 2020-07-15 17:21:10 +02:00
parent fb5fb42d8a
commit 5ced388133
3 changed files with 37 additions and 1 deletions

View File

@ -33,6 +33,9 @@ Bau091A::Bau091A(Platform& platform)
_memory.addSaveRestore(&_cemiServerObject); _memory.addSaveRestore(&_cemiServerObject);
#endif #endif
_memory.addSaveRestore(&_rtObjPrimary);
_memory.addSaveRestore(&_rtObjSecondary);
_memory.addSaveRestore(&_ipParameters); _memory.addSaveRestore(&_ipParameters);
// Set Mask Version in Device Object depending on the BAU // Set Mask Version in Device Object depending on the BAU

View File

@ -51,7 +51,7 @@ RouterObjectFilterTable::RouterObjectFilterTable(Memory& memory)
return 1; return 1;
}), }),
new DataProperty( PID_MCB_TABLE, false, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0, (uint16_t) 0 ), // TODO new DataProperty( PID_MCB_TABLE, false, PDT_GENERIC_08, 1, ReadLv3 | WriteLv0),
new FunctionProperty<RouterObjectFilterTable>(this, PID_ROUTETABLE_CONTROL, new FunctionProperty<RouterObjectFilterTable>(this, PID_ROUTETABLE_CONTROL,
// Command Callback of PID_ROUTETABLE_CONTROL // Command Callback of PID_ROUTETABLE_CONTROL
@ -105,6 +105,8 @@ const uint8_t* RouterObjectFilterTable::restore(const uint8_t* buffer)
else else
_data = 0; _data = 0;
_filterTableGroupAddresses = (uint16_t*)_data;
return RouterObject::restore(buffer); return RouterObject::restore(buffer);
} }
@ -357,6 +359,32 @@ void RouterObjectFilterTable::errorCode(ErrorCode errorCode)
prop->write(data); prop->write(data);
} }
void RouterObjectFilterTable::beforeStateChange(LoadState& newState)
{
if (newState != LS_LOADED)
return;
// calculate crc16-ccitt for PID_MCB_TABLE
updateMcb();
_filterTableGroupAddresses = (uint16_t*)_data;
}
void RouterObjectFilterTable::updateMcb()
{
uint8_t mcb[propertySize(PID_MCB_TABLE)];
static constexpr uint32_t segmentSize = 8192;
uint16_t crc16 = crc16Ccitt(_data, segmentSize);
pushInt(segmentSize, &mcb[0]); // Segment size
pushByte(0x00, &mcb[4]); // CRC control byte -> 0: always valid -> according to coupler spec. it shall always be a valid CRC
pushByte(0xFF, &mcb[5]); // Read access 4 bits + Write access 4 bits (unknown: value taken from real coupler device)
pushWord(crc16, &mcb[6]); // CRC-16 CCITT of filter table
property(PID_MCB_TABLE)->write(mcb);
}
void RouterObjectFilterTable::masterReset(EraseCode eraseCode, uint8_t channel) void RouterObjectFilterTable::masterReset(EraseCode eraseCode, uint8_t channel)
{ {
RouterObject::masterReset(eraseCode, channel); RouterObject::masterReset(eraseCode, channel);

View File

@ -23,11 +23,14 @@ public:
const uint8_t* restore(const uint8_t* buffer) override; const uint8_t* restore(const uint8_t* buffer) override;
uint16_t saveSize() override; uint16_t saveSize() override;
private: private:
// Function properties // Function properties
void functionRouteTableControl(bool isCommand, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength); void functionRouteTableControl(bool isCommand, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength);
void functionRfEnableSbc(bool isCommand, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength); void functionRfEnableSbc(bool isCommand, uint8_t* data, uint8_t length, uint8_t* resultData, uint8_t& resultLength);
void updateMcb();
uint32_t tableReference(); uint32_t tableReference();
bool allocTable(uint32_t size, bool doFill, uint8_t fillByte); bool allocTable(uint32_t size, bool doFill, uint8_t fillByte);
void errorCode(ErrorCode errorCode); void errorCode(ErrorCode errorCode);
@ -38,6 +41,7 @@ private:
void loadEventLoaded(const uint8_t* data); void loadEventLoaded(const uint8_t* data);
void loadEventError(const uint8_t* data); void loadEventError(const uint8_t* data);
void additionalLoadControls(const uint8_t* data); void additionalLoadControls(const uint8_t* data);
void beforeStateChange(LoadState& newState);
void loadState(LoadState newState); void loadState(LoadState newState);
LoadState _state = LS_UNLOADED; LoadState _state = LS_UNLOADED;
@ -45,4 +49,5 @@ private:
Memory& _memory; Memory& _memory;
uint8_t *_data = 0; uint8_t *_data = 0;
bool _rfSbcRoutingEnabled = false; bool _rfSbcRoutingEnabled = false;
uint16_t* _filterTableGroupAddresses = 0;
}; };