Add API for writable object property lists (#1206)

Added a new API for writable property lists across all the basic example object types, preparing for the introduction of a Writable_Property_List property in every object in a future BACnet standard revision.

The lists can be used by backup and restore feature to automatically choose the object property values in the backup that can be restored via internal WriteProperty directly from BACnet CreateObject services with  List of Initial Values. 

Updated existing device object examples to include these writable property lists.
This commit is contained in:
Steve Karg
2026-01-21 10:02:21 -06:00
committed by GitHub
parent c408cc555b
commit 3a0878a254
100 changed files with 2084 additions and 214 deletions
+83 -8
View File
@@ -63,7 +63,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ },
NULL /* Timer */,
Device_Writable_Property_List },
#if (BACNET_PROTOCOL_REVISION >= 17)
{ OBJECT_NETWORK_PORT,
Network_Port_Init,
@@ -84,7 +85,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ },
NULL /* Timer */,
Network_Port_Writable_Property_List },
#endif
{ OBJECT_LOAD_CONTROL,
Load_Control_Init,
@@ -105,7 +107,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ },
NULL /* Timer */,
Load_Control_Writable_Property_List },
#if (BACNET_PROTOCOL_REVISION >= 14)
{ OBJECT_LIGHTING_OUTPUT,
Lighting_Output_Init,
@@ -126,7 +129,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
Lighting_Output_Create,
Lighting_Output_Delete,
Lighting_Output_Timer },
Lighting_Output_Timer,
Lighting_Output_Writable_Property_List },
{ OBJECT_CHANNEL,
Channel_Init,
Channel_Count,
@@ -146,7 +150,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
Channel_Create,
Channel_Delete,
NULL /* Timer */ },
NULL /* Timer */,
Channel_Writable_Property_List },
#endif
#if (BACNET_PROTOCOL_REVISION >= 24)
{ OBJECT_COLOR,
@@ -168,7 +173,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
Color_Create,
Color_Delete,
Color_Timer },
Color_Timer,
Color_Writable_Property_List },
{ OBJECT_COLOR_TEMPERATURE,
Color_Temperature_Init,
Color_Temperature_Count,
@@ -188,7 +194,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
Color_Temperature_Create,
Color_Temperature_Delete,
Color_Temperature_Timer },
Color_Temperature_Timer,
Color_Temperature_Writable_Property_List },
#endif
{ MAX_BACNET_OBJECT_TYPE,
NULL /* Init */,
@@ -209,7 +216,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ }
NULL /* Timer */,
NULL /* Writable_Property_List */ }
};
/** Glue function to let the Device object, when called by a handler,
@@ -336,6 +344,31 @@ bool Device_Objects_Property_List_Member(
return found;
}
/**
* @brief Get the Writeable Property List for an object type
* @param object_type - object type of the object
* @param object_instance - object-instance number of the object
* @param properties - pointer to the list of writable properties
* @return The number of properties in the writable property list
*/
uint32_t Device_Objects_Writable_Property_List(
BACNET_OBJECT_TYPE object_type,
uint32_t object_instance,
const int32_t **properties)
{
uint32_t count = 0;
struct object_functions *pObject = NULL;
(void)object_instance;
pObject = Device_Object_Functions_Find(object_type);
if ((pObject != NULL) && (pObject->Object_Writable_Property_List != NULL)) {
pObject->Object_Writable_Property_List(object_instance, properties);
count = property_list_count(*properties);
}
return count;
}
/* These three arrays are used by the ReadPropertyMultiple handler */
static const int Device_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER,
@@ -384,6 +417,34 @@ static const int Device_Properties_Optional[] = {
static const int Device_Properties_Proprietary[] = { -1 };
/* Every object shall have a Writable Property_List property
which is a BACnetARRAY of property identifiers,
one property identifier for each property within this object
that is always writable. */
static const int32_t Writable_Properties[] = {
/* unordered list of writable properties */
PROP_OBJECT_IDENTIFIER,
PROP_NUMBER_OF_APDU_RETRIES,
PROP_APDU_TIMEOUT,
PROP_VENDOR_IDENTIFIER,
PROP_SYSTEM_STATUS,
PROP_OBJECT_NAME,
PROP_LOCATION,
PROP_DESCRIPTION,
PROP_MODEL_NAME,
#if defined(BACNET_TIME_MASTER)
PROP_TIME_SYNCHRONIZATION_INTERVAL,
PROP_ALIGN_INTERVALS,
PROP_INTERVAL_OFFSET,
#endif
PROP_UTC_OFFSET,
#if defined(BACDL_MSTP)
PROP_MAX_INFO_FRAMES,
PROP_MAX_MASTER,
#endif
-1
};
/**
* @brief Returns the list of required, optional, and proprietary properties
* for the Device object.
@@ -411,6 +472,20 @@ void Device_Property_Lists(
return;
}
/**
* @brief Get the list of writable properties for a Device object
* @param object_instance - object-instance number of the object
* @param properties - Pointer to the pointer of writable properties.
*/
void Device_Writable_Property_List(
uint32_t object_instance, const int32_t **properties)
{
(void)object_instance;
if (properties) {
*properties = Writable_Properties;
}
}
/* note: you really only need to define variables for
properties that are writable or that may change.
The properties that are constant can be hard coded
+17 -16
View File
@@ -10,22 +10,31 @@ BACNET_OBJECT_DIR = $(BACNET_SRC_DIR)/bacnet/basic/object
BACNET_OBJECT_SRC := \
$(BACNET_OBJECT_DIR)/gateway/gw_device.c \
$(BACNET_OBJECT_DIR)/acc.c \
$(BACNET_OBJECT_DIR)/device.c \
$(BACNET_OBJECT_DIR)/access_credential.c \
$(BACNET_OBJECT_DIR)/access_door.c \
$(BACNET_OBJECT_DIR)/access_point.c \
$(BACNET_OBJECT_DIR)/access_rights.c \
$(BACNET_OBJECT_DIR)/access_user.c \
$(BACNET_OBJECT_DIR)/access_zone.c \
$(BACNET_OBJECT_DIR)/ai.c \
$(BACNET_OBJECT_DIR)/ao.c \
$(BACNET_OBJECT_DIR)/av.c \
$(BACNET_OBJECT_DIR)/acc.c \
$(BACNET_OBJECT_DIR)/auditlog.c \
$(BACNET_OBJECT_DIR)/bacfile.c \
$(BACNET_OBJECT_DIR)/bi.c \
$(BACNET_OBJECT_DIR)/bitstring_value.c \
$(BACNET_OBJECT_DIR)/blo.c \
$(BACNET_OBJECT_DIR)/bo.c \
$(BACNET_OBJECT_DIR)/blo.c \
$(BACNET_OBJECT_DIR)/bv.c \
$(BACNET_OBJECT_DIR)/calendar.c \
$(BACNET_OBJECT_DIR)/channel.c \
$(BACNET_OBJECT_DIR)/color_object.c \
$(BACNET_OBJECT_DIR)/color_temperature.c \
$(BACNET_OBJECT_DIR)/command.c \
$(BACNET_OBJECT_DIR)/credential_data_input.c \
$(BACNET_OBJECT_DIR)/csv.c \
$(BACNET_OBJECT_DIR)/device.c \
$(BACNET_OBJECT_DIR)/iv.c \
$(BACNET_OBJECT_DIR)/lc.c \
$(BACNET_OBJECT_DIR)/lo.c \
@@ -35,24 +44,16 @@ BACNET_OBJECT_SRC := \
$(BACNET_OBJECT_DIR)/ms-input.c \
$(BACNET_OBJECT_DIR)/mso.c \
$(BACNET_OBJECT_DIR)/msv.c \
$(BACNET_OBJECT_DIR)/nc.c \
$(BACNET_OBJECT_DIR)/netport.c \
$(BACNET_OBJECT_DIR)/osv.c \
$(BACNET_OBJECT_DIR)/piv.c \
$(BACNET_OBJECT_DIR)/program.c \
$(BACNET_OBJECT_DIR)/nc.c \
$(BACNET_OBJECT_DIR)/netport.c \
$(BACNET_OBJECT_DIR)/time_value.c \
$(BACNET_OBJECT_DIR)/timer.c \
$(BACNET_OBJECT_DIR)/trendlog.c \
$(BACNET_OBJECT_DIR)/schedule.c \
$(BACNET_OBJECT_DIR)/structured_view.c \
$(BACNET_OBJECT_DIR)/access_credential.c \
$(BACNET_OBJECT_DIR)/access_door.c \
$(BACNET_OBJECT_DIR)/access_point.c \
$(BACNET_OBJECT_DIR)/access_rights.c \
$(BACNET_OBJECT_DIR)/access_user.c \
$(BACNET_OBJECT_DIR)/access_zone.c \
$(BACNET_OBJECT_DIR)/credential_data_input.c \
$(BACNET_OBJECT_DIR)/bacfile.c
$(BACNET_OBJECT_DIR)/time_value.c \
$(BACNET_OBJECT_DIR)/timer.c \
$(BACNET_OBJECT_DIR)/trendlog.c
BACNET_BASIC_SRC = \
$(wildcard $(BACNET_SRC_DIR)/bacnet/basic/*.c) \
+1 -1
View File
@@ -10,7 +10,7 @@ fi
if [ ! -d "libpifacedigital" ]
then
git clone https://github.com:piface/libpifacedigital.git
git clone https://github.com/piface/libpifacedigital.git
fi
# Build the library
+54 -6
View File
@@ -56,7 +56,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ },
NULL /* Timer */,
Device_Writable_Property_List },
#if (BACNET_PROTOCOL_REVISION >= 17)
{ OBJECT_NETWORK_PORT,
Network_Port_Init,
@@ -77,7 +78,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ },
NULL /* Timer */,
Network_Port_Writable_Property_List },
#endif
{ OBJECT_BINARY_INPUT,
Binary_Input_Init,
@@ -98,7 +100,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ },
NULL /* Timer */,
Binary_Input_Writable_Property_List },
{ OBJECT_BINARY_LIGHTING_OUTPUT,
Binary_Lighting_Output_Init,
Binary_Lighting_Output_Count,
@@ -118,7 +121,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
Binary_Lighting_Output_Create,
Binary_Lighting_Output_Delete,
Binary_Lighting_Output_Timer },
Binary_Lighting_Output_Timer,
Binary_Lighting_Output_Writable_Property_List },
{ OBJECT_BINARY_OUTPUT,
Binary_Output_Init,
Binary_Output_Count,
@@ -138,7 +142,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
Binary_Output_Create,
Binary_Output_Delete,
NULL /* Timer */ },
NULL /* Timer */,
Binary_Output_Writable_Property_List },
{ MAX_BACNET_OBJECT_TYPE,
NULL /* Init */,
NULL /* Count */,
@@ -158,7 +163,8 @@ static object_functions_t My_Object_Table[] = {
NULL /* Remove_List_Element */,
NULL /* Create */,
NULL /* Delete */,
NULL /* Timer */ }
NULL /* Timer */,
NULL /* Writable_Property_List */ }
};
/** Glue function to let the Device object, when called by a handler,
@@ -331,6 +337,34 @@ static const int Device_Properties_Optional[] = {
-1
};
/* Every object shall have a Writable Property_List property
which is a BACnetARRAY of property identifiers,
one property identifier for each property within this object
that is always writable. */
static const int32_t Writable_Properties[] = {
/* unordered list of writable properties */
PROP_OBJECT_IDENTIFIER,
PROP_NUMBER_OF_APDU_RETRIES,
PROP_APDU_TIMEOUT,
PROP_VENDOR_IDENTIFIER,
PROP_SYSTEM_STATUS,
PROP_OBJECT_NAME,
PROP_LOCATION,
PROP_DESCRIPTION,
PROP_MODEL_NAME,
#if defined(BACNET_TIME_MASTER)
PROP_TIME_SYNCHRONIZATION_INTERVAL,
PROP_ALIGN_INTERVALS,
PROP_INTERVAL_OFFSET,
#endif
PROP_UTC_OFFSET,
#if defined(BACDL_MSTP)
PROP_MAX_INFO_FRAMES,
PROP_MAX_MASTER,
#endif
-1
};
static const int Device_Properties_Proprietary[] = { -1 };
void Device_Property_Lists(
@@ -349,6 +383,20 @@ void Device_Property_Lists(
return;
}
/**
* @brief Get the list of writable properties for a Device object
* @param object_instance - object-instance number of the object
* @param properties - Pointer to the pointer of writable properties.
*/
void Device_Writable_Property_List(
uint32_t object_instance, const int32_t **properties)
{
(void)object_instance;
if (properties) {
*properties = Writable_Properties;
}
}
/* note: you really only need to define variables for
properties that are writable or that may change.
The properties that are constant can be hard coded
+16 -15
View File
@@ -9,9 +9,18 @@ SRC = main.c
BACNET_OBJECT_DIR = $(BACNET_SRC_DIR)/bacnet/basic/object
SRC = main.c \
$(BACNET_OBJECT_DIR)/device.c \
$(BACNET_OBJECT_DIR)/access_credential.c \
$(BACNET_OBJECT_DIR)/access_door.c \
$(BACNET_OBJECT_DIR)/access_point.c \
$(BACNET_OBJECT_DIR)/access_rights.c \
$(BACNET_OBJECT_DIR)/access_user.c \
$(BACNET_OBJECT_DIR)/access_zone.c \
$(BACNET_OBJECT_DIR)/ai.c \
$(BACNET_OBJECT_DIR)/ao.c \
$(BACNET_OBJECT_DIR)/av.c \
$(BACNET_OBJECT_DIR)/acc.c \
$(BACNET_OBJECT_DIR)/auditlog.c \
$(BACNET_OBJECT_DIR)/bacfile.c \
$(BACNET_OBJECT_DIR)/bi.c \
$(BACNET_OBJECT_DIR)/bitstring_value.c \
$(BACNET_OBJECT_DIR)/bo.c \
@@ -22,6 +31,7 @@ SRC = main.c \
$(BACNET_OBJECT_DIR)/color_object.c \
$(BACNET_OBJECT_DIR)/color_temperature.c \
$(BACNET_OBJECT_DIR)/command.c \
$(BACNET_OBJECT_DIR)/credential_data_input.c \
$(BACNET_OBJECT_DIR)/csv.c \
$(BACNET_OBJECT_DIR)/iv.c \
$(BACNET_OBJECT_DIR)/lc.c \
@@ -32,25 +42,16 @@ SRC = main.c \
$(BACNET_OBJECT_DIR)/ms-input.c \
$(BACNET_OBJECT_DIR)/mso.c \
$(BACNET_OBJECT_DIR)/msv.c \
$(BACNET_OBJECT_DIR)/osv.c \
$(BACNET_OBJECT_DIR)/piv.c \
$(BACNET_OBJECT_DIR)/nc.c \
$(BACNET_OBJECT_DIR)/netport.c \
$(BACNET_OBJECT_DIR)/program.c \
$(BACNET_OBJECT_DIR)/time_value.c \
$(BACNET_OBJECT_DIR)/timer.c \
$(BACNET_OBJECT_DIR)/trendlog.c \
$(BACNET_OBJECT_DIR)/osv.c \
$(BACNET_OBJECT_DIR)/piv.c \
$(BACNET_OBJECT_DIR)/program.c \
$(BACNET_OBJECT_DIR)/schedule.c \
$(BACNET_OBJECT_DIR)/structured_view.c \
$(BACNET_OBJECT_DIR)/access_credential.c \
$(BACNET_OBJECT_DIR)/access_door.c \
$(BACNET_OBJECT_DIR)/access_point.c \
$(BACNET_OBJECT_DIR)/access_rights.c \
$(BACNET_OBJECT_DIR)/access_user.c \
$(BACNET_OBJECT_DIR)/access_zone.c \
$(BACNET_OBJECT_DIR)/credential_data_input.c \
$(BACNET_OBJECT_DIR)/acc.c \
$(BACNET_OBJECT_DIR)/bacfile.c
$(BACNET_OBJECT_DIR)/time_value.c \
$(BACNET_OBJECT_DIR)/timer.c \
$(BACNET_OBJECT_DIR)/trendlog.c
# TARGET_EXT is defined in apps/Makefile as .exe or nothing
TARGET_BIN = ${TARGET}$(TARGET_EXT)
+11 -5
View File
@@ -102,7 +102,8 @@ static object_functions_t My_Object_Table[] = {
NULL,
NULL,
NULL,
NULL },
NULL,
Device_Writable_Property_List },
/* Analog Value (Read-Only) */
{ OBJECT_ANALOG_VALUE,
@@ -124,7 +125,8 @@ static object_functions_t My_Object_Table[] = {
NULL,
Analog_Value_Create,
Analog_Value_Delete,
NULL },
NULL,
Analog_Value_Writable_Property_List },
/* Analog Output (Commandable) */
{ OBJECT_ANALOG_OUTPUT,
@@ -146,7 +148,8 @@ static object_functions_t My_Object_Table[] = {
NULL,
Analog_Output_Create,
Analog_Output_Delete,
NULL },
NULL,
Analog_Output_Writable_Property_List },
/* Binary Output (Commandable) */
{ OBJECT_BINARY_OUTPUT,
@@ -168,7 +171,8 @@ static object_functions_t My_Object_Table[] = {
NULL,
Binary_Output_Create,
Binary_Output_Delete,
NULL },
NULL,
Binary_Output_Writable_Property_List },
/* Binary Value (Read-Only) */
{ OBJECT_BINARY_VALUE,
@@ -190,7 +194,8 @@ static object_functions_t My_Object_Table[] = {
NULL,
Binary_Value_Create,
Binary_Value_Delete,
NULL },
NULL,
Binary_Value_Writable_Property_List },
{ MAX_BACNET_OBJECT_TYPE,
NULL,
@@ -211,6 +216,7 @@ static object_functions_t My_Object_Table[] = {
NULL,
NULL,
NULL,
NULL,
NULL }
};