diff --git a/bacnet-stack/demo/dcc/main.c b/bacnet-stack/demo/dcc/main.c index 9d492caf..2915ee07 100644 --- a/bacnet-stack/demo/dcc/main.c +++ b/bacnet-stack/demo/dcc/main.c @@ -230,7 +230,13 @@ int main( last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); /* try to bind with the device */ - Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + if (!found) { + Send_WhoIs(Target_Device_Object_Instance, + Target_Device_Object_Instance); + } /* loop forever */ for (;;) { /* increment timer - exit if timed out */ @@ -250,9 +256,11 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = - address_bind_request(Target_Device_Object_Instance, &max_apdu, - &Target_Address); + if (!found) { + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + } if (found) { if (invoke_id == 0) { invoke_id = diff --git a/bacnet-stack/demo/readfile/main.c b/bacnet-stack/demo/readfile/main.c index 982f198e..6d676c86 100644 --- a/bacnet-stack/demo/readfile/main.c +++ b/bacnet-stack/demo/readfile/main.c @@ -301,7 +301,13 @@ int main( last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); /* try to bind with the device */ - Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + if (!found) { + Send_WhoIs(Target_Device_Object_Instance, + Target_Device_Object_Instance); + } /* loop forever */ for (;;) { /* increment timer - exit if timed out */ @@ -319,9 +325,11 @@ int main( tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000)); } /* wait until the device is bound, or timeout and quit */ - found = - address_bind_request(Target_Device_Object_Instance, &max_apdu, - &Target_Address); + if (!found) { + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + } if (found) { /* calculate the smaller of our APDU size or theirs and remove the overhead of the APDU (about 16 octets max). diff --git a/bacnet-stack/demo/reinit/main.c b/bacnet-stack/demo/reinit/main.c index e4791323..4a7a3068 100644 --- a/bacnet-stack/demo/reinit/main.c +++ b/bacnet-stack/demo/reinit/main.c @@ -190,7 +190,13 @@ int main( last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); /* try to bind with the device */ - Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + if (!found) { + Send_WhoIs(Target_Device_Object_Instance, + Target_Device_Object_Instance); + } /* loop forever */ for (;;) { /* increment timer - exit if timed out */ @@ -209,9 +215,11 @@ int main( if (Error_Detected) break; /* wait until the device is bound, or timeout and quit */ - found = - address_bind_request(Target_Device_Object_Instance, &max_apdu, - &Target_Address); + if (!found) { + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + } if (found) { if (invoke_id == 0) { invoke_id = diff --git a/bacnet-stack/demo/writefile/main.c b/bacnet-stack/demo/writefile/main.c index 90bbbdae..cc140a72 100644 --- a/bacnet-stack/demo/writefile/main.c +++ b/bacnet-stack/demo/writefile/main.c @@ -216,7 +216,13 @@ int main( last_seconds = time(NULL); timeout_seconds = (apdu_timeout() / 1000) * apdu_retries(); /* try to bind with the device */ - Send_WhoIs(Target_Device_Object_Instance, Target_Device_Object_Instance); + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + if (!found) { + Send_WhoIs(Target_Device_Object_Instance, + Target_Device_Object_Instance); + } /* loop forever */ for (;;) { /* increment timer - exit if timed out */ @@ -234,9 +240,11 @@ int main( tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000)); } /* wait until the device is bound, or timeout and quit */ - found = - address_bind_request(Target_Device_Object_Instance, &max_apdu, - &Target_Address); + if (!found) { + found = + address_bind_request(Target_Device_Object_Instance, &max_apdu, + &Target_Address); + } if (found) { if (Target_File_Requested_Octet_Count) { requestedOctetCount = Target_File_Requested_Octet_Count;