From ae0008d569b0fdbc383e74615cd83f4377afc444 Mon Sep 17 00:00:00 2001 From: skarg Date: Tue, 13 Mar 2012 19:06:26 +0000 Subject: [PATCH] Changed SubscribeCOV demo application to wait for APDU Timeout * Retries until the target device is found. After the target device is found, the demo application can wait the duration of the longest COV lifetime, if there is one. Thanks for the suggestion, Duane King! --- bacnet-stack/demo/scov/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bacnet-stack/demo/scov/main.c b/bacnet-stack/demo/scov/main.c index 5bb4dc0d..c087763a 100644 --- a/bacnet-stack/demo/scov/main.c +++ b/bacnet-stack/demo/scov/main.c @@ -307,11 +307,6 @@ int main( /* configure the timeout values */ last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); - if (!COV_Subscribe_Data->cancellationRequest && - (timeout_seconds < COV_Subscribe_Data->lifetime)) { - /* only use the first subscribe value */ - timeout_seconds = COV_Subscribe_Data->lifetime; - } /* try to bind with the device */ found = address_bind_request(Target_Device_Object_Instance, &max_apdu, @@ -350,6 +345,11 @@ int main( Request_Invoke_ID = Send_COV_Subscribe( Target_Device_Object_Instance, cov_data); + if (!cov_data->cancellationRequest && + (timeout_seconds < cov_data->lifetime)) { + /* increase the timeout to the longest lifetime */ + timeout_seconds = cov_data->lifetime; + } printf("Sent SubscribeCOV request. Waiting %u seconds.\r\n", (unsigned)(timeout_seconds - elapsed_seconds)); } else if (tsm_invoke_id_free(Request_Invoke_ID)) {