added functionproperty callback

This commit is contained in:
thewhobox 2023-03-13 21:24:41 +01:00
parent 6a1b70c558
commit d6348d2c80
3 changed files with 33 additions and 0 deletions

View File

@ -4,6 +4,9 @@
#include "interface_object.h" #include "interface_object.h"
typedef void (*BeforeRestartCallback)(void); typedef void (*BeforeRestartCallback)(void);
#ifdef USE_FUNCTIONPROPERTYCALLBACK
typedef void (*FunctionPropertyCallback)(uint8_t objectIndex, uint8_t propertyId, uint8_t length, uint8_t *data, uint8_t *resultData, uint8_t &resultLength);
#endif
class BusAccessUnit class BusAccessUnit
{ {
@ -165,4 +168,8 @@ class BusAccessUnit
uint8_t* data, uint32_t length); uint8_t* data, uint32_t length);
virtual void beforeRestartCallback(BeforeRestartCallback func); virtual void beforeRestartCallback(BeforeRestartCallback func);
virtual BeforeRestartCallback beforeRestartCallback(); virtual BeforeRestartCallback beforeRestartCallback();
#ifdef USE_FUNCTIONPROPERTYCALLBACK
virtual void functionPropertyCallback(FunctionPropertyCallback func);
virtual FunctionPropertyCallback functionPropertyCallback();
#endif
}; };

View File

@ -312,7 +312,14 @@ void BauSystemB::functionPropertyCommandIndication(Priority priority, HopCountTy
} }
else else
{ {
#ifdef USE_FUNCTIONPROPERTYCALLBACK
if(_functionProperty != 0)
_functionProperty(objectIndex, propertyId, length, data, resultData, resultLength);
else
resultLength = 0;
#else
resultLength = 0; // We must not send a return code or any data fields resultLength = 0; // We must not send a return code or any data fields
#endif
} }
} }
@ -638,3 +645,15 @@ BeforeRestartCallback BauSystemB::beforeRestartCallback()
{ {
return _beforeRestart; return _beforeRestart;
} }
#ifdef USE_FUNCTIONPROPERTYCALLBACK
void BauSystemB::functionPropertyCallback(FunctionPropertyCallback func)
{
_functionProperty = func;
}
FunctionPropertyCallback BauSystemB::functionPropertyCallback()
{
return _functionProperty;
}
#endif

View File

@ -43,6 +43,10 @@ class BauSystemB : protected BusAccessUnit
VersionCheckCallback versionCheckCallback(); VersionCheckCallback versionCheckCallback();
void beforeRestartCallback(BeforeRestartCallback func); void beforeRestartCallback(BeforeRestartCallback func);
BeforeRestartCallback beforeRestartCallback(); BeforeRestartCallback beforeRestartCallback();
#ifdef USE_FUNCTIONPROPERTYCALLBACK
void functionPropertyCallback(FunctionPropertyCallback func);
FunctionPropertyCallback functionPropertyCallback();
#endif
protected: protected:
virtual ApplicationLayer& applicationLayer() = 0; virtual ApplicationLayer& applicationLayer() = 0;
@ -113,4 +117,7 @@ class BauSystemB : protected BusAccessUnit
SecurityControl _restartSecurity; SecurityControl _restartSecurity;
uint32_t _restartDelay = 0; uint32_t _restartDelay = 0;
BeforeRestartCallback _beforeRestart = 0; BeforeRestartCallback _beforeRestart = 0;
#ifdef USE_FUNCTIONPROPERTYCALLBACK
FunctionPropertyCallback _functionProperty = 0;
#endif
}; };