diff --git a/bacnet-stack/demo/handler/s_whohas.c b/bacnet-stack/demo/handler/s_whohas.c index 8b00502a..5ff4fef8 100644 --- a/bacnet-stack/demo/handler/s_whohas.c +++ b/bacnet-stack/demo/handler/s_whohas.c @@ -84,6 +84,7 @@ void Send_WhoHas_Object(int32_t low_limit, int32_t high_limit, BACNET_OBJECT_TYPE object_type, uint32_t object_instance) { + int len = 0; int pdu_len = 0; BACNET_ADDRESS dest; int bytes_sent = 0; @@ -95,13 +96,18 @@ void Send_WhoHas_Object(int32_t low_limit, return; /* Who-Has is a global broadcast */ datalink_get_broadcast_address(&dest); + /* encode the NPDU portion of the packet */ + npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); + pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, + NULL, &npdu_data); /* encode the APDU portion of the packet */ data.low_limit = low_limit; data.high_limit = high_limit; data.object_name = false; data.object.identifier.type = object_type; data.object.identifier.instance = object_instance; - pdu_len = whohas_encode_apdu(&Handler_Transmit_Buffer[0], &data); + len = whohas_encode_apdu(&Handler_Transmit_Buffer[pdu_len], &data); + pdu_len += len; bytes_sent = datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); #if PRINT_ENABLED