Add common functions for initializing the BACnet Application Value lists. Fixes problems with receiving Unconfirmed COV Notifications with more values to store than the stack has reserved in its value list.
This commit is contained in:
@@ -69,7 +69,6 @@ void handler_ccov_notification(
|
||||
BACNET_COV_DATA cov_data;
|
||||
BACNET_PROPERTY_VALUE property_value[MAX_COV_PROPERTIES];
|
||||
BACNET_PROPERTY_VALUE *pProperty_value = NULL;
|
||||
unsigned index = 0;
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
@@ -77,16 +76,7 @@ void handler_ccov_notification(
|
||||
|
||||
/* create linked list to store data if more
|
||||
than one property value is expected */
|
||||
pProperty_value = &property_value[0];
|
||||
while (pProperty_value) {
|
||||
index++;
|
||||
if (index < MAX_COV_PROPERTIES) {
|
||||
pProperty_value->next = &property_value[index];
|
||||
} else {
|
||||
pProperty_value->next = NULL;
|
||||
}
|
||||
pProperty_value = pProperty_value->next;
|
||||
}
|
||||
bacapp_property_value_list_init(&property_value[0], MAX_COV_PROPERTIES);
|
||||
cov_data.listOfValues = &property_value[0];
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
#include "device.h"
|
||||
#include "handlers.h"
|
||||
|
||||
#ifndef MAX_COV_PROPERTIES
|
||||
#define MAX_COV_PROPERTIES 2
|
||||
#endif
|
||||
|
||||
/** @file h_cov.c Handles Change of Value (COV) services. */
|
||||
|
||||
typedef struct BACnet_COV_Address {
|
||||
@@ -616,7 +620,7 @@ bool handler_cov_fsm(
|
||||
uint32_t object_instance = 0;
|
||||
bool status = false;
|
||||
bool send = false;
|
||||
BACNET_PROPERTY_VALUE value_list[2];
|
||||
BACNET_PROPERTY_VALUE value_list[MAX_COV_PROPERTIES];
|
||||
/* states for transmitting */
|
||||
static enum {
|
||||
COV_STATE_IDLE = 0,
|
||||
@@ -716,8 +720,8 @@ bool handler_cov_fsm(
|
||||
fprintf(stderr, "COVtask: Sending...\n");
|
||||
#endif
|
||||
/* configure the linked list for the two properties */
|
||||
value_list[0].next = &value_list[1];
|
||||
value_list[1].next = NULL;
|
||||
bacapp_property_value_list_init(&value_list[0],
|
||||
MAX_COV_PROPERTIES);
|
||||
status = Device_Encode_Value_List(object_type,
|
||||
object_instance, &value_list[0]);
|
||||
if (status) {
|
||||
|
||||
@@ -66,22 +66,12 @@ void handler_ucov_notification(
|
||||
BACNET_PROPERTY_VALUE property_value[MAX_COV_PROPERTIES];
|
||||
BACNET_PROPERTY_VALUE *pProperty_value = NULL;
|
||||
int len = 0;
|
||||
unsigned index = 0;
|
||||
|
||||
/* src not needed for this application */
|
||||
src = src;
|
||||
/* create linked list to store data if more
|
||||
than one property value is expected */
|
||||
pProperty_value = &property_value[0];
|
||||
while (pProperty_value) {
|
||||
index++;
|
||||
if (index < MAX_COV_PROPERTIES) {
|
||||
pProperty_value->next = &property_value[index];
|
||||
} else {
|
||||
pProperty_value->next = NULL;
|
||||
}
|
||||
pProperty_value = pProperty_value->next;
|
||||
}
|
||||
bacapp_property_value_list_init(&property_value[0], MAX_COV_PROPERTIES);
|
||||
cov_data.listOfValues = &property_value[0];
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "UCOV: Received Notification!\n");
|
||||
|
||||
Reference in New Issue
Block a user