diff --git a/bacnet-stack/demo/handler/h_whois.c b/bacnet-stack/demo/handler/h_whois.c index d1e4a021..a639a1ad 100644 --- a/bacnet-stack/demo/handler/h_whois.c +++ b/bacnet-stack/demo/handler/h_whois.c @@ -64,13 +64,8 @@ void handler_who_is( Send_I_Am(&Handler_Transmit_Buffer[0]); } else if (len != BACNET_STATUS_ERROR) { /* is my device id within the limits? */ - /* or */ - /* BACnet wildcard is the max instance number - everyone responds */ - if (((Device_Object_Instance_Number() >= (uint32_t) low_limit) && - (Device_Object_Instance_Number() <= (uint32_t) high_limit)) - || - ((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) && - (BACNET_MAX_INSTANCE <= (uint32_t) high_limit))) { + if ((Device_Object_Instance_Number() >= (uint32_t) low_limit) && + (Device_Object_Instance_Number() <= (uint32_t) high_limit)) { Send_I_Am(&Handler_Transmit_Buffer[0]); } } @@ -98,17 +93,14 @@ void handler_who_is_unicast( whois_decode_service_request(service_request, service_len, &low_limit, &high_limit); /* If no limits, then always respond */ - if (len == 0) + if (len == 0) { Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src); - else if (len != BACNET_STATUS_ERROR) { + } else if (len != BACNET_STATUS_ERROR) { /* 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))) + if ((Device_Object_Instance_Number() >= (uint32_t) low_limit) && + (Device_Object_Instance_Number() <= (uint32_t) high_limit)) { Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src); + } } return; @@ -151,20 +143,14 @@ static void check_who_is_for_routing( /* Invalid; just leave */ return; } - /* If len == 0, then high_limit is untouched and still == 0 */ - /* BACnet wildcard is the max instance number - everyone responds */ - if ((BACNET_MAX_INSTANCE >= (uint32_t) low_limit) && - (BACNET_MAX_INSTANCE <= (uint32_t) high_limit)) - high_limit = 0; - /* This is the "always accept" case we will test for below */ - /* Go through all devices, starting with the root gateway Device */ memset(&bcast_net, 0, sizeof(BACNET_ADDRESS)); bcast_net.net = BACNET_BROADCAST_NETWORK; /* That's all we have to set */ while (Routed_Device_GetNext(&bcast_net, my_list, &cursor)) { dev_instance = Device_Object_Instance_Number(); - if ((high_limit == 0) || ((dev_instance >= low_limit) && + /* If len == 0, no limits and always respond */ + if ((len == 0) || ((dev_instance >= low_limit) && (dev_instance <= high_limit))) { if (is_unicast) Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src); diff --git a/bacnet-stack/ports/arduino_uno/h_whois.c b/bacnet-stack/ports/arduino_uno/h_whois.c index 60ad35dc..e05cc4f5 100644 --- a/bacnet-stack/ports/arduino_uno/h_whois.c +++ b/bacnet-stack/ports/arduino_uno/h_whois.c @@ -84,11 +84,7 @@ void handler_who_is(uint8_t * service_request, } else if (len != -1) { /* is my device id within the limits? */ target_device = Device_Object_Instance_Number(); - if (((target_device >= low_limit) && (target_device <= 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))) { + if (((target_device >= low_limit) && (target_device <= high_limit)) { sendIamUnicast(&Handler_Transmit_Buffer[0], src); } } diff --git a/bacnet-stack/ports/atmega168/h_whois.c b/bacnet-stack/ports/atmega168/h_whois.c index 05d82011..dced9c60 100644 --- a/bacnet-stack/ports/atmega168/h_whois.c +++ b/bacnet-stack/ports/atmega168/h_whois.c @@ -58,11 +58,7 @@ void handler_who_is( } else if (len != BACNET_STATUS_ERROR) { /* is my device id within the limits? */ target_device = Device_Object_Instance_Number(); - if (((target_device >= low_limit) && (target_device <= 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))) { + if (((target_device >= low_limit) && (target_device <= high_limit)) { Send_I_Am_Flag = true; } }