Added device WriteProperty callback for non-volatile storing in basic device examples. (#728)

This commit is contained in:
Steve Karg
2024-08-16 14:13:56 -05:00
committed by GitHub
parent e1002c433f
commit e3098bbaa2
3 changed files with 43 additions and 24 deletions
+24
View File
@@ -591,6 +591,7 @@ static uint32_t Database_Revision = 0;
/* Profile_Name */
static BACNET_REINITIALIZED_STATE Reinitialize_State = BACNET_REINIT_IDLE;
static const char *Reinit_Password = "filister";
static write_property_function Device_Write_Property_Store_Callback;
/**
* @brief Sets the ReinitializeDevice password
@@ -1901,6 +1902,26 @@ static bool Device_Write_Property_Object_Name(
return status;
}
/**
* @brief Set the callback for a WriteProperty successful operation
* @param cb [in] The function to be called, or NULL to disable
*/
void Device_Write_Property_Store_Callback_Set(
write_property_function cb)
{
Device_Write_Property_Store_Callback = cb;
}
/**
* @brief Store the value of a property when WriteProperty is successful
*/
static void Device_Write_Property_Store(BACNET_WRITE_PROPERTY_DATA *wp_data)
{
if (Device_Write_Property_Store_Callback) {
(void)Device_Write_Property_Store_Callback(wp_data);
}
}
/** Looks up the requested Object and Property, and set the new Value in it,
* if allowed.
* If the Object or Property can't be found, sets the error class and code.
@@ -1936,6 +1957,9 @@ bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
} else {
status = pObject->Object_Write_Property(wp_data);
}
if (status) {
Device_Write_Property_Store(wp_data);
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
+3
View File
@@ -471,6 +471,9 @@ extern "C" {
BACNET_STACK_EXPORT
bool Device_Write_Property_Local(
BACNET_WRITE_PROPERTY_DATA * wp_data);
BACNET_STACK_EXPORT
void Device_Write_Property_Store_Callback_Set(
write_property_function cb);
#if defined(INTRINSIC_REPORTING)
BACNET_STACK_EXPORT