make pretty using clang-format 10
This commit is contained in:
+5
-4
@@ -170,8 +170,10 @@ int abort_encode_apdu(
|
||||
*
|
||||
* @param apdu Receive buffer
|
||||
* @param apdu_len Count of bytes valid in the received buffer.
|
||||
* @param invoke_id Pointer to a variable, taking the invoked ID from the message.
|
||||
* @param abort_reason Pointer to a variable, taking the abort reason, see ABORT_REASON_X enumeration for details
|
||||
* @param invoke_id Pointer to a variable, taking the invoked ID from the
|
||||
* message.
|
||||
* @param abort_reason Pointer to a variable, taking the abort reason, see
|
||||
* ABORT_REASON_X enumeration for details
|
||||
*
|
||||
* @return Total length of the apdu, typically 2 on success, zero otherwise.
|
||||
*/
|
||||
@@ -314,8 +316,7 @@ static void testAbortError(Test *pTest)
|
||||
error_code = abort_convert_to_error_code(abort_code);
|
||||
test_abort_code = abort_convert_error_code(error_code);
|
||||
if (test_abort_code != abort_code) {
|
||||
printf("Abort: result=%u abort-code=%u\n",
|
||||
test_abort_code,
|
||||
printf("Abort: result=%u abort-code=%u\n", test_abort_code,
|
||||
abort_code);
|
||||
}
|
||||
ct_test(pTest, test_abort_code == abort_code);
|
||||
|
||||
@@ -122,8 +122,8 @@ int bacapp_decode_access_rule(uint8_t *apdu, BACNET_ACCESS_RULE *rule)
|
||||
}
|
||||
|
||||
if (decode_is_context_tag(&apdu[apdu_len], 2)) {
|
||||
len = decode_context_enumerated(
|
||||
&apdu[apdu_len], 2, &location_specifier);
|
||||
len =
|
||||
decode_context_enumerated(&apdu[apdu_len], 2, &location_specifier);
|
||||
if (len < 0) {
|
||||
return -1;
|
||||
} else if (location_specifier < LOCATION_SPECIFIER_MAX) {
|
||||
|
||||
+2
-2
@@ -158,8 +158,8 @@ int awf_decode_service_request(
|
||||
if (apdu_len >= apdu_len_max) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
len = bacnet_unsigned_application_decode(&apdu[apdu_len],
|
||||
apdu_len_max, &unsigned_value);
|
||||
len = bacnet_unsigned_application_decode(
|
||||
&apdu[apdu_len], apdu_len_max, &unsigned_value);
|
||||
if (len <= 0) {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
|
||||
+1
-2
@@ -141,8 +141,7 @@ int bacapp_encode_application_data(
|
||||
#if defined(BACAPP_OBJECT_ID)
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
apdu_len = encode_application_object_id(&apdu[0],
|
||||
value->type.Object_Id.type,
|
||||
value->type.Object_Id.instance);
|
||||
value->type.Object_Id.type, value->type.Object_Id.instance);
|
||||
break;
|
||||
#endif
|
||||
#if defined(BACAPP_LIGHTING_COMMAND)
|
||||
|
||||
+32
-21
@@ -725,14 +725,14 @@ int encode_context_bitstring(
|
||||
/* from clause 20.2.14 Encoding of an Object Identifier Value */
|
||||
/* returns the number of apdu bytes consumed */
|
||||
int decode_object_id(
|
||||
uint8_t *apdu, BACNET_OBJECT_TYPE *object_type,uint32_t *instance)
|
||||
uint8_t *apdu, BACNET_OBJECT_TYPE *object_type, uint32_t *instance)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
int len = 0;
|
||||
|
||||
len = decode_unsigned32(apdu, &value);
|
||||
*object_type = (BACNET_OBJECT_TYPE)
|
||||
(((value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
|
||||
*object_type = (BACNET_OBJECT_TYPE)(
|
||||
((value >> BACNET_INSTANCE_BITS) & BACNET_MAX_OBJECT));
|
||||
*instance = (value & BACNET_MAX_INSTANCE);
|
||||
|
||||
return len;
|
||||
@@ -866,14 +866,15 @@ int decode_context_object_id(uint8_t *apdu,
|
||||
|
||||
/* from clause 20.2.14 Encoding of an Object Identifier Value */
|
||||
/* returns the number of apdu bytes consumed */
|
||||
int encode_bacnet_object_id
|
||||
(uint8_t *apdu, BACNET_OBJECT_TYPE object_type, uint32_t instance)
|
||||
int encode_bacnet_object_id(
|
||||
uint8_t *apdu, BACNET_OBJECT_TYPE object_type, uint32_t instance)
|
||||
{
|
||||
uint32_t value = 0;
|
||||
int len = 0;
|
||||
|
||||
value = (((uint32_t)object_type & BACNET_MAX_OBJECT)
|
||||
<< BACNET_INSTANCE_BITS) | (instance & BACNET_MAX_INSTANCE);
|
||||
value =
|
||||
(((uint32_t)object_type & BACNET_MAX_OBJECT) << BACNET_INSTANCE_BITS) |
|
||||
(instance & BACNET_MAX_INSTANCE);
|
||||
len = encode_unsigned32(apdu, value);
|
||||
|
||||
return len;
|
||||
@@ -1313,8 +1314,10 @@ int decode_context_character_string(
|
||||
*
|
||||
* @return number of bytes decoded, or zero if errors occur
|
||||
*/
|
||||
int bacnet_unsigned_decode(
|
||||
uint8_t *apdu, uint16_t apdu_len_max, uint32_t len_value, BACNET_UNSIGNED_INTEGER *value)
|
||||
int bacnet_unsigned_decode(uint8_t *apdu,
|
||||
uint16_t apdu_len_max,
|
||||
uint32_t len_value,
|
||||
BACNET_UNSIGNED_INTEGER *value)
|
||||
{
|
||||
int len = 0;
|
||||
uint16_t unsigned16_value = 0;
|
||||
@@ -1388,8 +1391,10 @@ int bacnet_unsigned_decode(
|
||||
* @return number of bytes decoded, zero if wrong tag number,
|
||||
* or error (-1) if malformed
|
||||
*/
|
||||
int bacnet_unsigned_context_decode(
|
||||
uint8_t *apdu, uint16_t apdu_len_max, uint8_t tag_value, BACNET_UNSIGNED_INTEGER *value)
|
||||
int bacnet_unsigned_context_decode(uint8_t *apdu,
|
||||
uint16_t apdu_len_max,
|
||||
uint8_t tag_value,
|
||||
BACNET_UNSIGNED_INTEGER *value)
|
||||
{
|
||||
int apdu_len = 0;
|
||||
unsigned len = 0;
|
||||
@@ -1473,7 +1478,8 @@ int bacnet_unsigned_application_decode(
|
||||
*
|
||||
* @return number of bytes decoded, or zero if errors occur
|
||||
*/
|
||||
int decode_unsigned(uint8_t *apdu, uint32_t len_value, BACNET_UNSIGNED_INTEGER *value)
|
||||
int decode_unsigned(
|
||||
uint8_t *apdu, uint32_t len_value, BACNET_UNSIGNED_INTEGER *value)
|
||||
{
|
||||
#ifdef UINT64_MAX
|
||||
const uint16_t apdu_len_max = 8;
|
||||
@@ -1496,13 +1502,13 @@ int decode_unsigned(uint8_t *apdu, uint32_t len_value, BACNET_UNSIGNED_INTEGER *
|
||||
* @return number of bytes decoded, #BACNET_STATUS_ERROR (-1) if
|
||||
* wrong tag number, or error (-1) if malformed
|
||||
*/
|
||||
int decode_context_unsigned(uint8_t *apdu, uint8_t tag_value,
|
||||
BACNET_UNSIGNED_INTEGER *value)
|
||||
int decode_context_unsigned(
|
||||
uint8_t *apdu, uint8_t tag_value, BACNET_UNSIGNED_INTEGER *value)
|
||||
{
|
||||
#ifdef UINT64_MAX
|
||||
const uint16_t apdu_len_max = 3+8;
|
||||
const uint16_t apdu_len_max = 3 + 8;
|
||||
#else
|
||||
const uint16_t apdu_len_max = 2+4;
|
||||
const uint16_t apdu_len_max = 2 + 4;
|
||||
#endif
|
||||
int len = 0;
|
||||
|
||||
@@ -1552,7 +1558,8 @@ int encode_bacnet_unsigned(uint8_t *apdu, BACNET_UNSIGNED_INTEGER value)
|
||||
/* from clause 20.2.4 Encoding of an Unsigned Integer Value */
|
||||
/* and 20.2.1 General Rules for Encoding BACnet Tags */
|
||||
/* returns the number of apdu bytes consumed */
|
||||
int encode_context_unsigned(uint8_t *apdu, uint8_t tag_number, BACNET_UNSIGNED_INTEGER value)
|
||||
int encode_context_unsigned(
|
||||
uint8_t *apdu, uint8_t tag_number, BACNET_UNSIGNED_INTEGER value)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
@@ -1597,7 +1604,8 @@ int bacnet_enumerated_decode(
|
||||
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
|
||||
int len;
|
||||
|
||||
len = bacnet_unsigned_decode(apdu, apdu_len_max, len_value, &unsigned_value);
|
||||
len =
|
||||
bacnet_unsigned_decode(apdu, apdu_len_max, len_value, &unsigned_value);
|
||||
if (len > 0) {
|
||||
*value = unsigned_value;
|
||||
}
|
||||
@@ -2434,7 +2442,8 @@ int encode_bacnet_address(uint8_t *apdu, BACNET_ADDRESS *destination)
|
||||
|
||||
if (destination) {
|
||||
/* network number */
|
||||
apdu_len += encode_application_unsigned(&apdu[apdu_len], destination->net);
|
||||
apdu_len +=
|
||||
encode_application_unsigned(&apdu[apdu_len], destination->net);
|
||||
/* encode mac address as an octet-string */
|
||||
if (destination->len != 0) {
|
||||
octetstring_init(&mac_addr, destination->adr, destination->len);
|
||||
@@ -2450,7 +2459,8 @@ int encode_bacnet_address(uint8_t *apdu, BACNET_ADDRESS *destination)
|
||||
* Dencode a BACnetAddress and returns the number of apdu bytes consumed.
|
||||
*
|
||||
* @param apdu Receive buffer
|
||||
* @param destination Pointer to the destination address structure to be filled in.
|
||||
* @param destination Pointer to the destination address structure to be filled
|
||||
* in.
|
||||
*
|
||||
* @return number of apdu bytes consumed
|
||||
*/
|
||||
@@ -2765,7 +2775,8 @@ static void testBACDCodeDouble(Test *pTest)
|
||||
return;
|
||||
}
|
||||
|
||||
static void testBACDCodeUnsignedValue(Test *pTest, BACNET_UNSIGNED_INTEGER value)
|
||||
static void testBACDCodeUnsignedValue(
|
||||
Test *pTest, BACNET_UNSIGNED_INTEGER value)
|
||||
{
|
||||
uint8_t array[5] = { 0 };
|
||||
uint8_t encoded_array[5] = { 0 };
|
||||
|
||||
@@ -96,8 +96,7 @@ int bacapp_encode_device_obj_property_ref(
|
||||
* omit */
|
||||
if (value->deviceIdentifier.type == OBJECT_DEVICE) {
|
||||
len = encode_context_object_id(&apdu[apdu_len], 3,
|
||||
value->deviceIdentifier.type,
|
||||
value->deviceIdentifier.instance);
|
||||
value->deviceIdentifier.type, value->deviceIdentifier.instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
return apdu_len;
|
||||
@@ -231,8 +230,7 @@ int bacapp_encode_device_obj_ref(
|
||||
* omit */
|
||||
if (value->deviceIdentifier.type == OBJECT_DEVICE) {
|
||||
len = encode_context_object_id(&apdu[apdu_len], 0,
|
||||
value->deviceIdentifier.type,
|
||||
value->deviceIdentifier.instance);
|
||||
value->deviceIdentifier.type, value->deviceIdentifier.instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
/* object-identifier [1] BACnetObjectIdentifier */
|
||||
|
||||
+1
-3
@@ -300,9 +300,7 @@ bool characterstring_init(BACNET_CHARACTER_STRING *char_string,
|
||||
}
|
||||
|
||||
bool characterstring_init_ansi_safe(
|
||||
BACNET_CHARACTER_STRING * char_string,
|
||||
const char *value,
|
||||
size_t tmax)
|
||||
BACNET_CHARACTER_STRING *char_string, const char *value, size_t tmax)
|
||||
{
|
||||
return characterstring_init(char_string, CHARACTER_ANSI_X34, value,
|
||||
value ? strnlen(value, tmax) : 0);
|
||||
|
||||
@@ -45,7 +45,8 @@ static const char *Vendor_Proprietary_String = "Vendor Proprietary Value";
|
||||
|
||||
/* Search for a text value first based on the corresponding text list, then by
|
||||
* attempting to convert to an integer value. */
|
||||
static bool bactext_strtol_index(INDTEXT_DATA *istring, const char *search_name, unsigned *found_index)
|
||||
static bool bactext_strtol_index(
|
||||
INDTEXT_DATA *istring, const char *search_name, unsigned *found_index)
|
||||
{
|
||||
char *endptr;
|
||||
long value;
|
||||
@@ -934,13 +935,13 @@ INDTEXT_DATA bacnet_engineering_unit_names[] = {
|
||||
const char *bactext_engineering_unit_name(unsigned index)
|
||||
{
|
||||
if (index <= UNITS_RESERVED_RANGE_MAX) {
|
||||
return indtext_by_index_default(bacnet_engineering_unit_names,
|
||||
index, ASHRAE_Reserved_String);
|
||||
return indtext_by_index_default(
|
||||
bacnet_engineering_unit_names, index, ASHRAE_Reserved_String);
|
||||
} else if (index <= UNITS_PROPRIETARY_RANGE_MAX) {
|
||||
return Vendor_Proprietary_String;
|
||||
} else if (index <= UNITS_RESERVED_RANGE_MAX2) {
|
||||
return indtext_by_index_default(bacnet_engineering_unit_names,
|
||||
index, ASHRAE_Reserved_String);
|
||||
return indtext_by_index_default(
|
||||
bacnet_engineering_unit_names, index, ASHRAE_Reserved_String);
|
||||
} else if (index <= UNITS_PROPRIETARY_RANGE_MAX2) {
|
||||
return Vendor_Proprietary_String;
|
||||
}
|
||||
|
||||
@@ -1026,8 +1026,8 @@ void bvlc6_init(void)
|
||||
VMAC_Init();
|
||||
BVLC6_Result_Code = BVLC6_RESULT_SUCCESSFUL_COMPLETION;
|
||||
BVLC6_Function_Code = BVLC6_RESULT;
|
||||
bvlc6_address_set(&Remote_BBMD, 0, 0, 0, 0, 0, 0, 0,
|
||||
BIP6_MULTICAST_GROUP_ID);
|
||||
bvlc6_address_set(
|
||||
&Remote_BBMD, 0, 0, 0, 0, 0, 0, 0, BIP6_MULTICAST_GROUP_ID);
|
||||
#if defined(BACDL_BIP6) && BBMD6_ENABLED
|
||||
memset(&BBMD_Table, 0, sizeof(BBMD_Table));
|
||||
memset(&FD_Table, 0, sizeof(FD_Table));
|
||||
|
||||
@@ -121,7 +121,7 @@ bool address_match(BACNET_ADDRESS *dest, BACNET_ADDRESS *src)
|
||||
uint8_t max_len = 0;
|
||||
|
||||
if (dest == src) {
|
||||
return(true);
|
||||
return (true);
|
||||
}
|
||||
if (dest->mac_len != src->mac_len) {
|
||||
return false;
|
||||
@@ -624,7 +624,8 @@ void address_add(uint32_t device_id, unsigned max_apdu, BACNET_ADDRESS *src)
|
||||
}
|
||||
}
|
||||
|
||||
/* If adding has failed, see if we can squeeze it in by removed the oldest entry. */
|
||||
/* If adding has failed, see if we can squeeze it in by removed the oldest
|
||||
* entry. */
|
||||
if (!found) {
|
||||
pMatch = address_remove_oldest();
|
||||
if (pMatch != NULL) {
|
||||
@@ -775,8 +776,10 @@ void address_add_binding(
|
||||
*
|
||||
* @param index Table index [0..MAX_ADDRESS_CACHE-1]
|
||||
* @param device_id Pointer to the variable taking the device id.
|
||||
* @param device_ttl Pointer to the variable taking the Time To Life for the device.
|
||||
* @param max_apdu Pointer to the variable taking the max APDU size of the device.
|
||||
* @param device_ttl Pointer to the variable taking the Time To Life for the
|
||||
* device.
|
||||
* @param max_apdu Pointer to the variable taking the max APDU size of the
|
||||
* device.
|
||||
* @param src Pointer to the BACnet address.
|
||||
*
|
||||
* @return true/false
|
||||
@@ -818,7 +821,8 @@ bool address_device_get_by_index(unsigned index,
|
||||
*
|
||||
* @param index Table index [0..MAX_ADDRESS_CACHE-1]
|
||||
* @param device_id Pointer to the variable taking the device id.
|
||||
* @param max_apdu Pointer to the variable taking the max APDU size of the device.
|
||||
* @param max_apdu Pointer to the variable taking the max APDU size of the
|
||||
* device.
|
||||
* @param src Pointer to the BACnet address.
|
||||
*
|
||||
* @return true/false
|
||||
@@ -876,8 +880,9 @@ int address_list_encode(uint8_t *apdu, unsigned apdu_len)
|
||||
if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) ==
|
||||
BAC_ADDR_IN_USE) {
|
||||
iLen += encode_application_object_id(
|
||||
&apdu[iLen], OBJECT_DEVICE, pMatch->device_id);
|
||||
iLen += encode_application_unsigned(&apdu[iLen], pMatch->address.net);
|
||||
&apdu[iLen], OBJECT_DEVICE, pMatch->device_id);
|
||||
iLen +=
|
||||
encode_application_unsigned(&apdu[iLen], pMatch->address.net);
|
||||
if ((unsigned)iLen >= apdu_len) {
|
||||
break;
|
||||
}
|
||||
@@ -891,7 +896,8 @@ int address_list_encode(uint8_t *apdu, unsigned apdu_len)
|
||||
}
|
||||
octetstring_init(
|
||||
&MAC_Address, pMatch->address.adr, pMatch->address.len);
|
||||
iLen += encode_application_octet_string(&apdu[iLen], &MAC_Address);
|
||||
iLen +=
|
||||
encode_application_octet_string(&apdu[iLen], &MAC_Address);
|
||||
} else {
|
||||
/* MAC*/
|
||||
if ((unsigned)(iLen + pMatch->address.mac_len) >= apdu_len) {
|
||||
@@ -899,7 +905,8 @@ int address_list_encode(uint8_t *apdu, unsigned apdu_len)
|
||||
}
|
||||
octetstring_init(
|
||||
&MAC_Address, pMatch->address.mac, pMatch->address.mac_len);
|
||||
iLen += encode_application_octet_string(&apdu[iLen], &MAC_Address);
|
||||
iLen +=
|
||||
encode_application_octet_string(&apdu[iLen], &MAC_Address);
|
||||
}
|
||||
/* Any space left? */
|
||||
if ((unsigned)iLen >= apdu_len) {
|
||||
@@ -1030,7 +1037,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
pMatch++;
|
||||
/* Shall not happen as the count has been checked first. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
return(0); /* Issue with the table. */
|
||||
return (0); /* Issue with the table. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1045,7 +1052,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
}
|
||||
/* Shall not happen as the count has been checked first. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
return(0); /* Issue with the table. */
|
||||
return (0); /* Issue with the table. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1093,7 +1100,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
pMatch++;
|
||||
/* Can normally not happen. */
|
||||
if (pMatch > &Address_Cache[MAX_ADDRESS_CACHE - 1]) {
|
||||
return(0); /* Issue with the table. */
|
||||
return (0); /* Issue with the table. */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1116,7 +1123,8 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
|
||||
* is never called at all the whole cache is effectivly rendered static and
|
||||
* entries never expire unless explictely deleted.
|
||||
*
|
||||
* @param uSeconds Approximate number of seconds since last call to this function
|
||||
* @param uSeconds Approximate number of seconds since last call to this
|
||||
* function
|
||||
*/
|
||||
void address_cache_timer(uint16_t uSeconds)
|
||||
{
|
||||
|
||||
@@ -76,7 +76,8 @@ void npdu_handler(BACNET_ADDRESS *src, /* source address */
|
||||
|
||||
/* only handle the version that we know how to handle */
|
||||
if (pdu[0] == BACNET_PROTOCOL_VERSION) {
|
||||
apdu_offset = bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data);
|
||||
apdu_offset =
|
||||
bacnet_npdu_decode(&pdu[0], pdu_len, &dest, src, &npdu_data);
|
||||
if (npdu_data.network_layer_message) {
|
||||
/*FIXME: network layer message received! Handle it! */
|
||||
#if PRINT_ENABLED
|
||||
|
||||
@@ -44,28 +44,14 @@ struct object_data {
|
||||
static struct object_data Object_List[MAX_ACCUMULATORS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_SCALE,
|
||||
PROP_UNITS,
|
||||
PROP_MAX_PRES_VALUE,
|
||||
-1
|
||||
};
|
||||
static const int Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE, PROP_OUT_OF_SERVICE, PROP_SCALE, PROP_UNITS,
|
||||
PROP_MAX_PRES_VALUE, -1 };
|
||||
|
||||
static const int Properties_Optional[] = {
|
||||
PROP_DESCRIPTION,
|
||||
-1
|
||||
};
|
||||
static const int Properties_Optional[] = { PROP_DESCRIPTION, -1 };
|
||||
|
||||
static const int Properties_Proprietary[] = {
|
||||
-1
|
||||
};
|
||||
static const int Properties_Proprietary[] = { -1 };
|
||||
|
||||
/**
|
||||
* Returns the list of required, optional, and proprietary properties.
|
||||
@@ -79,9 +65,7 @@ static const int Properties_Proprietary[] = {
|
||||
* BACnet proprietary properties for this object.
|
||||
*/
|
||||
void Accumulator_Property_Lists(
|
||||
const int **pRequired,
|
||||
const int **pOptional,
|
||||
const int **pProprietary)
|
||||
const int **pRequired, const int **pOptional, const int **pProprietary)
|
||||
{
|
||||
if (pRequired)
|
||||
*pRequired = Properties_Required;
|
||||
@@ -100,8 +84,7 @@ void Accumulator_Property_Lists(
|
||||
*
|
||||
* @return true if the instance is valid, and false if not
|
||||
*/
|
||||
bool Accumulator_Valid_Instance(
|
||||
uint32_t object_instance)
|
||||
bool Accumulator_Valid_Instance(uint32_t object_instance)
|
||||
{
|
||||
if (object_instance < MAX_ACCUMULATORS)
|
||||
return true;
|
||||
@@ -141,8 +124,7 @@ uint32_t Accumulator_Index_To_Instance(unsigned index)
|
||||
* @return index for the given instance-number, or MAX_ACCUMULATORS
|
||||
* if not valid.
|
||||
*/
|
||||
unsigned Accumulator_Instance_To_Index(
|
||||
uint32_t object_instance)
|
||||
unsigned Accumulator_Instance_To_Index(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = MAX_ACCUMULATORS;
|
||||
|
||||
@@ -163,15 +145,14 @@ unsigned Accumulator_Instance_To_Index(
|
||||
* @return true if object-name was retrieved
|
||||
*/
|
||||
bool Accumulator_Object_Name(
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING * object_name)
|
||||
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
static char text_string[32]; /* okay for single thread */
|
||||
static char text_string[32]; /* okay for single thread */
|
||||
bool status = false;
|
||||
|
||||
if (object_instance < MAX_ACCUMULATORS) {
|
||||
sprintf(text_string, "ACCUMULATOR-%lu",
|
||||
(long unsigned int)object_instance);
|
||||
sprintf(
|
||||
text_string, "ACCUMULATOR-%lu", (long unsigned int)object_instance);
|
||||
status = characterstring_init_ansi(object_name, text_string);
|
||||
}
|
||||
|
||||
@@ -205,8 +186,7 @@ BACNET_UNSIGNED_INTEGER Accumulator_Present_Value(uint32_t object_instance)
|
||||
* @return true if values are within range and present-value is set.
|
||||
*/
|
||||
bool Accumulator_Present_Value_Set(
|
||||
uint32_t object_instance,
|
||||
BACNET_UNSIGNED_INTEGER value)
|
||||
uint32_t object_instance, BACNET_UNSIGNED_INTEGER value)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
@@ -233,7 +213,7 @@ uint16_t Accumulator_Units(uint32_t object_instance)
|
||||
units = UNITS_WATT_HOURS;
|
||||
}
|
||||
|
||||
return units;
|
||||
return units;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,7 +235,7 @@ int32_t Accumulator_Scale_Integer(uint32_t object_instance)
|
||||
scale = Object_List[object_instance].Scale;
|
||||
}
|
||||
|
||||
return scale;
|
||||
return scale;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -279,7 +259,7 @@ bool Accumulator_Scale_Integer_Set(uint32_t object_instance, int32_t scale)
|
||||
status = true;
|
||||
}
|
||||
|
||||
return status;
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +281,7 @@ BACNET_UNSIGNED_INTEGER Accumulator_Max_Pres_Value(uint32_t object_instance)
|
||||
max_value = BACNET_UNSIGNED_INTEGER_MAX;
|
||||
}
|
||||
|
||||
return max_value;
|
||||
return max_value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,10 +294,9 @@ BACNET_UNSIGNED_INTEGER Accumulator_Max_Pres_Value(uint32_t object_instance)
|
||||
* @return number of APDU bytes in the response, or
|
||||
* BACNET_STATUS_ERROR on error.
|
||||
*/
|
||||
int Accumulator_Read_Property(
|
||||
BACNET_READ_PROPERTY_DATA * rpdata)
|
||||
int Accumulator_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = 0; /* return value */
|
||||
int apdu_len = 0; /* return value */
|
||||
BACNET_BIT_STRING bit_string;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
uint8_t *apdu = NULL;
|
||||
@@ -327,11 +306,10 @@ int Accumulator_Read_Property(
|
||||
return 0;
|
||||
}
|
||||
apdu = rpdata->application_data;
|
||||
switch ((int) rpdata->object_property) {
|
||||
switch ((int)rpdata->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
apdu_len =
|
||||
encode_application_object_id(&apdu[0], OBJECT_ACCUMULATOR,
|
||||
rpdata->object_instance);
|
||||
apdu_len = encode_application_object_id(
|
||||
&apdu[0], OBJECT_ACCUMULATOR, rpdata->object_instance);
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_DESCRIPTION:
|
||||
@@ -340,21 +318,21 @@ int Accumulator_Read_Property(
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
break;
|
||||
case PROP_OBJECT_TYPE:
|
||||
apdu_len = encode_application_enumerated(&apdu[0], OBJECT_ACCUMULATOR);
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0], OBJECT_ACCUMULATOR);
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
apdu_len = encode_application_unsigned(&apdu[0],
|
||||
Accumulator_Present_Value(rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0], Accumulator_Present_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_SCALE:
|
||||
case PROP_SCALE:
|
||||
/* context tagged choice: [0]=REAL, [1]=INTEGER */
|
||||
apdu_len = encode_context_signed(&apdu[apdu_len], 1,
|
||||
apdu_len = encode_context_signed(&apdu[apdu_len], 1,
|
||||
Accumulator_Scale_Integer(rpdata->object_instance));
|
||||
break;
|
||||
break;
|
||||
case PROP_MAX_PRES_VALUE:
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0],
|
||||
Accumulator_Max_Pres_Value(rpdata->object_instance));
|
||||
apdu_len = encode_application_unsigned(
|
||||
&apdu[0], Accumulator_Max_Pres_Value(rpdata->object_instance));
|
||||
break;
|
||||
case PROP_STATUS_FLAGS:
|
||||
bitstring_init(&bit_string);
|
||||
@@ -372,7 +350,8 @@ int Accumulator_Read_Property(
|
||||
apdu_len = encode_application_boolean(&apdu[0], false);
|
||||
break;
|
||||
case PROP_UNITS:
|
||||
apdu_len = encode_application_enumerated(&apdu[0], Accumulator_Units(rpdata->object_instance));
|
||||
apdu_len = encode_application_enumerated(
|
||||
&apdu[0], Accumulator_Units(rpdata->object_instance));
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -398,16 +377,14 @@ int Accumulator_Read_Property(
|
||||
*
|
||||
* @return false if an error is loaded, true if no errors
|
||||
*/
|
||||
bool Accumulator_Write_Property(
|
||||
BACNET_WRITE_PROPERTY_DATA * wp_data)
|
||||
bool Accumulator_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
{
|
||||
int len = 0;
|
||||
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);
|
||||
len = bacapp_decode_application_data(
|
||||
wp_data->application_data, wp_data->application_data_len, &value);
|
||||
/* FIXME: len < application_data_len: more data? */
|
||||
if (len < 0) {
|
||||
/* error while decoding - a value larger than we can handle */
|
||||
@@ -427,7 +404,7 @@ bool Accumulator_Write_Property(
|
||||
case PROP_DESCRIPTION:
|
||||
case PROP_OBJECT_TYPE:
|
||||
case PROP_PRESENT_VALUE:
|
||||
case PROP_SCALE:
|
||||
case PROP_SCALE:
|
||||
case PROP_MAX_PRES_VALUE:
|
||||
case PROP_STATUS_FLAGS:
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -454,9 +431,9 @@ void Accumulator_Init(void)
|
||||
unsigned i = 0;
|
||||
|
||||
for (i = 0; i < MAX_ACCUMULATORS; i++) {
|
||||
Accumulator_Scale_Integer_Set(i, i+1);
|
||||
Accumulator_Scale_Integer_Set(i, i + 1);
|
||||
Accumulator_Present_Value_Set(i, unsigned_value);
|
||||
unsigned_value |= (unsigned_value<<1);
|
||||
unsigned_value |= (unsigned_value << 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,14 +443,13 @@ void Accumulator_Init(void)
|
||||
#include "ctest.h"
|
||||
#include "bactext.h"
|
||||
|
||||
void test_Accumulator(
|
||||
Test * pTest)
|
||||
void test_Accumulator(Test *pTest)
|
||||
{
|
||||
uint8_t apdu[MAX_APDU] = { 0 };
|
||||
int len = 0;
|
||||
int test_len = 0;
|
||||
BACNET_READ_PROPERTY_DATA rpdata = {0};
|
||||
BACNET_APPLICATION_DATA_VALUE value = {0};
|
||||
BACNET_READ_PROPERTY_DATA rpdata = { 0 };
|
||||
BACNET_APPLICATION_DATA_VALUE value = { 0 };
|
||||
const int *property = &Properties_Required[0];
|
||||
BACNET_UNSIGNED_INTEGER unsigned_value = 1;
|
||||
|
||||
@@ -489,11 +465,11 @@ void test_Accumulator(
|
||||
len = Accumulator_Read_Property(&rpdata);
|
||||
ct_test(pTest, len != 0);
|
||||
if (IS_CONTEXT_SPECIFIC(rpdata.application_data[0])) {
|
||||
test_len = bacapp_decode_context_data(rpdata.application_data,
|
||||
len, &value, rpdata.object_property);
|
||||
test_len = bacapp_decode_context_data(
|
||||
rpdata.application_data, len, &value, rpdata.object_property);
|
||||
} else {
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, len, &value);
|
||||
}
|
||||
if (len != test_len) {
|
||||
printf("property '%s': failed to decode!\n",
|
||||
@@ -508,17 +484,16 @@ void test_Accumulator(
|
||||
Accumulator_Present_Value_Set(0, unsigned_value);
|
||||
len = Accumulator_Read_Property(&rpdata);
|
||||
ct_test(pTest, len != 0);
|
||||
test_len = bacapp_decode_application_data(rpdata.application_data,
|
||||
len, &value);
|
||||
test_len = bacapp_decode_application_data(
|
||||
rpdata.application_data, len, &value);
|
||||
ct_test(pTest, len == test_len);
|
||||
unsigned_value |= (unsigned_value<<1);
|
||||
unsigned_value |= (unsigned_value << 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int main(
|
||||
void)
|
||||
int main(void)
|
||||
{
|
||||
Test *pTest;
|
||||
bool rc;
|
||||
@@ -530,7 +505,7 @@ int main(
|
||||
|
||||
ct_setStream(pTest, stdout);
|
||||
ct_run(pTest);
|
||||
(void) ct_report(pTest);
|
||||
(void)ct_report(pTest);
|
||||
ct_destroy(pTest);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -190,7 +190,7 @@ bool Access_Door_Present_Value_Set(
|
||||
index = Access_Door_Instance_To_Index(object_instance);
|
||||
if (index < MAX_ACCESS_DOORS) {
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */) &&
|
||||
(priority != 6 /* reserved */) &&
|
||||
(value <= DOOR_VALUE_EXTENDED_PULSE_UNLOCK)) {
|
||||
ad_descr[index].value_active[priority - 1] = true;
|
||||
ad_descr[index].priority_array[priority - 1] = value;
|
||||
@@ -467,7 +467,8 @@ bool Access_Door_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
algorithm and may not be used for other purposes in any
|
||||
object. */
|
||||
status = Access_Door_Present_Value_Set(wp_data->object_instance,
|
||||
(BACNET_DOOR_VALUE)value.type.Enumerated, wp_data->priority);
|
||||
(BACNET_DOOR_VALUE)value.type.Enumerated,
|
||||
wp_data->priority);
|
||||
if (wp_data->priority == 6) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
|
||||
@@ -64,7 +64,8 @@ static const int Analog_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
static const int Analog_Value_Properties_Proprietary[] = { -1 };
|
||||
|
||||
/**
|
||||
* Initialize the pointers for the required, the optional and the properitary value properties.
|
||||
* Initialize the pointers for the required, the optional and the properitary
|
||||
* value properties.
|
||||
*
|
||||
* @param pRequired - Pointer to the pointer of required values.
|
||||
* @param pOptional - Pointer to the pointer of optional values.
|
||||
@@ -477,7 +478,8 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_DESCRIPTION:
|
||||
if (Analog_Value_Object_Name(rpdata->object_instance, &char_string)) {
|
||||
if (Analog_Value_Object_Name(
|
||||
rpdata->object_instance, &char_string)) {
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
}
|
||||
@@ -667,7 +669,8 @@ int Analog_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
/**
|
||||
* Set the requested property of the analog value.
|
||||
*
|
||||
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA details.
|
||||
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA
|
||||
* details.
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
|
||||
@@ -63,7 +63,8 @@ static const int Binary_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
static const int Binary_Value_Properties_Proprietary[] = { -1 };
|
||||
|
||||
/**
|
||||
* Initialize the pointers for the required, the optional and the properitary value properties.
|
||||
* Initialize the pointers for the required, the optional and the properitary
|
||||
* value properties.
|
||||
*
|
||||
* @param pRequired - Pointer to the pointer of required values.
|
||||
* @param pOptional - Pointer to the pointer of optional values.
|
||||
@@ -302,7 +303,8 @@ int Binary_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
You could make Description writable and different */
|
||||
case PROP_OBJECT_NAME:
|
||||
case PROP_DESCRIPTION:
|
||||
if (Binary_Value_Object_Name(rpdata->object_instance, &char_string)) {
|
||||
if (Binary_Value_Object_Name(
|
||||
rpdata->object_instance, &char_string)) {
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
}
|
||||
@@ -405,7 +407,8 @@ int Binary_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
/**
|
||||
* Set the requested property of the binary value.
|
||||
*
|
||||
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA details.
|
||||
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA
|
||||
* details.
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
|
||||
@@ -115,9 +115,9 @@ static object_functions_t Object_Table[] = {
|
||||
Device_Count, Device_Index_To_Instance,
|
||||
Device_Valid_Object_Instance_Number, Device_Object_Name,
|
||||
Device_Read_Property_Local, NULL /* Write_Property */,
|
||||
Device_Property_Lists, NULL /* ReadRangeInfo */,
|
||||
NULL /* Iterator */, NULL /* Value_Lists */, NULL /* COV */,
|
||||
NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
Device_Property_Lists, NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
|
||||
NULL /* Intrinsic Reporting */ },
|
||||
#if (BACNET_PROTOCOL_REVISION >= 17)
|
||||
{ OBJECT_NETWORK_PORT, Network_Port_Init, Network_Port_Count,
|
||||
Network_Port_Index_To_Instance, Network_Port_Valid_Instance,
|
||||
@@ -225,8 +225,7 @@ static const int Device_Properties_Optional[] = {
|
||||
#if defined(BACDL_MSTP)
|
||||
PROP_MAX_MASTER, PROP_MAX_INFO_FRAMES,
|
||||
#endif
|
||||
PROP_DESCRIPTION, PROP_LOCATION, PROP_ACTIVE_COV_SUBSCRIPTIONS,
|
||||
-1
|
||||
PROP_DESCRIPTION, PROP_LOCATION, PROP_ACTIVE_COV_SUBSCRIPTIONS, -1
|
||||
};
|
||||
|
||||
static const int Device_Properties_Proprietary[] = { -1 };
|
||||
@@ -650,8 +649,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
* @param object_instance [in] The object instance number to be looked up.
|
||||
* @return True if found, else False if no such Object in this device.
|
||||
*/
|
||||
bool Device_Valid_Object_Id
|
||||
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
|
||||
bool Device_Valid_Object_Id(
|
||||
BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
struct object_functions *pObject = NULL;
|
||||
|
||||
@@ -204,8 +204,7 @@ int cl_decode_apdu(uint8_t *apdu,
|
||||
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);
|
||||
len = decode_unsigned(&apdu[dec_len], len_value_type, &unsigned_value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
@@ -229,8 +228,7 @@ int cl_decode_apdu(uint8_t *apdu,
|
||||
&apdu[dec_len], 4, &bcl->Value.type.Boolean);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
len = decode_context_unsigned(
|
||||
&apdu[dec_len], 4, &unsigned_value);
|
||||
len = decode_context_unsigned(&apdu[dec_len], 4, &unsigned_value);
|
||||
if (len < 0) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ static const int Properties_Optional[] = { PROP_EVENT_STATE,
|
||||
static const int Properties_Proprietary[] = { -1 };
|
||||
|
||||
/**
|
||||
* Initialize the pointers for the required, the optional and the properitary value properties.
|
||||
* Initialize the pointers for the required, the optional and the properitary
|
||||
* value properties.
|
||||
*
|
||||
* @param pRequired - Pointer to the pointer of required values.
|
||||
* @param pOptional - Pointer to the pointer of optional values.
|
||||
@@ -278,7 +279,8 @@ static char *CharacterString_Value_Description(uint32_t object_instance)
|
||||
* For a given object instance-number, set the description text.
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param new_descr - C-String pointer to the string, representing the description text
|
||||
* @param new_descr - C-String pointer to the string, representing the
|
||||
* description text
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
@@ -300,7 +302,8 @@ bool CharacterString_Value_Description_Set(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memset(&Object_Description[index][0], 0, sizeof(Object_Description[index]));
|
||||
memset(&Object_Description[index][0], 0,
|
||||
sizeof(Object_Description[index]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +314,8 @@ bool CharacterString_Value_Description_Set(
|
||||
* For a given object instance-number, return the object text.
|
||||
*
|
||||
* @param object_instance - object-instance number of the object
|
||||
* @param object_name - Pointer to the BACnet string object that shall take the object name
|
||||
* @param object_name - Pointer to the BACnet string object that shall take the
|
||||
* object name
|
||||
*
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
@@ -390,7 +394,8 @@ int CharacterString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
}
|
||||
|
||||
/* Valid object? */
|
||||
object_index = CharacterString_Value_Instance_To_Index(rpdata->object_instance);
|
||||
object_index =
|
||||
CharacterString_Value_Instance_To_Index(rpdata->object_instance);
|
||||
if (object_index >= MAX_CHARACTERSTRING_VALUES) {
|
||||
rpdata->error_class = ERROR_CLASS_OBJECT;
|
||||
rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
@@ -408,14 +413,15 @@ int CharacterString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
You could make Description writable and different */
|
||||
case PROP_OBJECT_NAME:
|
||||
if (CharacterString_Value_Object_Name(
|
||||
rpdata->object_instance, &char_string)) {
|
||||
rpdata->object_instance, &char_string)) {
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
}
|
||||
break;
|
||||
case PROP_DESCRIPTION:
|
||||
if (characterstring_init_ansi(&char_string,
|
||||
CharacterString_Value_Description(rpdata->object_instance))) {
|
||||
CharacterString_Value_Description(
|
||||
rpdata->object_instance))) {
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
}
|
||||
@@ -474,7 +480,8 @@ int CharacterString_Value_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
/**
|
||||
* Set the requested property of the character string value.
|
||||
*
|
||||
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA details.
|
||||
* @param wp_data Property requested, see for BACNET_WRITE_PROPERTY_DATA
|
||||
* details.
|
||||
*
|
||||
* @return true if successful
|
||||
*/
|
||||
@@ -504,7 +511,8 @@ bool CharacterString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
|
||||
/* Valid object? */
|
||||
object_index = CharacterString_Value_Instance_To_Index(wp_data->object_instance);
|
||||
object_index =
|
||||
CharacterString_Value_Instance_To_Index(wp_data->object_instance);
|
||||
if (object_index >= MAX_CHARACTERSTRING_VALUES) {
|
||||
wp_data->error_class = ERROR_CLASS_OBJECT;
|
||||
wp_data->error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||
|
||||
@@ -251,13 +251,12 @@ static object_functions_t My_Object_Table[] = {
|
||||
Schedule_Property_Lists, NULL /* ReadRangeInfo */, NULL /* Iterator */,
|
||||
NULL /* Value_Lists */, NULL /* COV */, NULL /* COV Clear */,
|
||||
NULL /* Intrinsic Reporting */ },
|
||||
{OBJECT_ACCUMULATOR, Accumulator_Init, Accumulator_Count,
|
||||
{ OBJECT_ACCUMULATOR, Accumulator_Init, Accumulator_Count,
|
||||
Accumulator_Index_To_Instance, Accumulator_Valid_Instance,
|
||||
Accumulator_Object_Name, Accumulator_Read_Property,
|
||||
Accumulator_Write_Property, Accumulator_Property_Lists,
|
||||
NULL /* ReadRangeInfo */ , NULL /* Iterator */ ,
|
||||
NULL /* Value_Lists */ , NULL /* COV */ , NULL /* COV Clear */ ,
|
||||
NULL /* Intrinsic Reporting */ },
|
||||
NULL /* ReadRangeInfo */, NULL /* Iterator */, NULL /* Value_Lists */,
|
||||
NULL /* COV */, NULL /* COV Clear */, NULL /* Intrinsic Reporting */ },
|
||||
{ MAX_BACNET_OBJECT_TYPE, NULL /* Init */, NULL /* Count */,
|
||||
NULL /* Index_To_Instance */, NULL /* Valid_Instance */,
|
||||
NULL /* Object_Name */, NULL /* Read_Property */,
|
||||
@@ -926,8 +925,8 @@ bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
* @param object_instance [in] The object instance number to be looked up.
|
||||
* @return True if found, else False if no such Object in this device.
|
||||
*/
|
||||
bool Device_Valid_Object_Id
|
||||
(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
|
||||
bool Device_Valid_Object_Id(
|
||||
BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
|
||||
{
|
||||
bool status = false; /* return value */
|
||||
struct object_functions *pObject = NULL;
|
||||
|
||||
@@ -1210,8 +1210,7 @@ static void Lighting_Output_Ramp_Handler(struct lighting_output_object *pLight,
|
||||
BACNET_LIGHTING_COMMAND *pCommand,
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
if (pLight && pCommand) {
|
||||
}
|
||||
if (pLight && pCommand) { }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1226,8 +1225,7 @@ static void Lighting_Output_Fade_Handler(struct lighting_output_object *pLight,
|
||||
BACNET_LIGHTING_COMMAND *pCommand,
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
if (pLight && pCommand) {
|
||||
}
|
||||
if (pLight && pCommand) { }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -933,8 +933,8 @@ bool Network_Port_IP_Subnet(
|
||||
if ((prefix > 0) && (prefix <= 32)) {
|
||||
mask = (0xFFFFFFFF << (32 - prefix)) & 0xFFFFFFFF;
|
||||
encode_unsigned32(ip_mask, mask);
|
||||
status = octetstring_init(subnet_mask, ip_mask,
|
||||
sizeof(ip_mask));
|
||||
status =
|
||||
octetstring_init(subnet_mask, ip_mask, sizeof(ip_mask));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1319,7 +1319,7 @@ bool Network_Port_BIP6_Mode_Set(uint32_t object_instance, BACNET_IP_MODE value)
|
||||
if (index < BACNET_NETWORK_PORTS_MAX) {
|
||||
if (Object_List[index].Network_Type == PORT_TYPE_BIP6) {
|
||||
if (Object_List[index].Network.IPv4.Mode != value) {
|
||||
Object_List[index].Changes_Pending = true;
|
||||
Object_List[index].Changes_Pending = true;
|
||||
}
|
||||
Object_List[index].Network.IPv6.Mode = value;
|
||||
status = true;
|
||||
@@ -1857,8 +1857,8 @@ int Network_Port_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
(rpdata->application_data_len == 0)) {
|
||||
return 0;
|
||||
}
|
||||
Network_Port_Property_List(rpdata->object_instance,
|
||||
&pRequired, &pOptional, &pProprietary);
|
||||
Network_Port_Property_List(
|
||||
rpdata->object_instance, &pRequired, &pOptional, &pProprietary);
|
||||
if ((!property_list_member(pRequired, rpdata->object_property)) &&
|
||||
(!property_list_member(pOptional, rpdata->object_property)) &&
|
||||
(!property_list_member(pProprietary, rpdata->object_property))) {
|
||||
|
||||
@@ -125,4 +125,3 @@ OBJECT_DEVICE_T *objects_device_delete(int index)
|
||||
}
|
||||
return pDevice;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,10 +89,8 @@ void Schedule_Init(void)
|
||||
psched->Present_Value = &psched->Schedule_Default;
|
||||
psched->Schedule_Default.context_specific = false;
|
||||
psched->Schedule_Default.tag = BACNET_APPLICATION_TAG_REAL;
|
||||
psched->Schedule_Default.type.Real =
|
||||
21.0; /* 21 C, room temperature */
|
||||
psched->obj_prop_ref_cnt =
|
||||
0; /* no references, add as needed */
|
||||
psched->Schedule_Default.type.Real = 21.0; /* 21 C, room temperature */
|
||||
psched->obj_prop_ref_cnt = 0; /* no references, add as needed */
|
||||
psched->Priority_For_Writing = 16; /* lowest priority */
|
||||
psched->Out_Of_Service = false;
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ AA_ABORT:
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -307,7 +307,8 @@ static error_function Error_Function[MAX_BACNET_CONFIRMED_SERVICE];
|
||||
* @brief Set a error handler function for the given confirmed service.
|
||||
*
|
||||
* @param service_choice Service, see SERVICE_CONFIRMED_X enumeration.
|
||||
* @param pFunction Pointer to the function, being in charge of the error handling.
|
||||
* @param pFunction Pointer to the function, being in charge of the error
|
||||
* handling.
|
||||
*/
|
||||
void apdu_set_error_handler(
|
||||
BACNET_CONFIRMED_SERVICE service_choice, error_function pFunction)
|
||||
@@ -374,7 +375,7 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t *apdu, /* APDU data */
|
||||
service_data->invoke_id = apdu[2];
|
||||
len = 3;
|
||||
if (service_data->segmented_message) {
|
||||
if (apdu_len >= (len+2)) {
|
||||
if (apdu_len >= (len + 2)) {
|
||||
service_data->sequence_number = apdu[len++];
|
||||
service_data->proposed_window_number = apdu[len++];
|
||||
} else {
|
||||
@@ -386,7 +387,7 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t *apdu, /* APDU data */
|
||||
*service_choice = apdu[len++];
|
||||
*service_request = NULL;
|
||||
*service_request_len = 0;
|
||||
} else if (apdu_len >= (len+2)) {
|
||||
} else if (apdu_len >= (len + 2)) {
|
||||
*service_choice = apdu[len++];
|
||||
*service_request = &apdu[len];
|
||||
*service_request_len = apdu_len - len;
|
||||
@@ -534,10 +535,11 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
service_request_len = apdu_len - 2;
|
||||
if (apdu_unconfirmed_dcc_disabled(service_choice)) {
|
||||
/* When network communications are disabled,
|
||||
only DeviceCommunicationControl and ReinitializeDevice
|
||||
APDUs shall be processed and no messages shall be
|
||||
initiated. If communications have been initiation
|
||||
disabled, then WhoIs may be processed. */
|
||||
only DeviceCommunicationControl and
|
||||
ReinitializeDevice APDUs shall be processed and no
|
||||
messages shall be initiated. If communications have
|
||||
been initiation disabled, then WhoIs may be
|
||||
processed. */
|
||||
break;
|
||||
}
|
||||
if (service_choice < MAX_BACNET_UNCONFIRMED_SERVICE) {
|
||||
@@ -573,7 +575,8 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
case SERVICE_CONFIRMED_VT_CLOSE:
|
||||
/* Security Services */
|
||||
case SERVICE_CONFIRMED_REQUEST_KEY:
|
||||
if (Confirmed_ACK_Function[service_choice] != NULL) {
|
||||
if (Confirmed_ACK_Function[service_choice] !=
|
||||
NULL) {
|
||||
((confirmed_simple_ack_function)
|
||||
Confirmed_ACK_Function[service_choice])(
|
||||
src, invoke_id);
|
||||
@@ -619,7 +622,8 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
case SERVICE_CONFIRMED_VT_DATA:
|
||||
/* Security Services */
|
||||
case SERVICE_CONFIRMED_AUTHENTICATE:
|
||||
if (Confirmed_ACK_Function[service_choice] != NULL) {
|
||||
if (Confirmed_ACK_Function[service_choice] !=
|
||||
NULL) {
|
||||
(Confirmed_ACK_Function[service_choice])(
|
||||
service_request, service_request_len, src,
|
||||
&service_ack_data);
|
||||
@@ -642,18 +646,20 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
service_choice = apdu[2];
|
||||
len = 3;
|
||||
|
||||
/* FIXME: Currently special case for C_P_T but there are others
|
||||
which may need consideration such as ChangeList-Error,
|
||||
CreateObject-Error, WritePropertyMultiple-Error and
|
||||
VTClose_Error but they may be left as is for now until
|
||||
support for these services is added */
|
||||
/* FIXME: Currently special case for C_P_T but there are
|
||||
others which may need consideration such as
|
||||
ChangeList-Error, CreateObject-Error,
|
||||
WritePropertyMultiple-Error and VTClose_Error but they
|
||||
may be left as is for now until support for these
|
||||
services is added */
|
||||
|
||||
if (service_choice ==
|
||||
SERVICE_CONFIRMED_PRIVATE_TRANSFER) { /* skip over
|
||||
opening tag 0 */
|
||||
opening tag 0
|
||||
*/
|
||||
if (decode_is_opening_tag_number(&apdu[len], 0)) {
|
||||
len++; /* a tag number of 0 is not extended so only one
|
||||
octet */
|
||||
len++; /* a tag number of 0 is not extended so only
|
||||
one octet */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -662,24 +668,30 @@ void apdu_handler(BACNET_ADDRESS *src,
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
|
||||
if (len < apdu_len) {
|
||||
/* FIXME: we could validate that the tag is enumerated... */
|
||||
len += decode_enumerated(&apdu[len], len_value, &error_class);
|
||||
/* FIXME: we could validate that the tag is
|
||||
* enumerated... */
|
||||
len += decode_enumerated(
|
||||
&apdu[len], len_value, &error_class);
|
||||
|
||||
if (len < apdu_len) {
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
|
||||
if (len < apdu_len) {
|
||||
/* FIXME: we could validate that the tag is enumerated... */
|
||||
len += decode_enumerated(&apdu[len], len_value, &error_code);
|
||||
/* FIXME: we could validate that the tag is
|
||||
* enumerated... */
|
||||
len += decode_enumerated(
|
||||
&apdu[len], len_value, &error_code);
|
||||
|
||||
if (service_choice ==
|
||||
SERVICE_CONFIRMED_PRIVATE_TRANSFER) {
|
||||
if (len < apdu_len) {
|
||||
/* skip over closing tag 0 */
|
||||
if (decode_is_closing_tag_number(&apdu[len], 0)) {
|
||||
len++; /* a tag number of 0 is not extended so
|
||||
only one octet */
|
||||
if (decode_is_closing_tag_number(
|
||||
&apdu[len], 0)) {
|
||||
len++; /* a tag number of 0 is
|
||||
not extended so only
|
||||
one octet */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +227,8 @@ GET_EVENT_ABORT:
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
|
||||
|
||||
@@ -111,8 +111,8 @@ LSO_ABORT:
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -208,9 +208,9 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
if (service_data->segmented_message) {
|
||||
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Segmented message. Sending Abort!\r\n");
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
/* decode apdu request & encode apdu reply
|
||||
encode complex ack, invoke id, service choice */
|
||||
@@ -219,16 +219,16 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
|
||||
for (;;) {
|
||||
/* Start by looking for an object ID */
|
||||
len = rpm_decode_object_id(
|
||||
&service_request[decode_len], service_len - decode_len, &rpmdata);
|
||||
len = rpm_decode_object_id(&service_request[decode_len],
|
||||
service_len - decode_len, &rpmdata);
|
||||
if (len >= 0) {
|
||||
/* Got one so skip to next stage */
|
||||
decode_len += len;
|
||||
} else {
|
||||
/* bad encoding - skip to error/reject/abort handling */
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Bad Encoding.\n");
|
||||
#endif
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break;
|
||||
@@ -242,14 +242,14 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
|
||||
/* Stick this object id into the reply - if it will fit */
|
||||
len = rpm_ack_encode_apdu_object_begin(&Temp_Buf[0], &rpmdata);
|
||||
copy_len =
|
||||
memcopy(&Handler_Transmit_Buffer[npdu_len], &Temp_Buf[0],
|
||||
apdu_len, len, MAX_APDU);
|
||||
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
if (copy_len == 0) {
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Response too big!\r\n");
|
||||
#endif
|
||||
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
#endif
|
||||
rpmdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break;
|
||||
@@ -259,16 +259,18 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
/* do each property of this object of the RPM request */
|
||||
for (;;) {
|
||||
/* Fetch a property */
|
||||
len = rpm_decode_object_property(&service_request[decode_len],
|
||||
service_len - decode_len, &rpmdata);
|
||||
len =
|
||||
rpm_decode_object_property(&service_request[decode_len],
|
||||
service_len - decode_len, &rpmdata);
|
||||
if (len < 0) {
|
||||
/* bad encoding - skip to error/reject/abort handling */
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Bad Encoding.\n");
|
||||
#endif
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both loops will be broken!
|
||||
break; // The berror flag ensures that both loops will
|
||||
// be broken!
|
||||
}
|
||||
decode_len += len;
|
||||
/* handle the special properties */
|
||||
@@ -281,43 +283,49 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
BACNET_PROPERTY_ID special_object_property;
|
||||
|
||||
if (rpmdata.array_index != BACNET_ARRAY_ALL) {
|
||||
|
||||
/* No array index options for this special property.
|
||||
Encode error for this object property response */
|
||||
len = rpm_ack_encode_apdu_object_property(&Temp_Buf[0],
|
||||
rpmdata.object_property, rpmdata.array_index);
|
||||
len = rpm_ack_encode_apdu_object_property(
|
||||
&Temp_Buf[0], rpmdata.object_property,
|
||||
rpmdata.array_index);
|
||||
|
||||
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
copy_len =
|
||||
memcopy(&Handler_Transmit_Buffer[npdu_len],
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
|
||||
if (copy_len == 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(
|
||||
stderr, "RPM: Too full to encode property!\r\n");
|
||||
#endif
|
||||
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both loops will be broken!
|
||||
}
|
||||
|
||||
apdu_len += len;
|
||||
len = rpm_ack_encode_apdu_object_property_error(
|
||||
&Temp_Buf[0], ERROR_CLASS_PROPERTY,
|
||||
ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY);
|
||||
|
||||
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
|
||||
if (copy_len == 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Too full to encode error!\r\n");
|
||||
#endif
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"RPM: Too full to encode property!\r\n");
|
||||
#endif
|
||||
rpmdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both loops will be broken!
|
||||
break; // The berror flag ensures that both
|
||||
// loops will be broken!
|
||||
}
|
||||
|
||||
apdu_len += len;
|
||||
len = rpm_ack_encode_apdu_object_property_error(
|
||||
&Temp_Buf[0], ERROR_CLASS_PROPERTY,
|
||||
ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY);
|
||||
|
||||
copy_len =
|
||||
memcopy(&Handler_Transmit_Buffer[npdu_len],
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
|
||||
if (copy_len == 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"RPM: Too full to encode error!\r\n");
|
||||
#endif
|
||||
rpmdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both
|
||||
// loops will be broken!
|
||||
}
|
||||
apdu_len += len;
|
||||
} else {
|
||||
@@ -328,65 +336,75 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
&property_list, special_object_property);
|
||||
|
||||
if (property_count == 0) {
|
||||
/* This only happens with the OPTIONAL property */
|
||||
/* This only happens with the OPTIONAL property
|
||||
*/
|
||||
/* 135-2016bl-2. Clarify ReadPropertyMultiple
|
||||
response on OPTIONAL when empty. */
|
||||
/* If no optional properties are supported then
|
||||
an empty 'List of Results' shall be returned
|
||||
for the specified property.*/
|
||||
} else {
|
||||
for (index = 0; index < property_count; index++) {
|
||||
rpmdata.object_property = RPM_Object_Property(
|
||||
&property_list, special_object_property, index);
|
||||
for (index = 0; index < property_count;
|
||||
index++) {
|
||||
rpmdata.object_property =
|
||||
RPM_Object_Property(&property_list,
|
||||
special_object_property, index);
|
||||
len = RPM_Encode_Property(
|
||||
&Handler_Transmit_Buffer[npdu_len],
|
||||
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
|
||||
&Handler_Transmit_Buffer[npdu_len],
|
||||
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(
|
||||
stderr, "RPM: Too full for property!\r\n");
|
||||
#endif
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"RPM: Too full for property!\r\n");
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both loops will be broken!
|
||||
break; // The berror flag ensures that
|
||||
// both loops will be broken!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* handle an individual property */
|
||||
len = RPM_Encode_Property(&Handler_Transmit_Buffer[npdu_len],
|
||||
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
|
||||
len = RPM_Encode_Property(
|
||||
&Handler_Transmit_Buffer[npdu_len],
|
||||
(uint16_t)apdu_len, MAX_APDU, &rpmdata);
|
||||
if (len > 0) {
|
||||
apdu_len += len;
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(
|
||||
stderr, "RPM: Too full for individual property!\r\n");
|
||||
#endif
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"RPM: Too full for individual property!\r\n");
|
||||
#endif
|
||||
error = len;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both loops will be broken!
|
||||
break; // The berror flag ensures that both loops
|
||||
// will be broken!
|
||||
}
|
||||
}
|
||||
|
||||
if (decode_is_closing_tag_number(&service_request[decode_len], 1)) {
|
||||
/* Reached end of property list so cap the result list */
|
||||
if (decode_is_closing_tag_number(
|
||||
&service_request[decode_len], 1)) {
|
||||
/* Reached end of property list so cap the result list
|
||||
*/
|
||||
decode_len++;
|
||||
len = rpm_ack_encode_apdu_object_end(&Temp_Buf[0]);
|
||||
copy_len = memcopy(&Handler_Transmit_Buffer[npdu_len],
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
&Temp_Buf[0], apdu_len, len, MAX_APDU);
|
||||
if (copy_len == 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Too full to encode object end!\r\n");
|
||||
#endif
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"RPM: Too full to encode object end!\r\n");
|
||||
#endif
|
||||
rpmdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
berror = true;
|
||||
break; // The berror flag ensures that both loops will be broken!
|
||||
break; // The berror flag ensures that both loops
|
||||
// will be broken!
|
||||
} else {
|
||||
apdu_len += copy_len;
|
||||
}
|
||||
@@ -406,11 +424,13 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
if (!berror) {
|
||||
if (apdu_len > service_data->max_resp) {
|
||||
/* too big for the sender - send an abort */
|
||||
rpmdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
rpmdata.error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
error = BACNET_STATUS_ABORT;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Message too large. Sending Abort!\n");
|
||||
#endif
|
||||
#if PRINT_ENABLED
|
||||
fprintf(
|
||||
stderr, "RPM: Message too large. Sending Abort!\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -419,34 +439,36 @@ void handler_read_property_multiple(uint8_t *service_request,
|
||||
if (error) {
|
||||
if (error == BACNET_STATUS_ABORT) {
|
||||
apdu_len = abort_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id,
|
||||
abort_convert_error_code(rpmdata.error_code), true);
|
||||
#if PRINT_ENABLED
|
||||
service_data->invoke_id,
|
||||
abort_convert_error_code(rpmdata.error_code), true);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Sending Abort!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else if (error == BACNET_STATUS_ERROR) {
|
||||
apdu_len = bacerror_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id, SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||
rpmdata.error_class, rpmdata.error_code);
|
||||
#if PRINT_ENABLED
|
||||
apdu_len = bacerror_encode_apdu(
|
||||
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
|
||||
SERVICE_CONFIRMED_READ_PROP_MULTIPLE, rpmdata.error_class,
|
||||
rpmdata.error_code);
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Sending Error!\n");
|
||||
#endif
|
||||
#endif
|
||||
} else if (error == BACNET_STATUS_REJECT) {
|
||||
apdu_len = reject_encode_apdu(&Handler_Transmit_Buffer[npdu_len],
|
||||
service_data->invoke_id,
|
||||
reject_convert_error_code(rpmdata.error_code));
|
||||
#if PRINT_ENABLED
|
||||
apdu_len = reject_encode_apdu(
|
||||
&Handler_Transmit_Buffer[npdu_len], service_data->invoke_id,
|
||||
reject_convert_error_code(rpmdata.error_code));
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Sending Reject!\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
pdu_len = apdu_len + npdu_len;
|
||||
bytes_sent = datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
bytes_sent = datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "RPM: Failed to send PDU (%s)!\n", strerror(errno));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,8 +293,7 @@ void rpm_ack_print_data(BACNET_READ_ACCESS_DATA *rpm_data)
|
||||
* @param rpm_data - #BACNET_READ_ACCESS_DATA
|
||||
* @return RPM data from the next element in the linked list
|
||||
*/
|
||||
static BACNET_READ_ACCESS_DATA *rpm_data_free(
|
||||
BACNET_READ_ACCESS_DATA *rpm_data)
|
||||
static BACNET_READ_ACCESS_DATA *rpm_data_free(BACNET_READ_ACCESS_DATA *rpm_data)
|
||||
{
|
||||
BACNET_READ_ACCESS_DATA *old_rpm_data = NULL;
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property = NULL;
|
||||
@@ -343,7 +342,7 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
|
||||
BACNET_CONFIRMED_SERVICE_ACK_DATA *service_data)
|
||||
{
|
||||
int len = 0;
|
||||
BACNET_READ_ACCESS_DATA * rpm_data;
|
||||
BACNET_READ_ACCESS_DATA *rpm_data;
|
||||
|
||||
(void)src;
|
||||
(void)service_data; /* we could use these... */
|
||||
@@ -358,9 +357,9 @@ void handler_read_property_multiple_ack(uint8_t *service_request,
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
}
|
||||
} else {
|
||||
#if 1
|
||||
#if 1
|
||||
fprintf(stderr, "RPM Ack Malformed! Freeing memory...\n");
|
||||
#endif
|
||||
#endif
|
||||
while (rpm_data) {
|
||||
rpm_data = rpm_data_free(rpm_data);
|
||||
}
|
||||
|
||||
@@ -185,8 +185,8 @@ RR_ABORT:
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
|
||||
|
||||
@@ -79,8 +79,8 @@ void handler_ucov_notification(
|
||||
#if PRINT_ENABLED
|
||||
len =
|
||||
#endif
|
||||
cov_notify_decode_service_request(
|
||||
service_request, service_len, &cov_data);
|
||||
cov_notify_decode_service_request(
|
||||
service_request, service_len, &cov_data);
|
||||
#if PRINT_ENABLED
|
||||
if (len > 0) {
|
||||
fprintf(stderr, "UCOV: PID=%u ", cov_data.subscriberProcessIdentifier);
|
||||
|
||||
@@ -98,7 +98,8 @@ void handler_write_property(uint8_t *service_request,
|
||||
#if PRINT_ENABLED
|
||||
if (len > 0)
|
||||
fprintf(stderr,
|
||||
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n",
|
||||
"WP: type=%lu instance=%lu property=%lu priority=%lu "
|
||||
"index=%ld\n",
|
||||
(unsigned long)wp_data.object_type,
|
||||
(unsigned long)wp_data.object_instance,
|
||||
(unsigned long)wp_data.object_property,
|
||||
@@ -137,7 +138,7 @@ void handler_write_property(uint8_t *service_request,
|
||||
/* Send PDU */
|
||||
pdu_len += len;
|
||||
bytes_sent = datalink_send_pdu(
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
if (bytes_sent <= 0) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "WP: Failed to send PDU (%s)!\n", strerror(errno));
|
||||
|
||||
@@ -90,8 +90,8 @@ uint8_t Send_Alarm_Acknowledgement(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Alarm Ack Request (%s)!\n",
|
||||
|
||||
@@ -97,8 +97,8 @@ uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send AtomicReadFile Request (%s)!\n",
|
||||
|
||||
@@ -99,8 +99,8 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -91,8 +91,8 @@ uint8_t Send_CEvent_Notify(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -103,8 +103,8 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -75,8 +75,8 @@ uint8_t Send_GetEvent(BACNET_ADDRESS *target_address,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
target_address, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(target_address, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -90,8 +90,8 @@ uint8_t Send_Life_Safety_Operation_Data(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Life Safe Op Request (%s)!\n",
|
||||
|
||||
@@ -100,8 +100,8 @@ uint8_t Send_Reinitialize_Device_Request(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -96,8 +96,8 @@ uint8_t Send_ReadRange_Request(uint32_t device_id, /* destination device */
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send ReadRange Request (%s)!\n",
|
||||
|
||||
@@ -103,7 +103,7 @@ uint8_t Send_Read_Property_Multiple_Request(uint8_t *pdu,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
|
||||
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -76,8 +76,8 @@ void Send_TimeSync_Remote(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send Time-Synchronization Request (%s)!\n",
|
||||
@@ -133,8 +133,8 @@ void Send_TimeSyncUTC_Remote(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -88,8 +88,8 @@ void Send_WhoHas_Name(
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(
|
||||
@@ -146,8 +146,8 @@ void Send_WhoHas_Object(int32_t low_limit,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(
|
||||
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(
|
||||
|
||||
@@ -104,7 +104,7 @@ uint8_t Send_Write_Property_Multiple_Request(uint8_t *pdu,
|
||||
#if PRINT_ENABLED
|
||||
bytes_sent =
|
||||
#endif
|
||||
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
|
||||
datalink_send_pdu(&dest, &npdu_data, &pdu[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0) {
|
||||
fprintf(stderr,
|
||||
|
||||
@@ -103,8 +103,7 @@ static int CheckArraySize(OS_Keylist list)
|
||||
}
|
||||
if (new_size) {
|
||||
/* Allocate more room for node pointer array */
|
||||
new_array = calloc((size_t)new_size,
|
||||
sizeof(struct Keylist_Node *));
|
||||
new_array = calloc((size_t)new_size, sizeof(struct Keylist_Node *));
|
||||
|
||||
/* See if we got the memory we wanted */
|
||||
if (!new_array) {
|
||||
@@ -453,7 +452,7 @@ int Keylist_Count(OS_Keylist list)
|
||||
cnt = list->count;
|
||||
}
|
||||
|
||||
return(cnt);
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
/******************************************************************** */
|
||||
|
||||
@@ -118,7 +118,7 @@ unsigned long mstimer_remaining(struct mstimer *t)
|
||||
*/
|
||||
unsigned long mstimer_elapsed(struct mstimer *t)
|
||||
{
|
||||
return mstimer_now() - t->start;
|
||||
return mstimer_now() - t->start;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -154,8 +154,7 @@ uint8_t tsm_transaction_idle_count(void)
|
||||
const BACNET_TSM_DATA *plist = TSM_List;
|
||||
|
||||
for (i = 0; i < MAX_TSM_TRANSACTIONS; i++, plist++) {
|
||||
if ((plist->InvokeID == 0) &&
|
||||
(plist->state == TSM_STATE_IDLE)) {
|
||||
if ((plist->InvokeID == 0) && (plist->state == TSM_STATE_IDLE)) {
|
||||
/* one is available! */
|
||||
count++;
|
||||
}
|
||||
|
||||
+4
-3
@@ -469,7 +469,7 @@ int cov_subscribe_decode_service_request(
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
/* tag 1 - monitoredObjectIdentifier */
|
||||
if ((unsigned) len >= apdu_len) {
|
||||
if ((unsigned)len >= apdu_len) {
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
if (decode_is_context_tag(&apdu[len], 1)) {
|
||||
@@ -496,11 +496,12 @@ int cov_subscribe_decode_service_request(
|
||||
data->cancellationRequest = true;
|
||||
}
|
||||
/* tag 3 - lifetime - optional */
|
||||
if ((unsigned) len < apdu_len) {
|
||||
if ((unsigned)len < apdu_len) {
|
||||
if (decode_is_context_tag(&apdu[len], 3)) {
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
len += decode_unsigned(&apdu[len], len_value, &unsigned_value);
|
||||
len +=
|
||||
decode_unsigned(&apdu[len], len_value, &unsigned_value);
|
||||
data->lifetime = unsigned_value;
|
||||
} else {
|
||||
data->lifetime = 0;
|
||||
|
||||
@@ -430,14 +430,15 @@ int encode_set_master_key(uint8_t *apdu, BACNET_SET_MASTER_KEY *set_master_key)
|
||||
// (uint32_t)(real_len - enc_begin), wrapper->signature)) {
|
||||
// return -SEC_RESP_MALFORMED_MESSAGE;
|
||||
// }
|
||||
// curr += decode_unsigned16(&apdu[real_len - 2], &wrapper->padding_len);
|
||||
// real_len -= wrapper->padding_len;
|
||||
// curr += decode_unsigned16(&apdu[real_len - 2],
|
||||
// &wrapper->padding_len); real_len -= wrapper->padding_len;
|
||||
// memcpy(wrapper->padding, &apdu[wrapper->padding_len],
|
||||
// wrapper->padding_len - 2);
|
||||
// }
|
||||
// /* destination device instance */
|
||||
// curr +=
|
||||
// decode_unsigned24(&apdu[curr], &wrapper->destination_device_instance);
|
||||
// decode_unsigned24(&apdu[curr],
|
||||
// &wrapper->destination_device_instance);
|
||||
// /* dst address */
|
||||
// curr += decode_unsigned16(&apdu[curr], &wrapper->dnet);
|
||||
// wrapper->dlen = apdu[curr++];
|
||||
|
||||
@@ -520,7 +520,6 @@ bool bvlc_broadcast_distribution_table_entry_forward_address(
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief J.2.2 Write-Broadcast-Distribution-Table: encode
|
||||
*
|
||||
@@ -1060,7 +1059,7 @@ bool bvlc_foreign_device_table_entry_add(
|
||||
a BBMD shall start a timer with a value equal to the
|
||||
Time-to-Live parameter supplied plus a fixed grace
|
||||
period of 30 seconds. */
|
||||
if (ttl_seconds < (UINT16_MAX-30)) {
|
||||
if (ttl_seconds < (UINT16_MAX - 30)) {
|
||||
fdt_entry->ttl_seconds_remaining = ttl_seconds + 30;
|
||||
} else {
|
||||
fdt_entry->ttl_seconds_remaining = UINT16_MAX;
|
||||
@@ -1077,7 +1076,7 @@ bool bvlc_foreign_device_table_entry_add(
|
||||
/* add to the first empty entry */
|
||||
bvlc_address_copy(&fdt_entry->dest_address, addr);
|
||||
fdt_entry->ttl_seconds = ttl_seconds;
|
||||
if (ttl_seconds < (UINT16_MAX-30)) {
|
||||
if (ttl_seconds < (UINT16_MAX - 30)) {
|
||||
fdt_entry->ttl_seconds_remaining = ttl_seconds + 30;
|
||||
} else {
|
||||
fdt_entry->ttl_seconds_remaining = UINT16_MAX;
|
||||
@@ -1756,8 +1755,8 @@ bool bvlc_address_different(
|
||||
* @param mask - B/IPv4 broadcast distribution mask
|
||||
* @return true if the addresses are different
|
||||
*/
|
||||
bool bvlc_address_mask(
|
||||
BACNET_IP_ADDRESS *dst, const BACNET_IP_ADDRESS *src,
|
||||
bool bvlc_address_mask(BACNET_IP_ADDRESS *dst,
|
||||
const BACNET_IP_ADDRESS *src,
|
||||
const BACNET_IP_BROADCAST_DISTRIBUTION_MASK *mask)
|
||||
{
|
||||
bool status = false;
|
||||
|
||||
+23
-32
@@ -1308,8 +1308,7 @@ int bvlc6_decode_delete_foreign_device(uint8_t *pdu,
|
||||
}
|
||||
offset += 3;
|
||||
if (bip6_address) {
|
||||
bvlc6_decode_address(
|
||||
&pdu[offset], pdu_len - offset, bip6_address);
|
||||
bvlc6_decode_address(&pdu[offset], pdu_len - offset, bip6_address);
|
||||
}
|
||||
bytes_consumed = (int)length;
|
||||
}
|
||||
@@ -1988,8 +1987,8 @@ static void test_BVLC6_Delete_Foreign_Device_Message(Test *pTest,
|
||||
ct_test(pTest, len == test_len);
|
||||
ct_test(pTest, msg_len == test_len);
|
||||
ct_test(pTest, vmac_src == test_vmac_src);
|
||||
test_BVLC6_Address(pTest, &fdt_entry->bip6_address,
|
||||
&test_fdt_entry.bip6_address);
|
||||
test_BVLC6_Address(
|
||||
pTest, &fdt_entry->bip6_address, &test_fdt_entry.bip6_address);
|
||||
}
|
||||
|
||||
static void test_BVLC6_Delete_Foreign_Device(Test *pTest)
|
||||
@@ -2161,48 +2160,40 @@ static void test_BVLC6_Address_Get_Set(Test *pTest)
|
||||
}
|
||||
/* test the ASCII hex to address */
|
||||
/* test too short */
|
||||
status = bvlc6_address_from_ascii(&src,"[1234:5678]");
|
||||
status = bvlc6_address_from_ascii(&src, "[1234:5678]");
|
||||
ct_test(pTest, status == false);
|
||||
status = bvlc6_address_from_ascii(&src,
|
||||
"[1234:5678:9ABC:DEF0:1234:5678:9ABC:DEF0]");
|
||||
status = bvlc6_address_from_ascii(
|
||||
&src, "[1234:5678:9ABC:DEF0:1234:5678:9ABC:DEF0]");
|
||||
ct_test(pTest, status);
|
||||
status = bvlc6_address_set(&dst,
|
||||
0x1234, 0x5678, 0x9ABC, 0xDEF0,
|
||||
0x1234, 0x5678, 0x9ABC, 0xDEF0);
|
||||
status = bvlc6_address_set(
|
||||
&dst, 0x1234, 0x5678, 0x9ABC, 0xDEF0, 0x1234, 0x5678, 0x9ABC, 0xDEF0);
|
||||
ct_test(pTest, status);
|
||||
status = bvlc6_address_different(&dst, &src);
|
||||
ct_test(pTest, status == false);
|
||||
/* test zero compression */
|
||||
status = bvlc6_address_from_ascii(&src,
|
||||
"[1234:5678:9ABC::5678:9ABC:DEF0]");
|
||||
status = bvlc6_address_from_ascii(&src, "[1234:5678:9ABC::5678:9ABC:DEF0]");
|
||||
ct_test(pTest, status);
|
||||
status = bvlc6_address_set(&dst,
|
||||
0x1234, 0x5678, 0x9ABC, 0x0000,
|
||||
0x0000, 0x5678, 0x9ABC, 0xDEF0);
|
||||
status = bvlc6_address_set(
|
||||
&dst, 0x1234, 0x5678, 0x9ABC, 0x0000, 0x0000, 0x5678, 0x9ABC, 0xDEF0);
|
||||
ct_test(pTest, status);
|
||||
status = bvlc6_address_different(&dst, &src);
|
||||
if (status) {
|
||||
status = bvlc6_address_get(
|
||||
&src, &hextet[0], &hextet[1], &hextet[2], &hextet[3],
|
||||
&hextet[4], &hextet[5], &hextet[6], &hextet[7]);
|
||||
printf("src:[%X:%X:%X:%X:%X:%X:%X:%X]\n",
|
||||
hextet[0], hextet[1], hextet[2], hextet[3],
|
||||
hextet[4], hextet[5], hextet[6], hextet[7]);
|
||||
status = bvlc6_address_get(
|
||||
&dst, &hextet[0], &hextet[1], &hextet[2], &hextet[3],
|
||||
&hextet[4], &hextet[5], &hextet[6], &hextet[7]);
|
||||
printf("dst:[%X:%X:%X:%X:%X:%X:%X:%X]\n",
|
||||
hextet[0], hextet[1], hextet[2], hextet[3],
|
||||
hextet[4], hextet[5], hextet[6], hextet[7]);
|
||||
status = bvlc6_address_get(&src, &hextet[0], &hextet[1], &hextet[2],
|
||||
&hextet[3], &hextet[4], &hextet[5], &hextet[6], &hextet[7]);
|
||||
printf("src:[%X:%X:%X:%X:%X:%X:%X:%X]\n", hextet[0], hextet[1],
|
||||
hextet[2], hextet[3], hextet[4], hextet[5], hextet[6], hextet[7]);
|
||||
status = bvlc6_address_get(&dst, &hextet[0], &hextet[1], &hextet[2],
|
||||
&hextet[3], &hextet[4], &hextet[5], &hextet[6], &hextet[7]);
|
||||
printf("dst:[%X:%X:%X:%X:%X:%X:%X:%X]\n", hextet[0], hextet[1],
|
||||
hextet[2], hextet[3], hextet[4], hextet[5], hextet[6], hextet[7]);
|
||||
}
|
||||
ct_test(pTest, status == false);
|
||||
/* test some compressed 16-bit zero fields */
|
||||
status = bvlc6_address_from_ascii(&src,
|
||||
"[234:678:ABC:EF0:1234:5678:9ABC:DEF0]");
|
||||
status =
|
||||
bvlc6_address_from_ascii(&src, "[234:678:ABC:EF0:1234:5678:9ABC:DEF0]");
|
||||
ct_test(pTest, status);
|
||||
status = bvlc6_address_set(&dst,
|
||||
0x0234, 0x0678, 0x0ABC, 0x0EF0,
|
||||
0x1234, 0x5678, 0x9ABC, 0xDEF0);
|
||||
status = bvlc6_address_set(
|
||||
&dst, 0x0234, 0x0678, 0x0ABC, 0x0EF0, 0x1234, 0x5678, 0x9ABC, 0xDEF0);
|
||||
ct_test(pTest, status);
|
||||
status = bvlc6_address_different(&dst, &src);
|
||||
ct_test(pTest, status == false);
|
||||
|
||||
+15
-20
@@ -63,8 +63,7 @@ static bool BIP_DL_Debug = false;
|
||||
* @param address - IPv4 address (uint32_t) of BBMD to register with,
|
||||
* in network byte order.
|
||||
*/
|
||||
void dlenv_bbmd_address_set(
|
||||
BACNET_IP_ADDRESS *address)
|
||||
void dlenv_bbmd_address_set(BACNET_IP_ADDRESS *address)
|
||||
{
|
||||
bvlc_address_copy(&BBMD_Address, address);
|
||||
BBMD_Address_Valid = true;
|
||||
@@ -121,7 +120,7 @@ int dlenv_register_as_foreign_device(void)
|
||||
char *pEnv = NULL;
|
||||
unsigned a[4] = { 0 };
|
||||
char bbmd_env[32] = "";
|
||||
unsigned entry_number = 0;\
|
||||
unsigned entry_number = 0;
|
||||
long long_value = 0;
|
||||
int c;
|
||||
|
||||
@@ -154,20 +153,16 @@ int dlenv_register_as_foreign_device(void)
|
||||
(unsigned)BBMD_Address.address[0],
|
||||
(unsigned)BBMD_Address.address[1],
|
||||
(unsigned)BBMD_Address.address[2],
|
||||
(unsigned)BBMD_Address.address[3],
|
||||
(unsigned)BBMD_Address.port,
|
||||
(unsigned)BBMD_Address.address[3], (unsigned)BBMD_Address.port,
|
||||
(unsigned)BBMD_TTL_Seconds);
|
||||
}
|
||||
retval = bvlc_register_with_bbmd(&BBMD_Address,
|
||||
BBMD_TTL_Seconds);
|
||||
retval = bvlc_register_with_bbmd(&BBMD_Address, BBMD_TTL_Seconds);
|
||||
if (retval < 0) {
|
||||
fprintf(stderr,
|
||||
"FAILED to Register with BBMD at %u.%u.%u.%u:%u\n",
|
||||
(unsigned)BBMD_Address.address[0],
|
||||
(unsigned)BBMD_Address.address[1],
|
||||
(unsigned)BBMD_Address.address[2],
|
||||
(unsigned)BBMD_Address.address[3],
|
||||
(unsigned)BBMD_Address.port);
|
||||
fprintf(stderr, "FAILED to Register with BBMD at %u.%u.%u.%u:%u\n",
|
||||
(unsigned)BBMD_Address.address[0],
|
||||
(unsigned)BBMD_Address.address[1],
|
||||
(unsigned)BBMD_Address.address[2],
|
||||
(unsigned)BBMD_Address.address[3], (unsigned)BBMD_Address.port);
|
||||
}
|
||||
BBMD_Timer_Seconds = (uint16_t)BBMD_TTL_Seconds;
|
||||
} else {
|
||||
@@ -176,8 +171,8 @@ int dlenv_register_as_foreign_device(void)
|
||||
sprintf(bbmd_env, "BACNET_BDT_ADDR_%u", entry_number);
|
||||
pEnv = getenv(bbmd_env);
|
||||
if (pEnv) {
|
||||
bdt_entry_valid = bip_get_addr_by_name(pEnv,
|
||||
&BBMD_Table_Entry.dest_address);
|
||||
bdt_entry_valid =
|
||||
bip_get_addr_by_name(pEnv, &BBMD_Table_Entry.dest_address);
|
||||
if (entry_number == 1) {
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr, "BBMD 1 is %s=%s!\n", bbmd_env, pEnv);
|
||||
@@ -211,15 +206,15 @@ int dlenv_register_as_foreign_device(void)
|
||||
pEnv, "%3u.%3u.%3u.%3u", &a[0], &a[1], &a[2], &a[3]);
|
||||
if (c == 4) {
|
||||
bvlc_broadcast_distribution_mask_set(
|
||||
&BBMD_Table_Entry.broadcast_mask,
|
||||
a[0], a[1], a[2], a[3]);
|
||||
&BBMD_Table_Entry.broadcast_mask, a[0], a[1], a[2],
|
||||
a[3]);
|
||||
}
|
||||
}
|
||||
bvlc_broadcast_distribution_table_entry_append(
|
||||
bvlc_bdt_list(), &BBMD_Table_Entry);
|
||||
if (BIP_DL_Debug) {
|
||||
fprintf(stderr,
|
||||
"BBMD %4u: %u.%u.%u.%u:%u %u.%u.%u.%u\n", entry_number,
|
||||
fprintf(stderr, "BBMD %4u: %u.%u.%u.%u:%u %u.%u.%u.%u\n",
|
||||
entry_number,
|
||||
(unsigned)BBMD_Table_Entry.dest_address.address[0],
|
||||
(unsigned)BBMD_Table_Entry.dest_address.address[1],
|
||||
(unsigned)BBMD_Table_Entry.dest_address.address[2],
|
||||
|
||||
+27
-35
@@ -561,12 +561,11 @@ static void seconds_since_midnight_into_hms(
|
||||
* @param btime [in] BACNET_TIME containing the time to convert
|
||||
*/
|
||||
void datetime_seconds_since_midnight_into_time(
|
||||
uint32_t seconds,
|
||||
BACNET_TIME *btime)
|
||||
uint32_t seconds, BACNET_TIME *btime)
|
||||
{
|
||||
if (btime) {
|
||||
seconds_since_midnight_into_hms(seconds,
|
||||
&btime->hour, &btime->min, &btime->sec);
|
||||
seconds_since_midnight_into_hms(
|
||||
seconds, &btime->hour, &btime->min, &btime->sec);
|
||||
btime->hundredths = 0;
|
||||
}
|
||||
}
|
||||
@@ -660,8 +659,7 @@ void datetime_add_minutes(BACNET_DATE_TIME *bdatetime, int32_t minutes)
|
||||
* @param bdatetime [in] the starting date and time
|
||||
* @return seconds since midnight
|
||||
*/
|
||||
uint64_t datetime_seconds_since_epoch(
|
||||
BACNET_DATE_TIME * bdatetime)
|
||||
uint64_t datetime_seconds_since_epoch(BACNET_DATE_TIME *bdatetime)
|
||||
{
|
||||
uint64_t seconds = 0;
|
||||
uint32_t days = 0;
|
||||
@@ -683,9 +681,7 @@ uint64_t datetime_seconds_since_epoch(
|
||||
* @param bdatetime [in] the starting date and time
|
||||
* @return seconds since midnight
|
||||
*/
|
||||
void datetime_since_epoch_seconds(
|
||||
BACNET_DATE_TIME * bdatetime,
|
||||
uint64_t seconds)
|
||||
void datetime_since_epoch_seconds(BACNET_DATE_TIME *bdatetime, uint64_t seconds)
|
||||
{
|
||||
uint32_t seconds_after_midnight = 0;
|
||||
uint32_t days = 0;
|
||||
@@ -1096,17 +1092,12 @@ int bacapp_decode_context_datetime(
|
||||
#include <string.h>
|
||||
#include "ctest.h"
|
||||
|
||||
static void datetime_print(const char *title,
|
||||
BACNET_DATE_TIME *bdatetime)
|
||||
static void datetime_print(const char *title, BACNET_DATE_TIME *bdatetime)
|
||||
{
|
||||
printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n",
|
||||
title,
|
||||
(unsigned int)bdatetime->date.year,
|
||||
(unsigned int)bdatetime->date.month,
|
||||
(unsigned int)bdatetime->date.wday,
|
||||
(unsigned int)bdatetime->time.hour,
|
||||
(unsigned int)bdatetime->time.min,
|
||||
(unsigned int)bdatetime->time.sec,
|
||||
printf("%s: %04u/%02u/%02u %02u:%02u:%02u.%03u\n", title,
|
||||
(unsigned int)bdatetime->date.year, (unsigned int)bdatetime->date.month,
|
||||
(unsigned int)bdatetime->date.wday, (unsigned int)bdatetime->time.hour,
|
||||
(unsigned int)bdatetime->time.min, (unsigned int)bdatetime->time.sec,
|
||||
(unsigned int)bdatetime->time.hundredths);
|
||||
}
|
||||
|
||||
@@ -1423,22 +1414,25 @@ static void testDayOfYear(Test *pTest)
|
||||
}
|
||||
|
||||
static void testDateEpochConversionCompare(Test *pTest,
|
||||
uint16_t year, uint8_t month, uint8_t day,
|
||||
uint8_t hour, uint8_t minute, uint8_t second, uint8_t hundredth)
|
||||
uint16_t year,
|
||||
uint8_t month,
|
||||
uint8_t day,
|
||||
uint8_t hour,
|
||||
uint8_t minute,
|
||||
uint8_t second,
|
||||
uint8_t hundredth)
|
||||
{
|
||||
uint64_t epoch_seconds = 0;
|
||||
BACNET_DATE_TIME bdatetime = {0};
|
||||
BACNET_DATE_TIME test_bdatetime = {0};
|
||||
BACNET_DATE_TIME bdatetime = { 0 };
|
||||
BACNET_DATE_TIME test_bdatetime = { 0 };
|
||||
int compare = 0;
|
||||
|
||||
datetime_set_date(&bdatetime.date, year, month, day);
|
||||
datetime_set_time(&bdatetime.time, hour, minute, second,
|
||||
hundredth);
|
||||
datetime_set_time(&bdatetime.time, hour, minute, second, hundredth);
|
||||
epoch_seconds = datetime_seconds_since_epoch(&bdatetime);
|
||||
datetime_since_epoch_seconds(&test_bdatetime,
|
||||
epoch_seconds);
|
||||
compare = datetime_compare(&bdatetime,&test_bdatetime);
|
||||
ct_test(pTest,compare == 0);
|
||||
datetime_since_epoch_seconds(&test_bdatetime, epoch_seconds);
|
||||
compare = datetime_compare(&bdatetime, &test_bdatetime);
|
||||
ct_test(pTest, compare == 0);
|
||||
if (compare != 0) {
|
||||
datetime_print("bdatetime", &bdatetime);
|
||||
datetime_print("test_bdatetime", &test_bdatetime);
|
||||
@@ -1448,14 +1442,12 @@ static void testDateEpochConversionCompare(Test *pTest,
|
||||
static void testDateEpochConversion(Test *pTest)
|
||||
{
|
||||
/* min */
|
||||
testDateEpochConversionCompare(pTest,
|
||||
BACNET_EPOCH_YEAR, 1, 1, 0, 0, 0, 0);
|
||||
testDateEpochConversionCompare(pTest, BACNET_EPOCH_YEAR, 1, 1, 0, 0, 0, 0);
|
||||
/* middle */
|
||||
testDateEpochConversionCompare(pTest,
|
||||
2020, 6, 26, 12, 30, 30, 0);
|
||||
testDateEpochConversionCompare(pTest, 2020, 6, 26, 12, 30, 30, 0);
|
||||
/* max */
|
||||
testDateEpochConversionCompare(pTest,
|
||||
BACNET_EPOCH_YEAR + 0xFF - 1, 12, 31, 23, 59, 59, 0);
|
||||
testDateEpochConversionCompare(
|
||||
pTest, BACNET_EPOCH_YEAR + 0xFF - 1, 12, 31, 23, 59, 59, 0);
|
||||
}
|
||||
|
||||
static void testDateEpoch(Test *pTest)
|
||||
|
||||
+4
-2
@@ -196,7 +196,8 @@ int dcc_encode_apdu(uint8_t *apdu,
|
||||
/* optional password */
|
||||
if (password) {
|
||||
if ((password->length >= 1) && (password->length <= 20)) {
|
||||
len = encode_context_character_string(&apdu[apdu_len], 2, password);
|
||||
len = encode_context_character_string(
|
||||
&apdu[apdu_len], 2, password);
|
||||
apdu_len += len;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +213,8 @@ int dcc_encode_apdu(uint8_t *apdu,
|
||||
* @param apdu Pointer to the received request.
|
||||
* @param apdu_len_max Valid count of bytes in the buffer.
|
||||
* @param timeDuration Pointer to the duration given in minutes [optional]
|
||||
* @param enable_disable Pointer to the variable takingthe communication enable/disable.
|
||||
* @param enable_disable Pointer to the variable takingthe communication
|
||||
* enable/disable.
|
||||
* @param password Pointer to the password [optional]
|
||||
*
|
||||
* @return Bytes decoded.
|
||||
|
||||
+19
-17
@@ -466,8 +466,8 @@ int event_notify_decode_service_request(
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* tag 6 - eventType */
|
||||
if ((section_length =
|
||||
decode_context_enumerated(&apdu[len], 6, &enum_value)) == -1) {
|
||||
if ((section_length = decode_context_enumerated(
|
||||
&apdu[len], 6, &enum_value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->eventType = (BACNET_EVENT_TYPE)enum_value;
|
||||
@@ -494,8 +494,8 @@ int event_notify_decode_service_request(
|
||||
}
|
||||
|
||||
/* tag 8 - notifyType */
|
||||
if ((section_length =
|
||||
decode_context_enumerated(&apdu[len], 8, &enum_value)) == -1) {
|
||||
if ((section_length = decode_context_enumerated(
|
||||
&apdu[len], 8, &enum_value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->notifyType = (BACNET_NOTIFY_TYPE)enum_value;
|
||||
@@ -529,8 +529,8 @@ int event_notify_decode_service_request(
|
||||
break;
|
||||
}
|
||||
/* tag 11 - toState */
|
||||
if ((section_length =
|
||||
decode_context_enumerated(&apdu[len], 11, &enum_value)) == -1) {
|
||||
if ((section_length = decode_context_enumerated(
|
||||
&apdu[len], 11, &enum_value)) == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
data->toState = (BACNET_EVENT_STATE)enum_value;
|
||||
@@ -770,24 +770,26 @@ int event_notify_decode_service_request(
|
||||
if (section_length > 0) {
|
||||
len += section_length;
|
||||
if (unsigned_value <= UINT32_MAX) {
|
||||
data->notificationParams.bufferReady.previousNotification =
|
||||
data->notificationParams.bufferReady
|
||||
.previousNotification =
|
||||
(uint32_t)unsigned_value;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
/* Tag 2 - currentNotification */
|
||||
/* Tag 2 - currentNotification */
|
||||
section_length = bacnet_unsigned_context_decode(
|
||||
&apdu[len], apdu_len - len, 2, &unsigned_value);
|
||||
if (section_length > 0) {
|
||||
len += section_length;
|
||||
if (unsigned_value <= UINT32_MAX) {
|
||||
data->notificationParams.bufferReady.currentNotification =
|
||||
data->notificationParams.bufferReady
|
||||
.currentNotification =
|
||||
(uint32_t)unsigned_value;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
@@ -801,10 +803,10 @@ int event_notify_decode_service_request(
|
||||
if (section_length > 0) {
|
||||
len += section_length;
|
||||
if (unsigned_value <= UINT32_MAX) {
|
||||
data->notificationParams.unsignedRange.exceedingValue =
|
||||
(uint32_t)unsigned_value;
|
||||
data->notificationParams.unsignedRange
|
||||
.exceedingValue = (uint32_t)unsigned_value;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
@@ -824,10 +826,10 @@ int event_notify_decode_service_request(
|
||||
if (section_length > 0) {
|
||||
len += section_length;
|
||||
if (unsigned_value <= UINT32_MAX) {
|
||||
data->notificationParams.unsignedRange.exceededLimit =
|
||||
(uint32_t)unsigned_value;
|
||||
data->notificationParams.unsignedRange
|
||||
.exceededLimit = (uint32_t)unsigned_value;
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
return BACNET_STATUS_ERROR;
|
||||
}
|
||||
} else {
|
||||
return BACNET_STATUS_ERROR;
|
||||
|
||||
@@ -93,7 +93,8 @@ int getevent_decode_service_request(uint8_t *apdu,
|
||||
return -1;
|
||||
}
|
||||
if (len < apdu_len) {
|
||||
len += decode_object_id(&apdu[len], &lastReceivedObjectIdentifier->type,
|
||||
len += decode_object_id(&apdu[len],
|
||||
&lastReceivedObjectIdentifier->type,
|
||||
&lastReceivedObjectIdentifier->instance);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -57,12 +57,12 @@ int ihave_encode_apdu(uint8_t *apdu, BACNET_I_HAVE_DATA *data)
|
||||
apdu[1] = SERVICE_UNCONFIRMED_I_HAVE;
|
||||
apdu_len = 2;
|
||||
/* deviceIdentifier */
|
||||
len = encode_application_object_id(&apdu[apdu_len],
|
||||
data->device_id.type, data->device_id.instance);
|
||||
len = encode_application_object_id(
|
||||
&apdu[apdu_len], data->device_id.type, data->device_id.instance);
|
||||
apdu_len += len;
|
||||
/* objectIdentifier */
|
||||
len = encode_application_object_id(&apdu[apdu_len],
|
||||
data->object_id.type, data->object_id.instance);
|
||||
len = encode_application_object_id(
|
||||
&apdu[apdu_len], data->object_id.type, data->object_id.instance);
|
||||
apdu_len += len;
|
||||
/* objectName */
|
||||
len = encode_application_character_string(
|
||||
|
||||
@@ -269,7 +269,7 @@ bool lighting_command_same(
|
||||
islessgreater(dst->target_level, src->target_level)) {
|
||||
status = false;
|
||||
}
|
||||
if ((dst->use_ramp_rate) &&
|
||||
if ((dst->use_ramp_rate) &&
|
||||
islessgreater(dst->ramp_rate, src->ramp_rate)) {
|
||||
status = false;
|
||||
}
|
||||
|
||||
+8
-5
@@ -286,7 +286,6 @@ void npdu_encode_npdu_data(BACNET_NPDU_DATA *npdu_data,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Decode the NPDU portion of a received message, particularly the NCPI byte.
|
||||
* The Network Layer Protocol Control Information byte is described
|
||||
* in section 6.2.2 of the BACnet standard.
|
||||
@@ -392,7 +391,8 @@ int bacnet_npdu_decode(uint8_t *npdu,
|
||||
if (npdu[1] & BIT(5)) {
|
||||
if (pdu_len >= (len + 3)) {
|
||||
len += decode_unsigned16(&npdu[len], &dest_net);
|
||||
/* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent */
|
||||
/* DLEN = 0 denotes broadcast MAC DADR and DADR field is absent
|
||||
*/
|
||||
/* DLEN > 0 specifies length of DADR field */
|
||||
dlen = npdu[len++];
|
||||
if (dest) {
|
||||
@@ -428,7 +428,8 @@ int bacnet_npdu_decode(uint8_t *npdu,
|
||||
if (npdu[1] & BIT(3)) {
|
||||
if (pdu_len >= (len + 3)) {
|
||||
len += decode_unsigned16(&npdu[len], &src_net);
|
||||
/* SLEN = 0 denotes broadcast MAC SADR and SADR field is absent */
|
||||
/* SLEN = 0 denotes broadcast MAC SADR and SADR field is absent
|
||||
*/
|
||||
/* SLEN > 0 specifies length of SADR field */
|
||||
slen = npdu[len++];
|
||||
if (src) {
|
||||
@@ -480,11 +481,13 @@ int bacnet_npdu_decode(uint8_t *npdu,
|
||||
if (pdu_len > len) {
|
||||
npdu_data->network_message_type =
|
||||
(BACNET_NETWORK_MESSAGE_TYPE)npdu[len++];
|
||||
/* Message Type field contains a value in the range 0x80 - 0xFF, */
|
||||
/* Message Type field contains a value in the range 0x80 - 0xFF,
|
||||
*/
|
||||
/* then a Vendor ID field shall be present */
|
||||
if (npdu_data->network_message_type >= 0x80) {
|
||||
if (pdu_len >= (len + 2)) {
|
||||
len += decode_unsigned16(&npdu[len], &npdu_data->vendor_id);
|
||||
len += decode_unsigned16(
|
||||
&npdu[len], &npdu_data->vendor_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+82
-48
@@ -59,7 +59,8 @@ static const int Access_Credential_Properties_Required[] = {
|
||||
PROP_GLOBAL_IDENTIFIER, PROP_STATUS_FLAGS, PROP_RELIABILITY,
|
||||
PROP_CREDENTIAL_STATUS, PROP_REASON_FOR_DISABLE,
|
||||
PROP_AUTHENTICATION_FACTORS, PROP_ACTIVATION_TIME, PROP_EXPIRATION_TIME,
|
||||
PROP_CREDENTIAL_DISABLE, PROP_ASSIGNED_ACCESS_RIGHTS, -1 };
|
||||
PROP_CREDENTIAL_DISABLE, PROP_ASSIGNED_ACCESS_RIGHTS, -1
|
||||
};
|
||||
|
||||
static const int Access_Credential_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_DAYS_REMAINING, PROP_USES_REMAINING, PROP_ABSENTEE_LIMIT,
|
||||
@@ -175,7 +176,8 @@ static const int Alert_Enrollment_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_EVENT_STATE, PROP_EVENT_DETECTION_ENABLE,
|
||||
PROP_NOTIFICATION_CLASS, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS,
|
||||
PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS, -1 };
|
||||
PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS, -1
|
||||
};
|
||||
|
||||
static const int Alert_Enrollment_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
|
||||
@@ -242,10 +244,11 @@ static const int Averaging_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_PROPERTY_REFERENCE, PROP_WINDOW_INTERVAL, PROP_WINDOW_SAMPLES,
|
||||
-1 };
|
||||
|
||||
static const int Averaging_Properties_Optional[] = {
|
||||
static const int Averaging_Properties_Optional[] = {
|
||||
PROP_MINIMUM_VALUE_TIMESTAMP, PROP_VARIANCE_VALUE,
|
||||
PROP_MAXIMUM_VALUE_TIMESTAMP, PROP_DESCRIPTION, PROP_TAGS,
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int Binary_Input_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
|
||||
@@ -269,7 +272,8 @@ static const int Binary_Lighting_Output_Properties_Required[] = {
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_OUT_OF_SERVICE,
|
||||
PROP_BLINK_WARN_ENABLE, PROP_EGRESS_TIME, PROP_EGRESS_ACTIVE,
|
||||
PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY,
|
||||
-1 };
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Lighting_Output_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_RELIABILITY, PROP_FEEDBACK_VALUE, PROP_POWER,
|
||||
@@ -280,7 +284,8 @@ static const int Binary_Lighting_Output_Properties_Optional[] = {
|
||||
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
|
||||
PROP_RELIABILITY_EVALUATION_INHIBIT, PROP_VALUE_SOURCE,
|
||||
PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME, PROP_COMMAND_TIME_ARRAY,
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int Binary_Output_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
|
||||
@@ -324,7 +329,8 @@ static const int Binary_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
|
||||
static const int BitString_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int BitString_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -343,8 +349,8 @@ static const int Calendar_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_DATE_LIST,
|
||||
-1 };
|
||||
|
||||
static const int Calendar_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
static const int Calendar_Properties_Optional[] = { PROP_DESCRIPTION, PROP_TAGS,
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
|
||||
static const int Channel_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_LAST_PRIORITY,
|
||||
@@ -358,8 +364,8 @@ static const int Channel_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE,
|
||||
PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
|
||||
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_RELIABILITY_EVALUATION_INHIBIT,
|
||||
PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME,
|
||||
-1 };
|
||||
|
||||
static const int Command_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_IN_PROCESS,
|
||||
@@ -375,7 +381,8 @@ static const int Command_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
|
||||
static const int CharacterString_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int CharacterString_Value_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -388,12 +395,14 @@ static const int CharacterString_Value_Properties_Optional[] = {
|
||||
PROP_TIME_DELAY_NORMAL, PROP_RELIABILITY_EVALUATION_INHIBIT,
|
||||
PROP_CURRENT_COMMAND_PRIORITY, PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY,
|
||||
PROP_LAST_COMMAND_TIME, PROP_COMMAND_TIME_ARRAY, PROP_TAGS,
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int Credential_Data_Input_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_RELIABILITY,
|
||||
PROP_OUT_OF_SERVICE, PROP_SUPPORTED_FORMATS, PROP_UPDATE_TIME, -1 };
|
||||
PROP_OUT_OF_SERVICE, PROP_SUPPORTED_FORMATS, PROP_UPDATE_TIME, -1
|
||||
};
|
||||
|
||||
static const int Credential_Data_Input_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_SUPPORTED_FORMAT_CLASSES,
|
||||
@@ -401,11 +410,13 @@ static const int Credential_Data_Input_Properties_Optional[] = {
|
||||
PROP_EVENT_STATE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE,
|
||||
PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
|
||||
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_RELIABILITY_EVALUATION_INHIBIT,
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int Date_Pattern_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int Date_Pattern_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -435,7 +446,8 @@ static const int Date_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
|
||||
static const int DateTime_Pattern_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int DateTime_Pattern_Value_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -446,11 +458,13 @@ static const int DateTime_Pattern_Value_Properties_Optional[] = {
|
||||
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_CURRENT_COMMAND_PRIORITY,
|
||||
PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME,
|
||||
PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_PROFILE_LOCATION,
|
||||
PROP_PROFILE_NAME, -1 };
|
||||
PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int DateTime_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int DateTime_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -496,7 +510,8 @@ static const int Device_Properties_Optional[] = { PROP_LOCATION,
|
||||
|
||||
static const int Elevator_Group_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_MACHINE_ROOM_ID, PROP_GROUP_ID, PROP_GROUP_MEMBERS, -1 };
|
||||
PROP_MACHINE_ROOM_ID, PROP_GROUP_ID, PROP_GROUP_MEMBERS, -1
|
||||
};
|
||||
|
||||
static const int Elevator_Group_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_GROUP_MODE, PROP_LANDING_CALLS, PROP_LANDING_CALL_CONTROL, PROP_TAGS,
|
||||
@@ -523,7 +538,8 @@ static const int Event_Enrollment_Properties_Required[] = {
|
||||
PROP_NOTIFY_TYPE, PROP_EVENT_PARAMETERS, PROP_OBJECT_PROPERTY_REFERENCE,
|
||||
PROP_EVENT_STATE, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS,
|
||||
PROP_NOTIFICATION_CLASS, PROP_EVENT_TIME_STAMPS,
|
||||
PROP_EVENT_DETECTION_ENABLE, PROP_STATUS_FLAGS, PROP_RELIABILITY, -1 };
|
||||
PROP_EVENT_DETECTION_ENABLE, PROP_STATUS_FLAGS, PROP_RELIABILITY, -1
|
||||
};
|
||||
|
||||
static const int Event_Enrollment_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_MESSAGE_TEXTS, PROP_EVENT_MESSAGE_TEXTS_CONFIG,
|
||||
@@ -552,8 +568,8 @@ static const int File_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_FILE_ACCESS_METHOD, -1 };
|
||||
|
||||
static const int File_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_RECORD_COUNT, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
PROP_RECORD_COUNT, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME,
|
||||
-1 };
|
||||
|
||||
static const int Global_Group_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_GROUP_MEMBERS, PROP_PRESENT_VALUE,
|
||||
@@ -600,7 +616,8 @@ static const int Integer_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
|
||||
static const int Large_Analog_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1
|
||||
};
|
||||
|
||||
static const int Large_Analog_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -645,7 +662,8 @@ static const int Lighting_Output_Properties_Required[] = {
|
||||
PROP_BLINK_WARN_ENABLE, PROP_EGRESS_TIME, PROP_EGRESS_ACTIVE,
|
||||
PROP_DEFAULT_FADE_TIME, PROP_DEFAULT_RAMP_RATE, PROP_DEFAULT_STEP_INCREMENT,
|
||||
PROP_PRIORITY_ARRAY, PROP_RELINQUISH_DEFAULT,
|
||||
PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, PROP_CURRENT_COMMAND_PRIORITY, -1 };
|
||||
PROP_LIGHTING_COMMAND_DEFAULT_PRIORITY, PROP_CURRENT_COMMAND_PRIORITY, -1
|
||||
};
|
||||
|
||||
static const int Lighting_Output_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_RELIABILITY, PROP_TRANSITION, PROP_FEEDBACK_VALUE, PROP_POWER,
|
||||
@@ -675,7 +693,8 @@ static const int Life_Safety_Point_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_MODE,
|
||||
PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED, -1 };
|
||||
PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED, -1
|
||||
};
|
||||
|
||||
static const int Life_Safety_Point_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_DEVICE_TYPE, PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS,
|
||||
@@ -694,18 +713,19 @@ static const int Life_Safety_Zone_Properties_Required[] = {
|
||||
PROP_PRESENT_VALUE, PROP_TRACKING_VALUE, PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE, PROP_MODE,
|
||||
PROP_ACCEPTED_MODES, PROP_SILENCED, PROP_OPERATION_EXPECTED,
|
||||
PROP_ZONE_MEMBERS, -1 };
|
||||
PROP_ZONE_MEMBERS, -1
|
||||
};
|
||||
|
||||
static const int Life_Safety_Zone_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_DEVICE_TYPE, PROP_TIME_DELAY,
|
||||
PROP_NOTIFICATION_CLASS, PROP_LIFE_SAFETY_ALARM_VALUES, PROP_ALARM_VALUES,
|
||||
PROP_FAULT_VALUES, PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS,
|
||||
PROP_NOTIFY_TYPE, PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
|
||||
static const int Life_Safety_Zone_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_DEVICE_TYPE, PROP_TIME_DELAY, PROP_NOTIFICATION_CLASS,
|
||||
PROP_LIFE_SAFETY_ALARM_VALUES, PROP_ALARM_VALUES, PROP_FAULT_VALUES,
|
||||
PROP_EVENT_ENABLE, PROP_ACKED_TRANSITIONS, PROP_NOTIFY_TYPE,
|
||||
PROP_EVENT_TIME_STAMPS, PROP_EVENT_MESSAGE_TEXTS,
|
||||
PROP_EVENT_MESSAGE_TEXTS_CONFIG, PROP_EVENT_DETECTION_ENABLE,
|
||||
PROP_EVENT_ALGORITHM_INHIBIT_REF, PROP_EVENT_ALGORITHM_INHIBIT,
|
||||
PROP_TIME_DELAY_NORMAL, PROP_MAINTENANCE_REQUIRED, PROP_MEMBER_OF,
|
||||
PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
PROP_VALUE_SOURCE, PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME,
|
||||
-1 };
|
||||
|
||||
static const int Loop_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
|
||||
@@ -732,7 +752,8 @@ static const int Loop_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
static const int Multistate_Input_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1 };
|
||||
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1
|
||||
};
|
||||
|
||||
static const int Multistate_Input_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_DEVICE_TYPE, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_TIME_DELAY,
|
||||
@@ -749,7 +770,8 @@ static const int Multistate_Output_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY, -1 };
|
||||
PROP_RELINQUISH_DEFAULT, PROP_CURRENT_COMMAND_PRIORITY, -1
|
||||
};
|
||||
|
||||
static const int Multistate_Output_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_DEVICE_TYPE, PROP_RELIABILITY, PROP_STATE_TEXT, PROP_TIME_DELAY,
|
||||
@@ -766,7 +788,8 @@ static const int Multistate_Output_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
static const int Multistate_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1 };
|
||||
PROP_OUT_OF_SERVICE, PROP_NUMBER_OF_STATES, -1
|
||||
};
|
||||
|
||||
static const int Multistate_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_RELIABILITY, PROP_STATE_TEXT, PROP_PRIORITY_ARRAY,
|
||||
@@ -819,7 +842,8 @@ static const int Network_Security_Properties_Required[] = {
|
||||
PROP_SECURITY_TIME_WINDOW, PROP_PACKET_REORDER_TIME,
|
||||
PROP_DISTRIBUTION_KEY_REVISION, PROP_KEY_SETS, PROP_LAST_KEY_SERVER,
|
||||
PROP_SECURITY_PDU_TIMEOUT, PROP_UPDATE_KEY_SET_TIMEOUT,
|
||||
PROP_SUPPORTED_SECURITY_ALGORITHM, PROP_DO_NOT_HIDE, -1 };
|
||||
PROP_SUPPORTED_SECURITY_ALGORITHM, PROP_DO_NOT_HIDE, -1
|
||||
};
|
||||
|
||||
static const int Network_Security_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
@@ -827,7 +851,8 @@ static const int Network_Security_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
static const int Notification_Class_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_NOTIFICATION_CLASS, PROP_PRIORITY, PROP_ACK_REQUIRED,
|
||||
PROP_RECIPIENT_LIST, -1 };
|
||||
PROP_RECIPIENT_LIST, -1
|
||||
};
|
||||
|
||||
static const int Notification_Class_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_RELIABILITY,
|
||||
@@ -840,15 +865,18 @@ static const int Notification_Forwarder_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_STATUS_FLAGS, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
PROP_RECIPIENT_LIST, PROP_SUBSCRIBED_RECIPIENTS,
|
||||
PROP_PROCESS_IDENTIFIER_FILTER, PROP_LOCAL_FORWARDING_ONLY, -1 };
|
||||
PROP_PROCESS_IDENTIFIER_FILTER, PROP_LOCAL_FORWARDING_ONLY, -1
|
||||
};
|
||||
|
||||
static const int Notification_Forwarder_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_PORT_FILTER, PROP_RELIABILITY_EVALUATION_INHIBIT,
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1 };
|
||||
PROP_TAGS, PROP_PROFILE_LOCATION, PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int OctetString_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int OctetString_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -860,7 +888,8 @@ static const int OctetString_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
|
||||
static const int Positive_Integer_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_UNITS, -1
|
||||
};
|
||||
|
||||
static const int Positive_Integer_Value_Properties_Optional[] = {
|
||||
PROP_DESCRIPTION, PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -875,7 +904,8 @@ static const int Positive_Integer_Value_Properties_Optional[] = {
|
||||
PROP_FAULT_HIGH_LIMIT, PROP_FAULT_LOW_LIMIT, PROP_CURRENT_COMMAND_PRIORITY,
|
||||
PROP_VALUE_SOURCE, PROP_VALUE_SOURCE_ARRAY, PROP_LAST_COMMAND_TIME,
|
||||
PROP_COMMAND_TIME_ARRAY, PROP_TAGS, PROP_PROFILE_LOCATION,
|
||||
PROP_PROFILE_NAME, -1 };
|
||||
PROP_PROFILE_NAME, -1
|
||||
};
|
||||
|
||||
static const int Program_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PROGRAM_STATE, PROP_PROGRAM_CHANGE,
|
||||
@@ -895,7 +925,8 @@ static const int Pulse_Converter_Properties_Required[] = {
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE, PROP_UNITS, PROP_SCALE_FACTOR, PROP_ADJUST_VALUE,
|
||||
PROP_COUNT, PROP_UPDATE_TIME, PROP_COUNT_CHANGE_TIME,
|
||||
PROP_COUNT_BEFORE_CHANGE, -1 };
|
||||
PROP_COUNT_BEFORE_CHANGE, -1
|
||||
};
|
||||
|
||||
static const int Pulse_Converter_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_INPUT_REFERENCE, PROP_RELIABILITY, PROP_COV_INCREMENT, PROP_COV_PERIOD,
|
||||
@@ -937,7 +968,8 @@ static const int Staging_Properties_Optional[] = { PROP_STAGE_NAMES,
|
||||
|
||||
static const int Structured_View_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_NODE_TYPE,
|
||||
PROP_SUBORDINATE_LIST, -1 };
|
||||
PROP_SUBORDINATE_LIST, -1
|
||||
};
|
||||
|
||||
static const int Structured_View_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_NODE_SUBTYPE, PROP_SUBORDINATE_ANNOTATIONS, PROP_SUBORDINATE_TAGS,
|
||||
@@ -947,7 +979,8 @@ static const int Structured_View_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
|
||||
static const int Time_Pattern_Value_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER, PROP_OBJECT_NAME, PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1 };
|
||||
PROP_PRESENT_VALUE, PROP_STATUS_FLAGS, -1
|
||||
};
|
||||
|
||||
static const int Time_Pattern_Value_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_EVENT_STATE, PROP_RELIABILITY, PROP_OUT_OF_SERVICE,
|
||||
@@ -1017,7 +1050,8 @@ static const int Trend_Log_Multiple_Properties_Required[] = {
|
||||
PROP_STATUS_FLAGS, PROP_EVENT_STATE, PROP_ENABLE,
|
||||
PROP_LOG_DEVICE_OBJECT_PROPERTY, PROP_LOGGING_TYPE, PROP_LOG_INTERVAL,
|
||||
PROP_STOP_WHEN_FULL, PROP_BUFFER_SIZE, PROP_LOG_BUFFER, PROP_RECORD_COUNT,
|
||||
PROP_TOTAL_RECORD_COUNT, -1 };
|
||||
PROP_TOTAL_RECORD_COUNT, -1
|
||||
};
|
||||
|
||||
static const int Trend_Log_Multiple_Properties_Optional[] = { PROP_DESCRIPTION,
|
||||
PROP_RELIABILITY, PROP_START_TIME, PROP_STOP_TIME, PROP_ALIGN_INTERVALS,
|
||||
|
||||
+4
-4
@@ -70,7 +70,8 @@ int rd_encode_apdu(uint8_t *apdu,
|
||||
if (password) {
|
||||
/* Must be at least 1 character, limited to 20 characters */
|
||||
if ((password->length >= 1) && (password->length <= 20)) {
|
||||
len = encode_context_character_string(&apdu[apdu_len], 1, password);
|
||||
len = encode_context_character_string(
|
||||
&apdu[apdu_len], 1, password);
|
||||
apdu_len += len;
|
||||
}
|
||||
}
|
||||
@@ -120,9 +121,8 @@ int rd_decode_service_request(uint8_t *apdu,
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (len < apdu_len) {
|
||||
if (password) {
|
||||
len += decode_character_string(&apdu[len],
|
||||
len_value_type,
|
||||
password);
|
||||
len += decode_character_string(
|
||||
&apdu[len], len_value_type, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-20
@@ -169,7 +169,7 @@ int rr_decode_service_request(
|
||||
rrdata->object_type = type;
|
||||
/* Tag 1: Property ID */
|
||||
if (len >= apdu_len) {
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
@@ -188,8 +188,8 @@ int rr_decode_service_request(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number == 2) {
|
||||
len += TagLen;
|
||||
len +=
|
||||
decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
len += decode_unsigned(
|
||||
&apdu[len], len_value_type, &unsigned_value);
|
||||
rrdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value;
|
||||
rrdata->Overhead +=
|
||||
RR_INDEX_OVERHEAD; /* Allow for this in the response */
|
||||
@@ -269,7 +269,7 @@ int rr_decode_service_request(
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
/* Allow for this in the response */
|
||||
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD;
|
||||
rrdata->Overhead += RR_1ST_SEQ_OVERHEAD;
|
||||
break;
|
||||
|
||||
case 7: /* ReadRange by time stamp */
|
||||
@@ -318,7 +318,7 @@ int rr_decode_service_request(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (int)len;
|
||||
@@ -434,15 +434,16 @@ int rr_ack_decode_service_request(uint8_t *apdu,
|
||||
return -1;
|
||||
}
|
||||
len = 1;
|
||||
len += decode_object_id(&apdu[len], &object_type, &rrdata->object_instance);
|
||||
len += decode_object_id(
|
||||
&apdu[len], &object_type, &rrdata->object_instance);
|
||||
rrdata->object_type = object_type;
|
||||
|
||||
/* Tag 1: Property ID */
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number != 1) {
|
||||
return -1;
|
||||
}
|
||||
@@ -453,8 +454,8 @@ int rr_ack_decode_service_request(uint8_t *apdu,
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
tag_len =
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
tag_len = decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number == 2) {
|
||||
len += tag_len;
|
||||
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
@@ -467,22 +468,23 @@ int rr_ack_decode_service_request(uint8_t *apdu,
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number != 3) {
|
||||
return -1;
|
||||
}
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
len += decode_bitstring(&apdu[len], len_value_type, &rrdata->ResultFlags);
|
||||
len +=
|
||||
decode_bitstring(&apdu[len], len_value_type, &rrdata->ResultFlags);
|
||||
|
||||
/* Tag 4: Item count */
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number != 4) {
|
||||
return -1;
|
||||
}
|
||||
@@ -496,8 +498,9 @@ int rr_ack_decode_service_request(uint8_t *apdu,
|
||||
}
|
||||
if (decode_is_opening_tag_number(&apdu[len], 5)) {
|
||||
len++; /* A tag number of 5 is not extended so only one octet
|
||||
* Setup the start position and length of the data returned from the
|
||||
* request don't decode the application tag number or its data here. */
|
||||
* Setup the start position and length of the data returned
|
||||
* from the request don't decode the application tag number
|
||||
* or its data here. */
|
||||
rrdata->application_data = &apdu[len];
|
||||
start_len = len;
|
||||
while (len < apdu_len) {
|
||||
@@ -511,8 +514,8 @@ int rr_ack_decode_service_request(uint8_t *apdu,
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], NULL, &len_value_type);
|
||||
len += len_value_type; /* Skip over data value as well */
|
||||
if (len >= apdu_len) { /* APDU is exhausted so we have failed to
|
||||
* find closing tag */
|
||||
if (len >= apdu_len) { /* APDU is exhausted so we have
|
||||
* failed to find closing tag */
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@@ -528,7 +531,8 @@ int rr_ack_decode_service_request(uint8_t *apdu,
|
||||
return -1;
|
||||
}
|
||||
if (len < apdu_len) {
|
||||
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
len += decode_unsigned(
|
||||
&apdu[len], len_value_type, &unsigned_value);
|
||||
rrdata->FirstSequence = (uint32_t)unsigned_value;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -289,8 +289,7 @@ static void testRejectErrorCode(Test *pTest)
|
||||
error_code = reject_convert_to_error_code(reject_reason);
|
||||
test_reject_reason = reject_convert_error_code(error_code);
|
||||
if (test_reject_reason != reject_reason) {
|
||||
printf("Reject: result=%u reject-code=%u\n",
|
||||
test_reject_reason,
|
||||
printf("Reject: result=%u reject-code=%u\n", test_reject_reason,
|
||||
reject_reason);
|
||||
}
|
||||
ct_test(pTest, test_reject_reason == reject_reason);
|
||||
|
||||
+10
-8
@@ -136,8 +136,8 @@ int rp_decode_service_request(
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if ((tag_number == 2) && (len < apdu_len)) {
|
||||
len +=
|
||||
decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
len += decode_unsigned(
|
||||
&apdu[len], len_value_type, &unsigned_value);
|
||||
rpdata->array_index = (BACNET_ARRAY_INDEX)unsigned_value;
|
||||
} else {
|
||||
rpdata->error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
@@ -283,14 +283,15 @@ int rp_ack_decode_service_request(uint8_t *apdu,
|
||||
return -1;
|
||||
}
|
||||
len = 1;
|
||||
len += decode_object_id(&apdu[len], &object_type, &rpdata->object_instance);
|
||||
len += decode_object_id(
|
||||
&apdu[len], &object_type, &rpdata->object_instance);
|
||||
rpdata->object_type = object_type;
|
||||
/* Tag 1: Property ID */
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
len +=
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number != 1) {
|
||||
return -1;
|
||||
}
|
||||
@@ -303,8 +304,8 @@ int rp_ack_decode_service_request(uint8_t *apdu,
|
||||
if (len >= apdu_len) {
|
||||
return -1;
|
||||
}
|
||||
tag_len =
|
||||
decode_tag_number_and_value(&apdu[len], &tag_number, &len_value_type);
|
||||
tag_len = decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number == 2) {
|
||||
len += tag_len;
|
||||
len += decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
@@ -323,7 +324,8 @@ int rp_ack_decode_service_request(uint8_t *apdu,
|
||||
rpdata->application_data = &apdu[len];
|
||||
/* Just to ensure we do not create a wrapped over value here. */
|
||||
if (len < apdu_len) {
|
||||
rpdata->application_data_len = apdu_len - len - 1 /*closing tag */;
|
||||
rpdata->application_data_len =
|
||||
apdu_len - len - 1 /*closing tag */;
|
||||
} else {
|
||||
rpdata->application_data_len = 0;
|
||||
}
|
||||
|
||||
+19
-15
@@ -98,8 +98,9 @@ int rpm_encode_apdu_object_begin(
|
||||
*
|
||||
* @return Bytes encoded or zero on error.
|
||||
*/
|
||||
int rpm_encode_apdu_object_property(
|
||||
uint8_t *apdu, BACNET_PROPERTY_ID object_property, BACNET_ARRAY_INDEX array_index)
|
||||
int rpm_encode_apdu_object_property(uint8_t *apdu,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
BACNET_ARRAY_INDEX array_index)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
@@ -160,8 +161,8 @@ int rpm_encode_apdu(uint8_t *apdu,
|
||||
apdu_len += len;
|
||||
rpm_object = read_access_data;
|
||||
while (rpm_object) {
|
||||
/* The encode function will return a length not more than 12. So the temp buffer
|
||||
* being 16 bytes is fine enought. */
|
||||
/* The encode function will return a length not more than 12. So the
|
||||
* temp buffer being 16 bytes is fine enought. */
|
||||
len = encode_context_object_id(&apdu_temp[0], 0,
|
||||
rpm_object->object_type, rpm_object->object_instance);
|
||||
len = (int)memcopy(&apdu[0], &apdu_temp[0], (size_t)apdu_len,
|
||||
@@ -180,9 +181,9 @@ int rpm_encode_apdu(uint8_t *apdu,
|
||||
apdu_len += len;
|
||||
rpm_property = rpm_object->listOfProperties;
|
||||
while (rpm_property) {
|
||||
/* The encode function will return a length not more than 12. So the temp buffer
|
||||
* being 16 bytes is fine enought.
|
||||
* Stuff as many properties into it as APDU length will allow. */
|
||||
/* The encode function will return a length not more than 12. So the
|
||||
* temp buffer being 16 bytes is fine enought. Stuff as many
|
||||
* properties into it as APDU length will allow. */
|
||||
len = encode_context_enumerated(
|
||||
&apdu_temp[0], 0, rpm_property->propertyIdentifier);
|
||||
len = (int)memcopy(&apdu[0], &apdu_temp[0], (size_t)apdu_len,
|
||||
@@ -341,8 +342,8 @@ int rpm_decode_object_property(
|
||||
ERROR_CODE_REJECT_MISSING_REQUIRED_PARAMETER;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
len +=
|
||||
decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
len += decode_unsigned(
|
||||
&apdu[len], len_value_type, &unsigned_value);
|
||||
rpmdata->array_index = unsigned_value;
|
||||
}
|
||||
}
|
||||
@@ -402,8 +403,9 @@ int rpm_ack_encode_apdu_object_begin(uint8_t *apdu, BACNET_RPM_DATA *rpmdata)
|
||||
*
|
||||
* @return Length of encoded bytes or 0 on failure.
|
||||
*/
|
||||
int rpm_ack_encode_apdu_object_property(
|
||||
uint8_t *apdu, BACNET_PROPERTY_ID object_property, BACNET_ARRAY_INDEX array_index)
|
||||
int rpm_ack_encode_apdu_object_property(uint8_t *apdu,
|
||||
BACNET_PROPERTY_ID object_property,
|
||||
BACNET_ARRAY_INDEX array_index)
|
||||
{
|
||||
int apdu_len = 0; /* total length of the apdu, return value */
|
||||
|
||||
@@ -412,7 +414,8 @@ int rpm_ack_encode_apdu_object_property(
|
||||
apdu_len = encode_context_enumerated(&apdu[0], 2, object_property);
|
||||
/* Tag 3: optional propertyArrayIndex */
|
||||
if (array_index != BACNET_ARRAY_ALL) {
|
||||
apdu_len += encode_context_unsigned(&apdu[apdu_len], 3, array_index);
|
||||
apdu_len +=
|
||||
encode_context_unsigned(&apdu[apdu_len], 3, array_index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,7 +425,8 @@ int rpm_ack_encode_apdu_object_property(
|
||||
/** Encode the object property value for an acknowledge of a RPM.
|
||||
*
|
||||
* @param apdu [in] Buffer of bytes to transmit.
|
||||
* @param application_data [in] Pointer to the application data used to fill in the APDU.
|
||||
* @param application_data [in] Pointer to the application data used to fill in
|
||||
* the APDU.
|
||||
* @param application_data_len [in] Length of the application data.
|
||||
*
|
||||
* @return Length of encoded bytes or 0 on failure.
|
||||
@@ -570,8 +574,8 @@ int rpm_ack_decode_object_property(uint8_t *apdu,
|
||||
&apdu[len], &tag_number, &len_value_type);
|
||||
if (tag_number == 3) {
|
||||
len += tag_len;
|
||||
len +=
|
||||
decode_unsigned(&apdu[len], len_value_type, &unsigned_value);
|
||||
len += decode_unsigned(
|
||||
&apdu[len], len_value_type, &unsigned_value);
|
||||
*array_index = unsigned_value;
|
||||
} else {
|
||||
*array_index = BACNET_ARRAY_ALL;
|
||||
|
||||
@@ -136,10 +136,10 @@ int timesync_decode_service_request(uint8_t *apdu,
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
if (tag_number == BACNET_APPLICATION_TAG_TIME) {
|
||||
if ((unsigned)(len + 4) <= apdu_len) {
|
||||
len += decode_bacnet_time(&apdu[len], my_time);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
len += decode_bacnet_time(&apdu[len], my_time);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ int timesync_encode_timesync_recipients(
|
||||
BACNET_RECIPIENT_LIST *pRecipient;
|
||||
|
||||
if ((!apdu) || (max_apdu < 1) || (!recipient)) {
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
pRecipient = recipient;
|
||||
|
||||
+5
-5
@@ -70,8 +70,7 @@ int whohas_encode_apdu(uint8_t *apdu, BACNET_WHO_HAS_DATA *data)
|
||||
apdu_len += len;
|
||||
} else {
|
||||
len = encode_context_object_id(&apdu[apdu_len], 2,
|
||||
data->object.identifier.type,
|
||||
data->object.identifier.instance);
|
||||
data->object.identifier.type, data->object.identifier.instance);
|
||||
apdu_len += len;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +111,8 @@ int whohas_decode_service_request(
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
if ((unsigned)len < apdu_len) {
|
||||
len += decode_unsigned(&apdu[len], len_value, &unsigned_value);
|
||||
len += decode_unsigned(
|
||||
&apdu[len], len_value, &unsigned_value);
|
||||
if (unsigned_value <= BACNET_MAX_INSTANCE) {
|
||||
data->high_limit = unsigned_value;
|
||||
}
|
||||
@@ -130,8 +130,8 @@ int whohas_decode_service_request(
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
if ((unsigned)len < apdu_len) {
|
||||
len += decode_object_id(
|
||||
&apdu[len], &decoded_type, &data->object.identifier.instance);
|
||||
len += decode_object_id(&apdu[len], &decoded_type,
|
||||
&data->object.identifier.instance);
|
||||
data->object.identifier.type = decoded_type;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -95,7 +95,8 @@ int whois_decode_service_request(
|
||||
decode_unsigned(&apdu[len], len_value, &unsigned_value);
|
||||
if (unsigned_value <= BACNET_MAX_INSTANCE) {
|
||||
if (pHigh_limit) {
|
||||
*pHigh_limit = (int32_t)unsigned_value;;
|
||||
*pHigh_limit = (int32_t)unsigned_value;
|
||||
;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -154,8 +154,8 @@ int wp_decode_service_request(
|
||||
return -1;
|
||||
}
|
||||
/* determine the length of the data blob */
|
||||
imax = bacapp_data_len( \
|
||||
&apdu[len], apdu_len - len, (BACNET_PROPERTY_ID)property);
|
||||
imax = bacapp_data_len(
|
||||
&apdu[len], apdu_len - len, (BACNET_PROPERTY_ID)property);
|
||||
if (imax == BACNET_STATUS_ERROR) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
+11
-9
@@ -147,8 +147,8 @@ int wpm_decode_object_property(
|
||||
/* tag 2 - Property Value */
|
||||
if ((tag_number == 2) && (decode_is_opening_tag(&apdu[len - 1]))) {
|
||||
len--;
|
||||
imax = bacapp_data_len(&apdu[len],
|
||||
(unsigned)(apdu_len - len), wp_data->object_property);
|
||||
imax = bacapp_data_len(&apdu[len], (unsigned)(apdu_len - len),
|
||||
wp_data->object_property);
|
||||
len++;
|
||||
|
||||
if (imax != BACNET_STATUS_ERROR) {
|
||||
@@ -165,7 +165,8 @@ int wpm_decode_object_property(
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
/* closing tag 2 */
|
||||
if ((tag_number != 2) && (decode_is_closing_tag(&apdu[len - 1]))) {
|
||||
if ((tag_number != 2) &&
|
||||
(decode_is_closing_tag(&apdu[len - 1]))) {
|
||||
wp_data->error_code = ERROR_CODE_REJECT_INVALID_TAG;
|
||||
return BACNET_STATUS_REJECT;
|
||||
}
|
||||
@@ -184,7 +185,8 @@ int wpm_decode_object_property(
|
||||
|
||||
/* tag 3 - Priority - optional */
|
||||
if (len < apdu_len) {
|
||||
len += decode_tag_number_and_value(&apdu[len], &tag_number, &len_value);
|
||||
len += decode_tag_number_and_value(
|
||||
&apdu[len], &tag_number, &len_value);
|
||||
if (tag_number == 3) {
|
||||
len += decode_unsigned(&apdu[len], len_value, &unsigned_value);
|
||||
wp_data->priority = (uint8_t)unsigned_value;
|
||||
@@ -298,8 +300,8 @@ int wpm_encode_apdu_object_property(
|
||||
apdu_len += encode_closing_tag(&apdu[apdu_len], 2);
|
||||
if (wpdata->priority != BACNET_NO_PRIORITY) {
|
||||
if (apdu_len < MAX_APDU) {
|
||||
apdu_len +=
|
||||
encode_context_unsigned(&apdu[apdu_len], 3, wpdata->priority);
|
||||
apdu_len += encode_context_unsigned(
|
||||
&apdu[apdu_len], 3, wpdata->priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,9 +353,9 @@ int wpm_encode_apdu(uint8_t *apdu,
|
||||
wpdata.object_property = wpm_property->propertyIdentifier;
|
||||
wpdata.array_index = wpm_property->propertyArrayIndex;
|
||||
wpdata.priority = wpm_property->priority;
|
||||
usize = (size_t)bacapp_encode_data(&apdu_temp[0], &wpm_property->value);
|
||||
if (usize > sizeof(wpdata.application_data))
|
||||
{
|
||||
usize = (size_t)bacapp_encode_data(
|
||||
&apdu_temp[0], &wpm_property->value);
|
||||
if (usize > sizeof(wpdata.application_data)) {
|
||||
usize = sizeof(wpdata.application_data);
|
||||
}
|
||||
wpdata.application_data_len = (int)usize;
|
||||
|
||||
Reference in New Issue
Block a user