save work

This commit is contained in:
Nanosonde 2020-06-18 17:50:49 +02:00
parent 9c45500e0e
commit 47b582068b
4 changed files with 39 additions and 6 deletions

View File

@ -251,8 +251,8 @@ void BauSystemB::propertyValueReadIndication(Priority priority, HopCountType hop
void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t* data, uint8_t length)
{
uint8_t resultLength = 0;
uint8_t resultData[32];
uint8_t resultLength = sizeof(resultData);
InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj)
@ -264,8 +264,8 @@ void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountTy
void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType hopType, uint16_t asap, uint8_t objectIndex,
uint8_t propertyId, uint8_t* data, uint8_t length)
{
uint8_t resultLength = 0;
uint8_t resultData[32];
uint8_t resultLength = sizeof(resultData);
InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj)

View File

@ -994,3 +994,21 @@ bool SecureApplicationLayer::isSecurityModeEnabled()
{
return _securityModeEnabled;
}
void SecureApplicationLayer::clearFailureLog()
{
println("clearFailureLog()");
}
void SecureApplicationLayer::getFailureCounters(uint8_t* data)
{
memset(data, 0, 8);
println("getFailureCounters()");
}
uint8_t SecureApplicationLayer::getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen)
{
print("getFromFailureLogByIndex(): Index: ");
println(index);
return 0;
}

View File

@ -28,6 +28,9 @@ class SecureApplicationLayer : public ApplicationLayer
void setSecurityMode(bool enabled);
bool isSecurityModeEnabled();
void clearFailureLog();
void getFailureCounters(uint8_t* data);
uint8_t getFromFailureLogByIndex(uint8_t index, uint8_t* data, uint8_t maxDataLen);
// from transport layer
virtual void dataGroupIndication(HopCountType hopType, Priority priority, uint16_t tsap, APDU& apdu) override;

View File

@ -88,7 +88,7 @@ SecurityInterfaceObject::SecurityInterfaceObject()
uint8_t info = data[2];
if (id == 0 && info == 0)
{
//TODO: clearFailureLog();
obj->_secAppLayer->clearFailureLog();
resultData[0] = id;
resultLength = 1;
}
@ -107,13 +107,15 @@ SecurityInterfaceObject::SecurityInterfaceObject()
// failure counters
if (id == 0 && info == 0)
{
//TODO:
// var counters = ByteBuffer.allocate(10).put((byte) id).put((byte) info).put(failureCountersArray());
// return new ServiceResult(counters.array());
resultData[0] = id;
resultData[1] = info;
obj->_secAppLayer->getFailureCounters(&resultData[2]); // Put 8 bytes in the buffer
resultLength = 2 + 8;
}
// query latest failure by index
else if(id == 1)
{
uint8_t maxBufferSize = resultLength;
// TODO:
//int index = info;
//int i = 0;
@ -122,6 +124,16 @@ SecurityInterfaceObject::SecurityInterfaceObject()
// return new ServiceResult(ByteBuffer.allocate(2 + msgInfo.length).put((byte) id)
// .put((byte) index).put(msgInfo).array());
//}
uint8_t index = info;
uint8_t numBytes = obj->_secAppLayer->getFromFailureLogByIndex(index, &resultData[2], maxBufferSize);
if ( numBytes > 0)
{
resultData[0] = id;
resultData[1] = index;
resultLength += numBytes;
resultLength = 2 + numBytes;
return;
}
resultData[0] = 0xF8; // DataVoid
resultData[1] = id;
resultLength = 2;