refactored the Who-Is and I-Am handling, and cleaned up some comments.

This commit is contained in:
skarg
2006-02-20 16:17:46 +00:00
parent 16c2545f45
commit 676ecf77a2
9 changed files with 149 additions and 188 deletions
+16 -23
View File
@@ -23,7 +23,7 @@
*
*********************************************************************/
/* WRITEPROP: command line tool that writes a property to a BACnet device. */
/* command line tool that sends a BACnet service, and displays the reply */
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -213,8 +213,6 @@ int main(int argc, char *argv[])
last_seconds = time(NULL);
timeout_seconds = (Device_APDU_Timeout() / 1000) *
Device_Number_Of_APDU_Retries();
/* don't send an I-Am unless asked */
I_Am_Request = false;
/* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
@@ -236,27 +234,22 @@ int main(int argc, char *argv[])
last_seconds) * 1000));
if (Error_Detected)
break;
if (I_Am_Request) {
I_Am_Request = false;
iam_send(&Handler_Transmit_Buffer[0]);
/* wait until the device is bound, or timeout and quit */
found = address_bind_request(Target_Device_Object_Instance,
&max_apdu, &Target_Address);
if (found) {
if (invoke_id == 0) {
invoke_id =
Send_Reinitialize_Device_Request
(Target_Device_Object_Instance, Reinitialize_State,
Reinitialize_Password);
} else if (tsm_invoke_id_free(invoke_id))
break;
} else {
/* wait until the device is bound, or timeout and quit */
found = address_bind_request(Target_Device_Object_Instance,
&max_apdu, &Target_Address);
if (found) {
if (invoke_id == 0) {
invoke_id =
Send_Reinitialize_Device_Request
(Target_Device_Object_Instance, Reinitialize_State,
Reinitialize_Password);
} else if (tsm_invoke_id_free(invoke_id))
break;
} else {
/* increment timer - exit if timed out */
elapsed_seconds += (current_seconds - last_seconds);
if (elapsed_seconds > timeout_seconds)
break;
}
/* increment timer - exit if timed out */
elapsed_seconds += (current_seconds - last_seconds);
if (elapsed_seconds > timeout_seconds)
break;
}
/* keep track of time for next check */
last_seconds = current_seconds;