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" #include "interface_object.h"
typedef void (*BeforeRestartCallback)(void); 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 class BusAccessUnit
{ {

View File

@ -303,23 +303,31 @@ void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountTy
uint8_t resultData[kFunctionPropertyResultBufferMaxSize]; uint8_t resultData[kFunctionPropertyResultBufferMaxSize];
uint8_t resultLength = sizeof(resultData); // tell the callee the maximum size of the buffer uint8_t resultLength = sizeof(resultData); // tell the callee the maximum size of the buffer
bool handled = false;
InterfaceObject* obj = getInterfaceObject(objectIndex); InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj) if(obj)
{ {
if (obj->property((PropertyID)propertyId)->Type() == PDT_FUNCTION) if (obj->property((PropertyID)propertyId)->Type() == PDT_FUNCTION)
{ {
obj->command((PropertyID)propertyId, data, length, resultData, resultLength); obj->command((PropertyID)propertyId, data, length, resultData, resultLength);
handled = true;
} }
else else
{ {
if(_functionProperty != 0) if(_functionProperty != 0)
_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength); if(_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength))
else handled = true;
resultLength = 0;
} }
} else {
if(_functionProperty != 0)
if(_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength))
handled = true;
} }
applicationLayer().functionPropertyStateResponse(AckRequested, priority, hopType, asap, secCtrl, objectIndex, propertyId, resultData, resultLength); //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);
} }
void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, uint8_t objectIndex, void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, uint8_t objectIndex,
@ -328,23 +336,31 @@ void BauSystemB::functionPropertyStateIndication(Priority priority, HopCountType
uint8_t resultData[kFunctionPropertyResultBufferMaxSize]; uint8_t resultData[kFunctionPropertyResultBufferMaxSize];
uint8_t resultLength = sizeof(resultData); // tell the callee the maximum size of the buffer uint8_t resultLength = sizeof(resultData); // tell the callee the maximum size of the buffer
bool handled = true;
InterfaceObject* obj = getInterfaceObject(objectIndex); InterfaceObject* obj = getInterfaceObject(objectIndex);
if(obj) if(obj)
{ {
if (obj->property((PropertyID)propertyId)->Type() == PDT_FUNCTION) if (obj->property((PropertyID)propertyId)->Type() == PDT_FUNCTION)
{ {
obj->state((PropertyID)propertyId, data, length, resultData, resultLength); obj->state((PropertyID)propertyId, data, length, resultData, resultLength);
handled = true;
} }
else else
{ {
if(_functionPropertyState != 0) if(_functionPropertyState != 0)
_functionPropertyState(objectIndex, propertyId, length, data, resultData, resultLength); if(_functionPropertyState(objectIndex, propertyId, length, data, resultData, resultLength))
else handled = true;
resultLength = 0;
} }
} else {
if(_functionProperty != 0)
if(_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength))
handled = true;
} }
applicationLayer().functionPropertyStateResponse(AckRequested, priority, hopType, asap, secCtrl, objectIndex, propertyId, resultData, resultLength); //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);
} }
void BauSystemB::functionPropertyExtCommandIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, ObjectType objectType, uint8_t objectInstance, void BauSystemB::functionPropertyExtCommandIndication(Priority priority, HopCountType hopType, uint16_t asap, const SecurityControl &secCtrl, ObjectType objectType, uint8_t objectInstance,