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_ADDRESS * src)
{ {
BACNET_COV_DATA cov_data; BACNET_COV_DATA cov_data;
BACNET_PROPERTY_VALUE property_value;
int len = 0; 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 #if PRINT_ENABLED
fprintf(stderr, "UCOV: Received Notification!\n"); fprintf(stderr, "UCOV: Received Notification!\n");
#endif #endif
@@ -56,14 +61,23 @@ void handler_ucov_notification(
service_request, service_len, &cov_data); service_request, service_len, &cov_data);
#if PRINT_ENABLED #if PRINT_ENABLED
if (len > 0) { if (len > 0) {
fprintf(stderr, fprintf(stderr, "UCOV: PID=%u ",
"UCOV: PID=%u instance=%u %s %u time remaining=%u seconds\n", cov_data.subscriberProcessIdentifier);
cov_data.subscriberProcessIdentifier, fprintf(stderr, "instance=%u ",
cov_data.initiatingDeviceIdentifier, cov_data.initiatingDeviceIdentifier);
fprintf(stderr, "%s %u ",
bactext_object_type_name( bactext_object_type_name(
cov_data.monitoredObjectIdentifier.type), cov_data.monitoredObjectIdentifier.type),
cov_data.monitoredObjectIdentifier.instance, cov_data.monitoredObjectIdentifier.instance);
fprintf(stderr, "time remaining=%u seconds ",
cov_data.timeRemaining); 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 { } else {
fprintf(stderr, "UCOV: Unable to decode service request!\n"); 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_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value); len += decode_unsigned(&apdu[len], len_value, &decoded_value);
data->subscriberProcessIdentifier = decoded_value; data->subscriberProcessIdentifier = decoded_value;
} else } else {
return -1; return -1;
}
/* tag 1 - initiatingDeviceIdentifier */ /* tag 1 - initiatingDeviceIdentifier */
if (decode_is_context_tag(&apdu[len], 1)) { if (decode_is_context_tag(&apdu[len], 1)) {
len += len +=
@@ -196,10 +197,12 @@ int cov_notify_decode_service_request(
len += len +=
decode_object_id(&apdu[len], &decoded_type, decode_object_id(&apdu[len], &decoded_type,
&data->initiatingDeviceIdentifier); &data->initiatingDeviceIdentifier);
if (decoded_type != OBJECT_DEVICE) if (decoded_type != OBJECT_DEVICE) {
return -1; return -1;
} else }
} else {
return -1; return -1;
}
/* tag 2 - monitoredObjectIdentifier */ /* tag 2 - monitoredObjectIdentifier */
if (decode_is_context_tag(&apdu[len], 2)) { if (decode_is_context_tag(&apdu[len], 2)) {
len += len +=
@@ -209,8 +212,9 @@ int cov_notify_decode_service_request(
decode_object_id(&apdu[len], &decoded_type, decode_object_id(&apdu[len], &decoded_type,
&data->monitoredObjectIdentifier.instance); &data->monitoredObjectIdentifier.instance);
data->monitoredObjectIdentifier.type = decoded_type; data->monitoredObjectIdentifier.type = decoded_type;
} else } else {
return -1; return -1;
}
/* tag 3 - timeRemaining */ /* tag 3 - timeRemaining */
if (decode_is_context_tag(&apdu[len], 3)) { if (decode_is_context_tag(&apdu[len], 3)) {
len += len +=
@@ -218,11 +222,13 @@ int cov_notify_decode_service_request(
&len_value); &len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value); len += decode_unsigned(&apdu[len], len_value, &decoded_value);
data->timeRemaining = decoded_value; data->timeRemaining = decoded_value;
} else } else {
return -1; return -1;
}
/* tag 4: opening context tag - listOfValues */ /* 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; return -1;
}
/* a tag number of 4 is not extended so only one octet */ /* a tag number of 4 is not extended so only one octet */
len++; len++;
/* the first value includes a pointer to the next value, etc */ /* the first value includes a pointer to the next value, etc */
@@ -235,8 +241,9 @@ int cov_notify_decode_service_request(
&len_value); &len_value);
len += decode_enumerated(&apdu[len], len_value, &property); len += decode_enumerated(&apdu[len], len_value, &property);
value->propertyIdentifier = property; value->propertyIdentifier = property;
} else } else {
return -1; return -1;
}
/* tag 1 - propertyArrayIndex OPTIONAL */ /* tag 1 - propertyArrayIndex OPTIONAL */
if (decode_is_context_tag(&apdu[len], 1)) { if (decode_is_context_tag(&apdu[len], 1)) {
len += len +=
@@ -244,11 +251,13 @@ int cov_notify_decode_service_request(
&len_value); &len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value); len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->propertyArrayIndex = decoded_value; value->propertyArrayIndex = decoded_value;
} else } else {
value->propertyArrayIndex = BACNET_ARRAY_ALL; value->propertyArrayIndex = BACNET_ARRAY_ALL;
}
/* tag 2: opening context tag - value */ /* 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; return -1;
}
/* a tag number of 2 is not extended so only one octet */ /* a tag number of 2 is not extended so only one octet */
len++; len++;
len += len +=
@@ -256,8 +265,9 @@ int cov_notify_decode_service_request(
&value->value); &value->value);
/* FIXME: check the return value; abort if no valid data? */ /* FIXME: check the return value; abort if no valid data? */
/* FIXME: there might be more than one data element in here! */ /* 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; return -1;
}
/* a tag number of 2 is not extended so only one octet */ /* a tag number of 2 is not extended so only one octet */
len++; len++;
/* tag 3 - priority OPTIONAL */ /* tag 3 - priority OPTIONAL */
@@ -267,16 +277,19 @@ int cov_notify_decode_service_request(
&len_value); &len_value);
len += decode_unsigned(&apdu[len], len_value, &decoded_value); len += decode_unsigned(&apdu[len], len_value, &decoded_value);
value->priority = decoded_value; value->priority = decoded_value;
} else } else {
value->priority = BACNET_NO_PRIORITY; value->priority = BACNET_NO_PRIORITY;
}
/* end of list? */ /* end of list? */
if (decode_is_closing_tag_number(&apdu[len], 4)) if (decode_is_closing_tag_number(&apdu[len], 4)) {
break; break;
}
/* is there another one to decode? */ /* is there another one to decode? */
value = value->next; value = value->next;
/* out of room to store more values */ /* out of room to store more values */
if (value == NULL) if (value == NULL) {
return -1; return -1;
}
} }
} }