Fixed handler.

This commit is contained in:
skarg
2008-11-20 23:31:54 +00:00
parent 6072b98f1f
commit 815d8f8dbb
2 changed files with 45 additions and 18 deletions
+19 -5
View File
@@ -46,8 +46,13 @@ void handler_ucov_notification(
BACNET_ADDRESS * src)
{
BACNET_COV_DATA cov_data;
BACNET_PROPERTY_VALUE property_value;
int len = 0;
/* create linked list to store data if more
than one property value is expected */
property_value.next = NULL;
cov_data.listOfValues = &property_value;
#if PRINT_ENABLED
fprintf(stderr, "UCOV: Received Notification!\n");
#endif
@@ -56,14 +61,23 @@ void handler_ucov_notification(
service_request, service_len, &cov_data);
#if PRINT_ENABLED
if (len > 0) {
fprintf(stderr,
"UCOV: PID=%u instance=%u %s %u time remaining=%u seconds\n",
cov_data.subscriberProcessIdentifier,
cov_data.initiatingDeviceIdentifier,
fprintf(stderr, "UCOV: PID=%u ",
cov_data.subscriberProcessIdentifier);
fprintf(stderr, "instance=%u ",
cov_data.initiatingDeviceIdentifier);
fprintf(stderr, "%s %u ",
bactext_object_type_name(
cov_data.monitoredObjectIdentifier.type),
cov_data.monitoredObjectIdentifier.instance,
cov_data.monitoredObjectIdentifier.instance);
fprintf(stderr, "time remaining=%u seconds ",
cov_data.timeRemaining);
fprintf(stderr, "%s ",
bactext_property_name(property_value.propertyIdentifier));
if (property_value.propertyArrayIndex != BACNET_ARRAY_ALL) {
fprintf(stderr, "%u ",
property_value.propertyArrayIndex);
}
fprintf(stderr, "\n");
} else {
fprintf(stderr, "UCOV: Unable to decode service request!\n");
}
+26 -13
View File
@@ -186,8 +186,9 @@ int cov_notify_decode_service_request(
&len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value);
data->subscriberProcessIdentifier = decoded_value;
} else
} else {
return -1;
}
/* tag 1 - initiatingDeviceIdentifier */
if (decode_is_context_tag(&apdu[len], 1)) {
len +=
@@ -196,10 +197,12 @@ int cov_notify_decode_service_request(
len +=
decode_object_id(&apdu[len], &decoded_type,
&data->initiatingDeviceIdentifier);
if (decoded_type != OBJECT_DEVICE)
if (decoded_type != OBJECT_DEVICE) {
return -1;
} else
}
} else {
return -1;
}
/* tag 2 - monitoredObjectIdentifier */
if (decode_is_context_tag(&apdu[len], 2)) {
len +=
@@ -209,8 +212,9 @@ int cov_notify_decode_service_request(
decode_object_id(&apdu[len], &decoded_type,
&data->monitoredObjectIdentifier.instance);
data->monitoredObjectIdentifier.type = decoded_type;
} else
} else {
return -1;
}
/* tag 3 - timeRemaining */
if (decode_is_context_tag(&apdu[len], 3)) {
len +=
@@ -218,11 +222,13 @@ int cov_notify_decode_service_request(
&len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value);
data->timeRemaining = decoded_value;
} else
} else {
return -1;
}
/* tag 4: opening context tag - listOfValues */
if (!decode_is_opening_tag_number(&apdu[len], 4))
if (!decode_is_opening_tag_number(&apdu[len], 4)) {
return -1;
}
/* a tag number of 4 is not extended so only one octet */
len++;
/* the first value includes a pointer to the next value, etc */
@@ -235,8 +241,9 @@ int cov_notify_decode_service_request(
&len_value);
len += decode_enumerated(&apdu[len], len_value, &property);
value->propertyIdentifier = property;
} else
} else {
return -1;
}
/* tag 1 - propertyArrayIndex OPTIONAL */
if (decode_is_context_tag(&apdu[len], 1)) {
len +=
@@ -244,11 +251,13 @@ int cov_notify_decode_service_request(
&len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->propertyArrayIndex = decoded_value;
} else
} else {
value->propertyArrayIndex = BACNET_ARRAY_ALL;
}
/* tag 2: opening context tag - value */
if (!decode_is_opening_tag_number(&apdu[len], 2))
if (!decode_is_opening_tag_number(&apdu[len], 2)) {
return -1;
}
/* a tag number of 2 is not extended so only one octet */
len++;
len +=
@@ -256,8 +265,9 @@ int cov_notify_decode_service_request(
&value->value);
/* FIXME: check the return value; abort if no valid data? */
/* FIXME: there might be more than one data element in here! */
if (!decode_is_closing_tag_number(&apdu[len], 2))
if (!decode_is_closing_tag_number(&apdu[len], 2)) {
return -1;
}
/* a tag number of 2 is not extended so only one octet */
len++;
/* tag 3 - priority OPTIONAL */
@@ -267,16 +277,19 @@ int cov_notify_decode_service_request(
&len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->priority = decoded_value;
} else
} else {
value->priority = BACNET_NO_PRIORITY;
}
/* end of list? */
if (decode_is_closing_tag_number(&apdu[len], 4))
if (decode_is_closing_tag_number(&apdu[len], 4)) {
break;
}
/* is there another one to decode? */
value = value->next;
/* out of room to store more values */
if (value == NULL)
if (value == NULL) {
return -1;
}
}
}