functionproperty respond only if handled

This commit is contained in:
thewhobox 2023-05-06 20:53:06 +02:00
parent d52df6d584
commit 859b50eff6
2 changed files with 25 additions and 9 deletions

View File

@ -4,7 +4,7 @@
#include "interface_object.h"
typedef void (*BeforeRestartCallback)(void);
typedef void (*FunctionPropertyCallback)(uint8_t objectIndex, uint8_t propertyId, uint8_t length, uint8_t *data, uint8_t *resultData, uint8_t &resultLength);
typedef bool (*FunctionPropertyCallback)(uint8_t objectIndex, uint8_t propertyId, uint8_t length, uint8_t *data, uint8_t *resultData, uint8_t &resultLength);
class BusAccessUnit
{

View File

@ -303,22 +303,30 @@ void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountTy
uint8_t resultData[kFunctionPropertyResultBufferMaxSize];
uint8_t resultLength = sizeof(resultData); // tell the callee the maximum size of the buffer
bool handled = false;
InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj)
{
if (obj->property((PropertyID)propertyId)->Type() == PDT_FUNCTION)
{
obj->command((PropertyID)propertyId, data, length, resultData, resultLength);
handled = true;
}
else
{
if(_functionProperty != 0)
_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength);
else
resultLength = 0;
if(_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength))
handled = true;
}
} else {
if(_functionProperty != 0)
if(_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength))
handled = true;
}
//only return a value it was handled by a property or function
if(handled)
applicationLayer().functionPropertyStateResponse(AckRequested, priority, hopType, asap, secCtrl, objectIndex, propertyId, resultData, resultLength);
}
@ -328,22 +336,30 @@ void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType
uint8_t resultData[kFunctionPropertyResultBufferMaxSize];
uint8_t resultLength = sizeof(resultData); // tell the callee the maximum size of the buffer
bool handled = true;
InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj)
{
if (obj->property((PropertyID)propertyId)->Type() == PDT_FUNCTION)
{
obj->state((PropertyID)propertyId, data, length, resultData, resultLength);
handled = true;
}
else
{
if(_functionPropertyState != 0)
_functionPropertyState(objectIndex, propertyId, length, data, resultData, resultLength);
else
resultLength = 0;
if(_functionPropertyState(objectIndex, propertyId, length, data, resultData, resultLength))
handled = true;
}
} else {
if(_functionProperty != 0)
if(_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength))
handled = true;
}
//only return a value it was handled by a property or function
if(handled)
applicationLayer().functionPropertyStateResponse(AckRequested, priority, hopType, asap, secCtrl, objectIndex, propertyId, resultData, resultLength);
}