Secure ReadProperty decoding and BACnetActionCommand (#702)

* Refactored and secured BACnetActionCommand codec into bacaction.c module for command object and added to bacapp module encode/decode with define for enabling and pseudo application tag for internal use.

* Simplified bacapp_data_len() and moved into bacdcode module as bacnet_enclosed_data_len() function.

* Secured ReadProperty-REQUEST and -ACK decoding.

* Removed deprecated Keylist_Key() functions from usage.

* Removed pseudo application datatypes from bacapp_data_decode() which only uses primitive application tag encoded values.

* Defined INT_MAX when it is not already defined by compiler or libc.

* Deprecated bacapp_decode_application_data_len() and bacapp_decode_context_data_len() as they are no longer used in any code in the library.

* Added BACnetScale to bacapp module. Improved complex property value decoding. Refactored bacapp_decode_known_property() function.

* Refactored and improved the bacapp_snprintf() function for printing EPICS.

* Fixed Lighting Output WriteProperty to handle known property decoding.
This commit is contained in:
Steve Karg
2024-07-25 17:12:08 -05:00
committed by GitHub
parent 923eaf2313
commit 4326128e72
191 changed files with 3856 additions and 2099 deletions
+8 -4
View File
@@ -151,13 +151,17 @@ unsigned Binary_Input_Count(void)
/**
* @brief Determines the object instance-number for a given 0..N index
* of Binary Input objects where N is Binary_Input_Count().
* @param index - 0..MAX_BINARY_INPUTS value
* @return object instance-number for the given index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Binary_Input_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+9 -8
View File
@@ -116,17 +116,18 @@ unsigned BitString_Value_Count(void)
}
/**
* We simply have 0-n object instances. Yours might be
* more complex, and then you need to return the index
* that correlates to the correct instance number
*
* @param index Object index
*
* @return Index in the object table.
* @brief Determines the object instance-number for a given 0..N index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t BitString_Value_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+7 -3
View File
@@ -154,12 +154,16 @@ unsigned Binary_Value_Count(void)
/**
* @brief Determines the object instance-number for a given 0..N index
* of objects where N is the count.
* @param index - 0..count value
* @return object instance-number for the given index
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Binary_Value_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+95 -364
View File
@@ -21,316 +21,34 @@
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacaction.h"
#include "bacnet/bacdcode.h"
#include "bacnet/bactext.h"
#include "bacnet/lighting.h"
#include "bacnet/proplist.h"
#include "bacnet/timestamp.h"
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/services.h"
/* me!*/
#include "bacnet/basic/object/command.h"
/*
BACnetActionCommand ::= SEQUENCE {
deviceIdentifier [0] BACnetObjectIdentifier OPTIONAL,
objectIdentifier [1] BACnetObjectIdentifier,
propertyIdentifier [2] BACnetPropertyIdentifier,
propertyArrayIndex [3] Unsigned OPTIONAL,
--used only with array datatype
propertyValue [4] ABSTRACT-SYNTAX.&Type,
priority [5] Unsigned (1..16) OPTIONAL,
--used only when property is commandable
postDelay [6] Unsigned OPTIONAL,
quitOnFailure [7] BOOLEAN,
writeSuccessful [8] BOOLEAN
}
*/
int cl_encode_apdu(uint8_t *apdu, BACNET_ACTION_LIST *bcl)
{
int len = 0;
int apdu_len = 0;
if (bcl->Device_Id.instance <= BACNET_MAX_INSTANCE) {
len = encode_context_object_id(
&apdu[apdu_len], 0, bcl->Device_Id.type, bcl->Device_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
/* TODO: Check for object type and instance limits */
len = encode_context_object_id(
&apdu[apdu_len], 1, bcl->Object_Id.type, bcl->Object_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len =
encode_context_enumerated(&apdu[apdu_len], 2, bcl->Property_Identifier);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
if (bcl->Property_Array_Index != BACNET_ARRAY_ALL) {
len = encode_context_unsigned(
&apdu[apdu_len], 3, bcl->Property_Array_Index);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
/* BACnet Testing Observed Incident oi00108
Command Action not correctly formatted
Revealed by BACnet Test Client v1.8.16 (
www.bac-test.com/bacnet-test-client-download ) BITS: BIT00031 BC
135.1: 9.20.1.7 BC 135.1: 9.20.1.9 Any discussions can be directed to
edward@bac-test.com Please feel free to remove this comment when my
changes have been reviewed by all interested parties. Say 6 months ->
September 2016 */
len = encode_opening_tag(&apdu[apdu_len], 4);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len = bacapp_encode_application_data(&apdu[apdu_len], &bcl->Value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len = encode_closing_tag(&apdu[apdu_len], 4);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
if (bcl->Priority != BACNET_NO_PRIORITY) {
len = encode_context_unsigned(&apdu[apdu_len], 5, bcl->Priority);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
if (bcl->Post_Delay != 0xFFFFFFFFU) {
len = encode_context_unsigned(&apdu[apdu_len], 6, bcl->Post_Delay);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
}
len = encode_context_boolean(&apdu[apdu_len], 7, bcl->Quit_On_Failure);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
len = encode_context_boolean(&apdu[apdu_len], 8, bcl->Write_Successful);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
apdu_len += len;
return apdu_len;
}
int cl_decode_apdu(uint8_t *apdu,
unsigned apdu_len,
BACNET_APPLICATION_TAG tag,
BACNET_ACTION_LIST *bcl)
{
int len = 0;
int dec_len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint32_t enum_value = 0;
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
if (decode_is_context_tag(&apdu[dec_len], 0)) {
/* Tag 0: Device ID */
dec_len++;
len = decode_object_id(
&apdu[dec_len], &bcl->Device_Id.type, &bcl->Device_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
}
if (!decode_is_context_tag(&apdu[dec_len++], 1)) {
return BACNET_STATUS_REJECT;
}
len = decode_object_id(
&apdu[dec_len], &bcl->Object_Id.type, &bcl->Object_Id.instance);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
if (tag_number != 2) {
return BACNET_STATUS_REJECT;
}
len = decode_enumerated(&apdu[dec_len], len_value_type, &enum_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Property_Identifier = enum_value;
dec_len += len;
if (decode_is_context_tag(&apdu[dec_len], 3)) {
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
dec_len += len;
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Property_Array_Index = unsigned_value;
dec_len += len;
} else {
bcl->Property_Array_Index = BACNET_ARRAY_ALL;
}
if (!decode_is_context_tag(&apdu[dec_len], 4)) {
return BACNET_STATUS_REJECT;
}
bcl->Value.context_specific = true;
bcl->Value.context_tag = 4;
bcl->Value.tag = tag;
switch (tag) {
case BACNET_APPLICATION_TAG_NULL:
len = 1;
break;
case BACNET_APPLICATION_TAG_BOOLEAN:
len = decode_context_boolean2(
&apdu[dec_len], 4, &bcl->Value.type.Boolean);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
break;
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
len = decode_context_unsigned(&apdu[dec_len], 4, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Value.type.Unsigned_Int = unsigned_value;
break;
case BACNET_APPLICATION_TAG_SIGNED_INT:
len = decode_context_signed(
&apdu[dec_len], 4, &bcl->Value.type.Signed_Int);
break;
case BACNET_APPLICATION_TAG_REAL:
len = decode_context_real(&apdu[dec_len], 4, &bcl->Value.type.Real);
break;
case BACNET_APPLICATION_TAG_DOUBLE:
len = decode_context_double(
&apdu[dec_len], 4, &bcl->Value.type.Double);
break;
case BACNET_APPLICATION_TAG_OCTET_STRING:
len = decode_context_octet_string(
&apdu[dec_len], 4, &bcl->Value.type.Octet_String);
break;
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
len = decode_context_character_string(
&apdu[dec_len], 4, &bcl->Value.type.Character_String);
break;
case BACNET_APPLICATION_TAG_BIT_STRING:
len = decode_context_bitstring(
&apdu[dec_len], 4, &bcl->Value.type.Bit_String);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
break;
case BACNET_APPLICATION_TAG_ENUMERATED:
len = decode_context_enumerated(
&apdu[dec_len], 4, &bcl->Value.type.Enumerated);
break;
case BACNET_APPLICATION_TAG_DATE:
len = decode_context_date(&apdu[dec_len], 4, &bcl->Value.type.Date);
break;
case BACNET_APPLICATION_TAG_TIME:
len = decode_context_bacnet_time(
&apdu[dec_len], 4, &bcl->Value.type.Time);
break;
case BACNET_APPLICATION_TAG_OBJECT_ID:
len = decode_context_object_id(&apdu[dec_len], 4,
&bcl->Value.type.Object_Id.type,
&bcl->Value.type.Object_Id.instance);
break;
#if defined(BACAPP_TYPES_EXTRA)
case BACNET_APPLICATION_TAG_LIGHTING_COMMAND:
len = lighting_command_decode(&apdu[dec_len], apdu_len - dec_len,
&bcl->Value.type.Lighting_Command);
break;
#endif
default:
return BACNET_STATUS_REJECT;
}
if (len > 0) {
dec_len += len;
}
if (decode_is_context_tag(&apdu[dec_len], 5)) {
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
dec_len += len;
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Priority = (uint8_t)unsigned_value;
dec_len += len;
} else {
bcl->Priority = BACNET_NO_PRIORITY;
}
if (decode_is_context_tag(&apdu[dec_len], 6)) {
len = decode_tag_number_and_value(
&apdu[dec_len], &tag_number, &len_value_type);
dec_len += len;
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Post_Delay = unsigned_value;
dec_len += len;
} else {
bcl->Post_Delay = 0xFFFFFFFFU;
}
if (!decode_is_context_tag(&apdu[dec_len], 7)) {
return BACNET_STATUS_REJECT;
}
len = decode_context_boolean2(&apdu[dec_len], 7, &bcl->Quit_On_Failure);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
if (!decode_is_context_tag(&apdu[dec_len], 8)) {
return BACNET_STATUS_REJECT;
}
len = decode_context_boolean2(&apdu[dec_len], 8, &bcl->Write_Successful);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
dec_len += len;
if (dec_len < apdu_len) {
return BACNET_STATUS_REJECT;
}
return dec_len;
}
COMMAND_DESCR Command_Descr[MAX_COMMANDS];
static COMMAND_DESCR Command_Descr[MAX_COMMANDS];
/* clang-format off */
/* These arrays are used by the ReadPropertyMultiple handler */
static const int Command_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_IN_PROCESS,
PROP_ALL_WRITES_SUCCESSFUL, PROP_ACTION, -1 };
static const int Command_Properties_Required[] = {
PROP_OBJECT_IDENTIFIER,
PROP_OBJECT_NAME,
PROP_OBJECT_TYPE,
PROP_PRESENT_VALUE,
PROP_IN_PROCESS,
PROP_ALL_WRITES_SUCCESSFUL,
PROP_ACTION,
-1 };
static const int Command_Properties_Optional[] = { PROP_DESCRIPTION, -1 };
static const int Command_Properties_Optional[] = { -1 };
static const int Command_Properties_Proprietary[] = { -1 };
/* clang-format on */
/**
* Returns the list of required, optional, and proprietary properties.
@@ -584,14 +302,78 @@ bool Command_Object_Name(
index = Command_Instance_To_Index(object_instance);
if (index < MAX_COMMANDS) {
snprintf(text, sizeof(text), "COMMAND %lu",
(unsigned long)object_instance);
snprintf(
text, sizeof(text), "COMMAND %lu", (unsigned long)object_instance);
status = characterstring_init_ansi(object_name, text);
}
return status;
}
/**
* @brief For a given object instance-number, returns the object data
* @param object_instance [in] BACnet network port object instance number
* @return pointer to the object data
*/
static COMMAND_DESCR *Object_Data(uint32_t object_instance)
{
unsigned int index = Command_Instance_To_Index(object_instance);
if (index < MAX_COMMANDS) {
return &Command_Descr[index];
}
return NULL;
}
BACNET_ACTION_LIST * Command_Action_List_Entry(
uint32_t instance, unsigned index)
{
COMMAND_DESCR *pObject;
BACNET_ACTION_LIST *pAction = NULL;
pObject = Object_Data(instance);
if (pObject && (index < MAX_COMMAND_ACTIONS)) {
pAction = &pObject->Action[index];
}
return pAction;
}
/**
* @brief For a given object instance-number, returns the number of actions
*/
unsigned Command_Action_List_Count(
uint32_t instance)
{
(void)instance;
return MAX_COMMAND_ACTIONS;
}
/**
* @brief Encode a BACnetARRAY property element
* @param object_instance [in] BACnet network port object instance number
* @param index [in] array index requested:
* 0 to N for individual array members
* @param apdu [out] Buffer in which the APDU contents are built, or NULL to
* return the length of buffer if it had been built
* @return The length of the apdu encoded or
* BACNET_STATUS_ERROR for ERROR_CODE_INVALID_ARRAY_INDEX
*/
static int Command_Action_List_Encode(
uint32_t object_instance, BACNET_ARRAY_INDEX index, uint8_t *apdu)
{
int apdu_len = BACNET_STATUS_ERROR;
COMMAND_DESCR *pObject;
pObject = Object_Data(object_instance);
if (pObject && (index < MAX_COMMAND_ACTIONS)) {
apdu_len = bacnet_action_command_encode(
apdu, &pObject->Action[index]);
}
return apdu_len;
}
/**
* ReadProperty handler for this object. For the given ReadProperty
* data, the application_data is loaded or the error flags are set.
@@ -605,26 +387,16 @@ bool Command_Object_Name(
int Command_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
{
int apdu_len = 0; /* return value */
int len = 0;
BACNET_CHARACTER_STRING char_string;
unsigned object_index = 0;
uint8_t *apdu = NULL;
uint16_t apdu_max = 0;
COMMAND_DESCR *CurrentCommand;
int apdu_size = 0;
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
(rpdata->application_data_len == 0)) {
return 0;
}
apdu_max = rpdata->application_data_len;
object_index = Command_Instance_To_Index(rpdata->object_instance);
if (object_index < MAX_COMMANDS) {
CurrentCommand = &Command_Descr[object_index];
} else {
return false;
}
apdu = rpdata->application_data;
apdu_size = rpdata->application_data_len;
switch ((int)rpdata->object_property) {
case PROP_OBJECT_IDENTIFIER:
apdu_len = encode_application_object_id(
@@ -632,7 +404,6 @@ int Command_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
break;
case PROP_OBJECT_NAME:
case PROP_DESCRIPTION:
Command_Object_Name(rpdata->object_instance, &char_string);
apdu_len =
encode_application_character_string(&apdu[0], &char_string);
@@ -651,60 +422,20 @@ int Command_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
&apdu[0], Command_In_Process(rpdata->object_instance));
break;
case PROP_ALL_WRITES_SUCCESSFUL:
apdu_len = encode_application_boolean(&apdu[0],
apdu_len = encode_application_boolean(
&apdu[0],
Command_All_Writes_Successful(rpdata->object_instance));
break;
case PROP_ACTION:
/* TODO */
if (rpdata->array_index == 0) {
apdu_len =
encode_application_unsigned(&apdu[0], MAX_COMMAND_ACTIONS);
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
int i;
for (i = 0; i < MAX_COMMAND_ACTIONS; i++) {
BACNET_ACTION_LIST *Curr_CL_Member =
&CurrentCommand->Action[0];
/* another loop, for additional actions in the list */
for (; Curr_CL_Member != NULL;
Curr_CL_Member = Curr_CL_Member->next) {
len = cl_encode_apdu(
&apdu[apdu_len], &CurrentCommand->Action[0]);
apdu_len += len;
/* assume the next one is of the same length, which need
* not be the case */
if ((i != MAX_COMMAND_ACTIONS - 1) &&
(apdu_len + len) >= apdu_max) {
rpdata->error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
apdu_len = BACNET_STATUS_ABORT;
break;
}
}
}
} else {
if (rpdata->array_index < MAX_COMMAND_ACTIONS) {
BACNET_ACTION_LIST *Curr_CL_Member =
&CurrentCommand->Action[rpdata->array_index];
/* another loop, for additional actions in the list */
for (; Curr_CL_Member != NULL;
Curr_CL_Member = Curr_CL_Member->next) {
len = cl_encode_apdu(
&apdu[apdu_len], &CurrentCommand->Action[0]);
apdu_len += len;
/* assume the next one is of the same length, which need
* not be the case */
if ((apdu_len + len) >= apdu_max) {
rpdata->error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
apdu_len = BACNET_STATUS_ABORT;
break;
}
}
} else {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
apdu_len = BACNET_STATUS_ERROR;
}
apdu_len = bacnet_array_encode(rpdata->object_instance,
rpdata->array_index, Command_Action_List_Encode,
MAX_COMMAND_ACTIONS, apdu, apdu_size);
if (apdu_len == BACNET_STATUS_ABORT) {
rpdata->error_code =
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
} else if (apdu_len == BACNET_STATUS_ERROR) {
rpdata->error_class = ERROR_CLASS_PROPERTY;
rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
}
break;
default:
@@ -781,8 +512,8 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
default:
if (property_lists_member(
Command_Properties_Required, Command_Properties_Optional,
Command_Properties_Proprietary, wp_data->object_property)) {
Command_Properties_Required, Command_Properties_Optional,
Command_Properties_Proprietary, wp_data->object_property)) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
} else {
+8 -23
View File
@@ -12,6 +12,7 @@
/* BACnet Stack defines - first */
#include "bacnet/bacdef.h"
/* BACnet Stack API */
#include "bacnet/bacaction.h"
#include "bacnet/rp.h"
#include "bacnet/wp.h"
@@ -27,29 +28,6 @@
extern "C" {
#endif /* __cplusplus */
typedef struct bacnet_action_list {
BACNET_OBJECT_ID Device_Id; /* Optional */
BACNET_OBJECT_ID Object_Id;
BACNET_PROPERTY_ID Property_Identifier;
uint32_t Property_Array_Index; /* Conditional */
BACNET_APPLICATION_DATA_VALUE Value;
uint8_t Priority; /* Conditional */
uint32_t Post_Delay; /* Optional */
bool Quit_On_Failure;
bool Write_Successful;
struct bacnet_action_list *next;
} BACNET_ACTION_LIST;
int cl_encode_apdu(
uint8_t * apdu,
BACNET_ACTION_LIST * bcl);
int cl_decode_apdu(
uint8_t * apdu,
unsigned apdu_len,
BACNET_APPLICATION_TAG tag,
BACNET_ACTION_LIST * bcl);
typedef struct command_descr {
uint32_t Present_Value;
bool In_Process;
@@ -144,6 +122,13 @@ extern "C" {
uint32_t instance,
float value);
BACNET_STACK_EXPORT
BACNET_ACTION_LIST * Command_Action_List_Entry(
uint32_t instance, unsigned index);
BACNET_STACK_EXPORT
unsigned Command_Action_List_Count(
uint32_t instance);
/* note: header of Intrinsic_Reporting function is required
even when INTRINSIC_REPORTING is not defined */
BACNET_STACK_EXPORT
+345 -108
View File
@@ -188,33 +188,6 @@ unsigned Lighting_Output_Instance_To_Index(uint32_t object_instance)
return Keylist_Index(Object_List, object_instance);
}
/**
* For a given object instance-number, determines the present-value
*
* @param object_instance - object-instance number of the object
*
* @return present-value of the object
*/
float Lighting_Output_Present_Value(uint32_t object_instance)
{
float value = 0.0;
unsigned p = 0;
struct object_data *pObject;
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
value = pObject->Relinquish_Default;
for (p = 0; p < BACNET_MAX_PRIORITY; p++) {
if (BIT_CHECK(pObject->Priority_Active_Bits, p)) {
value = pObject->Priority_Array[p];
break;
}
}
}
return value;
}
/**
* @brief Get the priority-array active status for the specific priority
* @param object [in] BACnet object instance
@@ -236,6 +209,27 @@ Priority_Array_Active(struct object_data *pObject, BACNET_ARRAY_INDEX priority)
return active;
}
/**
* @brief Get the priority-array value for the specific priority
* @param object [in] BACnet object instance
* @param priority [in] array index requested:
* 0 to N for individual array members
* @return The priority-array value for the specific priority
*/
static float
Priority_Array_Value(struct object_data *pObject, BACNET_ARRAY_INDEX priority)
{
float real_value = 0.0;
if (priority < BACNET_MAX_PRIORITY) {
if (BIT_CHECK(pObject->Priority_Active_Bits, priority)) {
real_value = pObject->Priority_Array[priority];
}
}
return real_value;
}
/**
* @brief Get the value of the next highest non-NULL priority, including
* Relinquish_Default
@@ -262,24 +256,23 @@ static float Priority_Array_Next_Value(
}
/**
* @brief Get the priority-array value for the specific priority
* @param object [in] BACnet object instance
* @param priority [in] array index requested:
* 0 to N for individual array members
* @return The priority-array value for the specific priority
* For a given object instance-number, determines the present-value
*
* @param object_instance - object-instance number of the object
*
* @return present-value of the object
*/
static float
Priority_Array_Value(struct object_data *pObject, BACNET_ARRAY_INDEX priority)
float Lighting_Output_Present_Value(uint32_t object_instance)
{
float real_value = 0.0;
float value = 0.0;
struct object_data *pObject;
if (priority < BACNET_MAX_PRIORITY) {
if (BIT_CHECK(pObject->Priority_Active_Bits, priority)) {
real_value = pObject->Priority_Array[priority];
}
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
value = Priority_Array_Next_Value(pObject, 0);
}
return real_value;
return value;
}
/**
@@ -437,6 +430,181 @@ bool Lighting_Output_Present_Value_Set(
return status;
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Warn(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(Priority_Array_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur
if any of the following conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN;
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Warn_Off(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(Priority_Array_Next_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur and
the value 0.0% written at the specified
priority immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The Present_Value is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN_OFF;
} else {
Present_Value_Set(pObject, 0.0, priority);
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Warn_Relinquish(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(Priority_Array_Next_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur,
and the value at the specified priority shall be
relinquished immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority
is 0.0% or NULL, or
(c) The value of the next highest non-NULL
priority, including Relinquish_Default,
is greater than 0.0%, or
(d) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN_RELINQUISH;
} else {
Present_Value_Relinquish(pObject, priority);
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
* @param value [in] BACnet lighting value
* @param fade_time [in] BACnet lighting fade time
*/
static void
Lighting_Command_Fade_To(struct object_data *pObject,
unsigned priority, float value, uint32_t fade_time)
{
unsigned current_priority;
if (!pObject) {
return;
}
Present_Value_Set(pObject, value, priority);
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.fade_time = fade_time;
pObject->Lighting_Command.operation = BACNET_LIGHTS_FADE_TO;
pObject->Lighting_Command.target_level = value;
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
* @param value [in] BACnet lighting value
* @param ramp_rate [in] BACnet lighting ramp rate
*/
static void
Lighting_Command_Ramp_To(struct object_data *pObject,
unsigned priority, float value, float ramp_rate)
{
unsigned current_priority;
if (!pObject) {
return;
}
Present_Value_Set(pObject, value, priority);
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.ramp_rate = ramp_rate;
pObject->Lighting_Command.operation = BACNET_LIGHTS_RAMP_TO;
pObject->Lighting_Command.target_level = value;
}
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
* @param operation [in] BACnet lighting operation
* @param step_increment [in] BACnet lighting step increment value
*/
static void Lighting_Command_Step(
struct object_data *pObject,
unsigned priority,
BACNET_LIGHTING_OPERATION operation,
float step_increment)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.operation = operation;
pObject->Lighting_Command.fade_time = 0;
pObject->Lighting_Command.ramp_rate = 0.0f;
pObject->Lighting_Command.step_increment = step_increment;
}
}
/**
* For a given object instance-number, writes the present-value
*
@@ -475,73 +643,17 @@ static bool Lighting_Output_Present_Value_Write(
if (!islessgreater(value, -1.0)) {
/* Provides the same functionality as the
WARN lighting command. */
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(
Priority_Array_Value(pObject, priority - 1), 0.0))) {
/* The blink-warn notification shall not occur
if any of the following conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation = BACNET_LIGHTS_WARN;
}
Lighting_Command_Warn(pObject, priority);
status = true;
} else if (!islessgreater(value, -2.0)) {
/* Provides the same functionality as the
WARN_RELINQUISH lighting command. */
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(
Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(
Priority_Array_Next_Value(pObject, priority - 1),
0.0))) {
/* The blink-warn notification shall not occur,
and the value at the specified priority shall be
relinquished immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The value at the specified priority
is 0.0% or NULL, or
(c) The value of the next highest non-NULL
priority, including Relinquish_Default,
is greater than 0.0%, or
(d) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation =
BACNET_LIGHTS_WARN_RELINQUISH;
} else {
Present_Value_Relinquish(pObject, priority);
}
Lighting_Command_Warn_Relinquish(pObject, priority);
status = true;
} else if (!islessgreater(value, -3.0)) {
/* Provides the same functionality as the
WARN_OFF lighting command. */
current_priority = Present_Value_Priority(pObject);
if ((priority <= current_priority) &&
(Priority_Array_Active(pObject, priority - 1)) &&
(isgreater(
Priority_Array_Value(pObject, priority - 1), 0.0)) &&
(isgreater(
Priority_Array_Next_Value(pObject, priority - 1),
0.0))) {
/* The blink-warn notification shall not occur and
the value 0.0% written at the specified
priority immediately if any of the following
conditions occur:
(a) The specified priority is not the highest
active priority, or
(b) The Present_Value is 0.0%, or
(c) Blink_Warn_Enable is FALSE. */
pObject->Lighting_Command.operation =
BACNET_LIGHTS_WARN_OFF;
} else {
Present_Value_Set(pObject, 0.0, priority);
}
Lighting_Command_Warn_Off(pObject, priority);
status = true;
} else if (
isgreaterequal(value, 0.0) && islessequal(value, 100.0)) {
@@ -799,9 +911,131 @@ bool Lighting_Output_Lighting_Command_Set(
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
/* FIXME: check lighting command member values */
status = lighting_command_copy(&pObject->Lighting_Command, value);
/* FIXME: set all the other values, and get the light levels moving */
}
return status;
}
/**
* @brief Set the lighting command if the priority is active
* @param object [in] BACnet object instance
* @param priority [in] BACnet priority array value 1..16
*/
static void
Lighting_Command_Stop(struct object_data *pObject, unsigned priority)
{
unsigned current_priority;
if (!pObject) {
return;
}
current_priority = Present_Value_Priority(pObject);
if (priority <= current_priority) {
/* we have priority - configure the Lighting Command */
pObject->Lighting_Command.operation = BACNET_LIGHTS_STOP;
}
}
/**
* For a given object instance-number, writes the present-value
*
* @param object_instance - object-instance number of the object
* @param value - property value to write
* @param priority - priority-array index value 1..16
* @param error_class - the BACnet error class
* @param error_code - BACnet Error code
*
* @return true if values are within range and present-value is set.
*/
static bool Lighting_Output_Lighting_Command_Write(
uint32_t object_instance,
BACNET_LIGHTING_COMMAND *value,
uint8_t priority,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
bool status = false;
struct object_data *pObject;
if (!value) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
if (priority == 6) {
/* Command priority 6 is reserved for use by Minimum On/Off
algorithm and may not be used for other purposes in any
object. */
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
return status;
}
if ((priority < BACNET_MIN_PRIORITY) ||
(priority > BACNET_MAX_PRIORITY)) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
if (value->operation >= MAX_BACNET_LIGHTING_OPERATION) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
pObject = Keylist_Data(Object_List, object_instance);
if (pObject) {
switch (value->operation) {
case BACNET_LIGHTS_NONE:
status = true;
break;
case BACNET_LIGHTS_FADE_TO:
Lighting_Command_Fade_To(pObject, priority,
value->target_level, value->fade_time);
status = true;
break;
case BACNET_LIGHTS_RAMP_TO:
Lighting_Command_Ramp_To(pObject, priority,
value->target_level, value->ramp_rate);
status = true;
break;
case BACNET_LIGHTS_STEP_UP:
case BACNET_LIGHTS_STEP_DOWN:
case BACNET_LIGHTS_STEP_ON:
case BACNET_LIGHTS_STEP_OFF:
Lighting_Command_Step(pObject,priority,
value->operation,value->step_increment);
status = true;
break;
case BACNET_LIGHTS_WARN:
/* Provides the same functionality as the
WARN lighting command. */
Lighting_Command_Warn(pObject, priority);
status = true;
break;
case BACNET_LIGHTS_WARN_OFF:
/* Provides the same functionality as the
WARN_OFF lighting command. */
Lighting_Command_Warn_Off(pObject, priority);
status = true;
break;
case BACNET_LIGHTS_WARN_RELINQUISH:
/* Provides the same functionality as the
WARN_RELINQUISH lighting command. */
Lighting_Command_Warn_Relinquish(pObject, priority);
status = true;
break;
case BACNET_LIGHTS_STOP:
Lighting_Command_Stop(pObject, priority);
status = true;
break;
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
break;
}
} else {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
}
return status;
@@ -1866,9 +2100,11 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
BACNET_APPLICATION_DATA_VALUE value;
/* decode the some of the request */
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
/* FIXME: len < application_data_len: more data? */
len = bacapp_decode_known_property(
wp_data->application_data, wp_data->application_data_len, &value,
wp_data->object_type, wp_data->object_property);
/* note: len < application_data_len means there is more data,
such as an array or list */
if (len < 0) {
/* error while decoding - a value larger than we can handle */
wp_data->error_class = ERROR_CLASS_PROPERTY;
@@ -1905,8 +2141,10 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_LIGHTING_COMMAND);
if (status) {
status = Lighting_Output_Lighting_Command_Set(
wp_data->object_instance, &value.type.Lighting_Command);
status = Lighting_Output_Lighting_Command_Write(
wp_data->object_instance, &value.type.Lighting_Command,
wp_data->priority,
&wp_data->error_class, &wp_data->error_code);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
@@ -1997,8 +2235,7 @@ bool Lighting_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
/**
* Handles the timing for a single Lighting Output object Fade
*
* @param pLight - Lighting Output object
* @param pCommand - BACNET_LIGHTING_COMMAND of the Lighting Output object
* @param object_instance - Lighting Output object
* @param milliseconds - number of milliseconds elapsed since previously
* called. Works best when called about every 10 milliseconds.
*/
+8 -4
View File
@@ -101,13 +101,17 @@ unsigned Multistate_Input_Instance_To_Index(uint32_t object_instance)
/**
* @brief Determines the object instance-number for a given 0..N index
* of Multistate Input objects where N is Multistate_Input_Count().
* @param index - 0..Multistate_Input_Count() value
* @return object instance-number for the given index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Multistate_Input_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+8 -4
View File
@@ -103,13 +103,17 @@ unsigned Multistate_Value_Instance_To_Index(uint32_t object_instance)
/**
* @brief Determines the object instance-number for a given 0..N index
* of Multistate Input objects where N is Multistate_Value_Count().
* @param index - 0..Multistate_Value_Count() value
* @return object instance-number for the given index
* of objects where N is the count.
* @param index - 0..N value
* @return object instance-number for a valid given index, or UINT32_MAX
*/
uint32_t Multistate_Value_Index_To_Instance(unsigned index)
{
return Keylist_Key(Object_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Object_List, index, &instance);
return instance;
}
/**
+81 -61
View File
@@ -2,7 +2,7 @@
* @file
* @author Steve Karg <skarg@users.sourceforge.net>
* @date 2016
* @brief A basic BACnet Network Port object provides access to the
* @brief A basic BACnet Network Port object provides access to the
* configuration and properties of any network ports of a device.
* @copyright SPDX-License-Identifier: MIT
*/
@@ -2898,7 +2898,75 @@ static bool Network_Port_FD_BBMD_Address_Write(
#endif
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
return status;
}
/**
* @brief Write the FD Subscription Lifetime
* @param object_instance [in] BACnet network port object instance number
* @param value [in] BACnet IP address and port
* @param error_class [out] BACnet error class
* @param error_code [out] BACnet error code
* @return true if the value was written
*/
static bool Network_Port_FD_Subscription_Lifetime_Write(
uint32_t object_instance,
BACNET_UNSIGNED_INTEGER value,
BACNET_ERROR_CLASS *error_class,
BACNET_ERROR_CODE *error_code)
{
bool status = false;
uint16_t lifetime = 0;
if (!error_class || !error_code) {
return status;
}
if (value > UINT16_MAX) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
return status;
}
lifetime = (uint16_t)value;
switch (Network_Port_Type(object_instance)) {
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
case PORT_TYPE_BIP:
if (Network_Port_BIP_Mode(object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status = Network_Port_Remote_BBMD_BIP_Lifetime_Set(
object_instance, lifetime);
if (!status) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
case PORT_TYPE_BIP6:
if (Network_Port_BIP6_Mode(object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status = Network_Port_Remote_BBMD_BIP6_Lifetime_Set(
object_instance, lifetime);
if (!status) {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
default:
*error_class = ERROR_CLASS_PROPERTY;
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
break;
}
@@ -3379,13 +3447,13 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
return false;
}
/* decode the some of the request */
#if !defined(BACAPP_COMPLEX_TYPES)
#if defined(BACAPP_COMPLEX_TYPES)
len = bacapp_decode_known_property(
wp_data->application_data, wp_data->application_data_len, &value,
wp_data->object_type, wp_data->object_property);
#else
len = bacapp_decode_application_data(
wp_data->application_data, wp_data->application_data_len, &value);
#else
len = bacapp_decode_generic_property(
wp_data->application_data, wp_data->application_data_len, &value,
wp_data->object_property);
#endif
if (len < 0) {
/* error while decoding - a value larger than we can handle */
@@ -3462,60 +3530,12 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_FD_SUBSCRIPTION_LIFETIME:
if (write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT)) {
if (value.type.Unsigned_Int <= 65535) {
switch (Network_Port_Type(wp_data->object_instance)) {
#if (defined(BACDL_ALL) || defined(BACDL_BIP))
case PORT_TYPE_BIP:
if (Network_Port_BIP_Mode(
wp_data->object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status =
Network_Port_Remote_BBMD_BIP_Lifetime_Set(
wp_data->object_instance,
value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
#if (defined(BACDL_ALL) || defined(BACDL_BIP6))
case PORT_TYPE_BIP6:
if (Network_Port_BIP6_Mode(
wp_data->object_instance) ==
BACNET_IP_MODE_FOREIGN) {
status =
Network_Port_Remote_BBMD_BIP6_Lifetime_Set(
wp_data->object_instance,
value.type.Unsigned_Int);
if (!status) {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_VALUE_OUT_OF_RANGE;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_WRITE_ACCESS_DENIED;
}
break;
#endif
default:
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code =
ERROR_CODE_INVALID_ARRAY_INDEX;
break;
}
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
status = Network_Port_FD_Subscription_Lifetime_Write(
wp_data->object_instance, value.type.Unsigned_Int,
&wp_data->error_class, &wp_data->error_code);
} else {
wp_data->error_class = ERROR_CLASS_PROPERTY;
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
}
break;
#endif
+5 -1
View File
@@ -31,7 +31,11 @@ int objects_device_count(void)
uint32_t objects_device_id(int index)
{
return Keylist_Key(Device_List, index);
uint32_t instance = UINT32_MAX;
(void)Keylist_Index_Key(Device_List, index, &instance);
return instance;
}
OBJECT_DEVICE_T *objects_device_data(int index)
+1 -2
View File
@@ -112,8 +112,7 @@ int rpm_ack_decode_service_request(
apdu_len -= len;
apdu += len;
if (apdu_len && decode_is_opening_tag_number(apdu, 4)) {
data_len = bacapp_data_len(apdu, (unsigned)apdu_len,
rpm_property->propertyIdentifier);
data_len = bacnet_enclosed_data_length(apdu, apdu_len);
/* propertyValue */
decoded_len++;
apdu_len--;
+6
View File
@@ -10,8 +10,14 @@
#ifndef BACNET_SYS_PLATFORM_H
#define BACNET_SYS_PLATFORM_H
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#ifndef INT_MAX
#define INT_MAX (~0U >> 1U)
#endif
#ifndef islessgreater
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
#endif