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
+10 -7
View File
@@ -33,9 +33,8 @@
#include "bacdcode.h"
#include "whois.h"
#include "device.h"
/* global flag to send an I-Am */
bool I_Am_Request = true;
#include "client.h"
#include "txbuf.h"
void handler_who_is(uint8_t * service_request,
uint16_t service_len, BACNET_ADDRESS * src)
@@ -50,11 +49,15 @@ void handler_who_is(uint8_t * service_request,
/* in our simple system, we just set a flag and let the main loop
send the I-Am request. */
if (len == 0)
I_Am_Request = true;
iam_send(&Handler_Transmit_Buffer[0]);
else if (len != -1) {
if ((Device_Object_Instance_Number() >= (uint32_t) low_limit) &&
(Device_Object_Instance_Number() <= (uint32_t) high_limit))
I_Am_Request = true;
/* is my device id within the limits? */
if (((Device_Object_Instance_Number() >= (uint32_t) low_limit) &&
(Device_Object_Instance_Number() <= (uint32_t) high_limit)) ||
/* BACnet wildcard is the max instance number - everyone responds */
((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) &&
(BACNET_MAX_INSTANCE <= (uint32_t) high_limit)))
iam_send(&Handler_Transmit_Buffer[0]);
}
return;
-3
View File
@@ -32,9 +32,6 @@
#include "apdu.h"
#include "bacapp.h"
/* flag requesting main loop to send an I-Am */
extern bool I_Am_Request;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */