diff --git a/bacnet-stack/demo/handler/h_arf.c b/bacnet-stack/demo/handler/h_arf.c index b51e710a..ef8ad3b4 100644 --- a/bacnet-stack/demo/handler/h_arf.c +++ b/bacnet-stack/demo/handler/h_arf.c @@ -118,7 +118,11 @@ void handler_atomic_read_file( fprintf(stderr, "Received Atomic-Read-File Request!\n"); #endif /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_awf.c b/bacnet-stack/demo/handler/h_awf.c index 28c94c94..afcd5901 100644 --- a/bacnet-stack/demo/handler/h_awf.c +++ b/bacnet-stack/demo/handler/h_awf.c @@ -96,7 +96,11 @@ void handler_atomic_write_file( fprintf(stderr, "Received AtomicWriteFile Request!\n"); #endif /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_cov.c b/bacnet-stack/demo/handler/h_cov.c index 456e3f09..8ff84da4 100644 --- a/bacnet-stack/demo/handler/h_cov.c +++ b/bacnet-stack/demo/handler/h_cov.c @@ -326,7 +326,11 @@ static bool cov_send_request( #if PRINT_ENABLED fprintf(stderr, "COVnotification: requested\n"); #endif +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &cov_subscription->dest, @@ -334,7 +338,11 @@ static bool cov_send_request( /* load the COV data structure for outgoing message */ cov_data.subscriberProcessIdentifier = cov_subscription->subscriberProcessIdentifier; +#if BAC_ROUTING cov_data.initiatingDeviceIdentifier = Device_Object_Instance_Number(); +#else + cov_data.initiatingDeviceIdentifier = Device_Object_Instance_Number(); +#endif cov_data.monitoredObjectIdentifier.type = cov_subscription->monitoredObjectIdentifier.type; cov_data.monitoredObjectIdentifier.instance = @@ -520,7 +528,11 @@ void handler_cov_subscribe( /* initialize a common abort code */ cov_data.error_code = ABORT_REASON_SEGMENTATION_NOT_SUPPORTED; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_dcc.c b/bacnet-stack/demo/handler/h_dcc.c index 64a1f61a..1e69fd7d 100644 --- a/bacnet-stack/demo/handler/h_dcc.c +++ b/bacnet-stack/demo/handler/h_dcc.c @@ -38,6 +38,7 @@ #include "reject.h" #include "dcc.h" #include "handlers.h" +#include "device.h" /** @file h_dcc.c Handles Device Communication Control request. */ @@ -102,7 +103,11 @@ void handler_device_communication_control( BACNET_ADDRESS my_address; /* encode the NPDU portion of the reply packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_lso.c b/bacnet-stack/demo/handler/h_lso.c index 276c5f86..19d6f6b9 100644 --- a/bacnet-stack/demo/handler/h_lso.c +++ b/bacnet-stack/demo/handler/h_lso.c @@ -36,6 +36,7 @@ #include "abort.h" #include "lso.h" #include "handlers.h" +#include "device.h" /** @file h_lso.c Handles BACnet Life Safey Operation messages. */ @@ -53,7 +54,11 @@ void handler_lso( BACNET_ADDRESS my_address; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_rd.c b/bacnet-stack/demo/handler/h_rd.c index 3c1d048a..560fd610 100644 --- a/bacnet-stack/demo/handler/h_rd.c +++ b/bacnet-stack/demo/handler/h_rd.c @@ -77,7 +77,11 @@ void handler_reinitialize_device( BACNET_ADDRESS my_address; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_rp.c b/bacnet-stack/demo/handler/h_rp.c index aedbe198..6c09e539 100644 --- a/bacnet-stack/demo/handler/h_rp.c +++ b/bacnet-stack/demo/handler/h_rp.c @@ -83,7 +83,11 @@ void handler_read_property( /* configure default error code as an abort since it is common */ rpdata.error_code = ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_rpm.c b/bacnet-stack/demo/handler/h_rpm.c index f23fa0d4..a5b587d9 100644 --- a/bacnet-stack/demo/handler/h_rpm.c +++ b/bacnet-stack/demo/handler/h_rpm.c @@ -204,7 +204,11 @@ void handler_read_property_multiple( /* jps_debug - see if we are utilizing all the buffer */ /* memset(&Handler_Transmit_Buffer[0], 0xff, sizeof(Handler_Transmit_Buffer)); */ /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/h_whohas.c b/bacnet-stack/demo/handler/h_whohas.c index e83d303d..602e358f 100644 --- a/bacnet-stack/demo/handler/h_whohas.c +++ b/bacnet-stack/demo/handler/h_whohas.c @@ -65,8 +65,13 @@ void handler_who_has( if (len > 0) { if ((data.low_limit == -1) || (data.high_limit == -1)) directed_to_me = true; +#if BAC_ROUTING + else if ((Routed_Device_Object_Instance_Number() >= (uint32_t) data.low_limit) + && (Routed_Device_Object_Instance_Number() <= (uint32_t) data.high_limit)) +#else else if ((Device_Object_Instance_Number() >= (uint32_t) data.low_limit) && (Device_Object_Instance_Number() <= (uint32_t) data.high_limit)) +#endif directed_to_me = true; if (directed_to_me) { /* do we have such an object? If so, send an I-Have. @@ -78,7 +83,11 @@ void handler_who_has( Device_Valid_Object_Name(object_name, &object_type, &object_instance); if (found) +#if BAC_ROUTING + Send_I_Have(Routed_Device_Object_Instance_Number(), +#else Send_I_Have(Device_Object_Instance_Number(), +#endif (BACNET_OBJECT_TYPE) object_type, object_instance, object_name); } else { @@ -87,7 +96,11 @@ void handler_who_has( Device_Valid_Object_Id(data.object.identifier.type, data.object.identifier.instance); if (object_name) +#if BAC_ROUTING + Send_I_Have(Routed_Device_Object_Instance_Number(), +#else Send_I_Have(Device_Object_Instance_Number(), +#endif (BACNET_OBJECT_TYPE) data.object.identifier.type, data.object.identifier.instance, object_name); } diff --git a/bacnet-stack/demo/handler/h_whois.c b/bacnet-stack/demo/handler/h_whois.c index 7d1261f4..1ae79559 100644 --- a/bacnet-stack/demo/handler/h_whois.c +++ b/bacnet-stack/demo/handler/h_whois.c @@ -63,12 +63,21 @@ void handler_who_is( Send_I_Am(&Handler_Transmit_Buffer[0]); else if (len != -1) { /* is my device id within the limits? */ +#if BAC_ROUTING + if (((Routed_Device_Object_Instance_Number() >= (uint32_t) low_limit) && + (Routed_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))) +#else 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))) +#endif Send_I_Am(&Handler_Transmit_Buffer[0]); } @@ -98,12 +107,21 @@ void handler_who_is_unicast( Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src); else if (len != -1) { /* is my device id within the limits? */ +#if BAC_ROUTING + if (((Routed_Device_Object_Instance_Number() >= (uint32_t) low_limit) && + (Routed_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))) +#else 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))) +#endif Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src); } diff --git a/bacnet-stack/demo/handler/h_wp.c b/bacnet-stack/demo/handler/h_wp.c index b1ec68c8..ae505bd3 100644 --- a/bacnet-stack/demo/handler/h_wp.c +++ b/bacnet-stack/demo/handler/h_wp.c @@ -75,7 +75,11 @@ void handler_write_property( BACNET_ADDRESS my_address; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/noserv.c b/bacnet-stack/demo/handler/noserv.c index 152665b0..c32ea245 100644 --- a/bacnet-stack/demo/handler/noserv.c +++ b/bacnet-stack/demo/handler/noserv.c @@ -34,6 +34,7 @@ #include "npdu.h" #include "reject.h" #include "handlers.h" +#include "device.h" /** @file noserv.c Handles an unrecognized/unsupported service. */ @@ -64,7 +65,11 @@ void handler_unrecognized_service( (void) service_len; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], src, &my_address, diff --git a/bacnet-stack/demo/handler/s_arfs.c b/bacnet-stack/demo/handler/s_arfs.c index 15d43971..68a8ae51 100644 --- a/bacnet-stack/demo/handler/s_arfs.c +++ b/bacnet-stack/demo/handler/s_arfs.c @@ -79,7 +79,11 @@ uint8_t Send_Atomic_Read_File_Stream( data.type.stream.fileStartPosition = fileStartPosition; data.type.stream.requestedOctetCount = requestedOctetCount; /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, diff --git a/bacnet-stack/demo/handler/s_awfs.c b/bacnet-stack/demo/handler/s_awfs.c index b0aef8bb..507093f7 100644 --- a/bacnet-stack/demo/handler/s_awfs.c +++ b/bacnet-stack/demo/handler/s_awfs.c @@ -80,7 +80,11 @@ uint8_t Send_Atomic_Write_File_Stream( status = octetstring_copy(&data.fileData, fileData); if (status) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, diff --git a/bacnet-stack/demo/handler/s_cov.c b/bacnet-stack/demo/handler/s_cov.c index 6cefdaab..e717d4fe 100644 --- a/bacnet-stack/demo/handler/s_cov.c +++ b/bacnet-stack/demo/handler/s_cov.c @@ -52,12 +52,20 @@ int ucov_notify_encode_pdu( { int len = 0; int pdu_len = 0; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif /* unconfirmed is a broadcast */ datalink_get_broadcast_address(dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data); +#else pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data); +#endif /* encode the APDU portion of the packet */ len = ucov_notify_encode_apdu(&buffer[pdu_len], cov_data); pdu_len += len; @@ -119,7 +127,11 @@ uint8_t Send_COV_Subscribe( } if (invoke_id) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, diff --git a/bacnet-stack/demo/handler/s_dcc.c b/bacnet-stack/demo/handler/s_dcc.c index 1f4653f7..5d2f069c 100644 --- a/bacnet-stack/demo/handler/s_dcc.c +++ b/bacnet-stack/demo/handler/s_dcc.c @@ -83,7 +83,11 @@ uint8_t Send_Device_Communication_Control_Request( invoke_id = tsm_next_free_invokeID(); if (invoke_id) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, diff --git a/bacnet-stack/demo/handler/s_iam.c b/bacnet-stack/demo/handler/s_iam.c index d03a4651..14ce2e68 100644 --- a/bacnet-stack/demo/handler/s_iam.c +++ b/bacnet-stack/demo/handler/s_iam.c @@ -56,14 +56,23 @@ int iam_encode_pdu( { int len = 0; int pdu_len = 0; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif datalink_get_broadcast_address(dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data); + /* encode the APDU portion of the packet */ + len = iam_encode_apdu(&buffer[pdu_len], Routed_Device_Object_Instance_Number(), +#else pdu_len = npdu_encode_pdu(&buffer[0], dest, NULL, npdu_data); /* encode the APDU portion of the packet */ - len = - iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(), + len = iam_encode_apdu(&buffer[pdu_len], Device_Object_Instance_Number(), +#endif MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier()); pdu_len += len; @@ -128,18 +137,24 @@ int iam_unicast_encode_pdu( int apdu_len = 0; int pdu_len = 0; BACNET_ADDRESS my_address; - /* The destination will be the same as the src, so copy it over. */ memcpy(dest, src, sizeof(BACNET_ADDRESS)); dest->net = 0; +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(npdu_data, false, MESSAGE_PRIORITY_NORMAL); npdu_len = npdu_encode_pdu(&buffer[0], dest, &my_address, npdu_data); /* encode the APDU portion of the packet */ - apdu_len = - iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(), +#if BAC_ROUTING + apdu_len = iam_encode_apdu(&buffer[npdu_len], Routed_Device_Object_Instance_Number(), +#else + apdu_len = iam_encode_apdu(&buffer[npdu_len], Device_Object_Instance_Number(), +#endif MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier()); pdu_len = npdu_len + apdu_len; diff --git a/bacnet-stack/demo/handler/s_ihave.c b/bacnet-stack/demo/handler/s_ihave.c index 9091fd27..3bf868b9 100644 --- a/bacnet-stack/demo/handler/s_ihave.c +++ b/bacnet-stack/demo/handler/s_ihave.c @@ -65,7 +65,11 @@ void Send_I_Have( int bytes_sent = 0; BACNET_I_HAVE_DATA data; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif /* if we are forbidden to send, don't send! */ if (!dcc_communication_enabled()) return; @@ -73,8 +77,14 @@ void Send_I_Have( 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); + +#if BAC_ROUTING + pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); +#else + pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); +#endif + + pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); /* encode the APDU portion of the packet */ data.device_id.type = OBJECT_DEVICE; data.device_id.instance = device_id; diff --git a/bacnet-stack/demo/handler/s_rd.c b/bacnet-stack/demo/handler/s_rd.c index f2fdc5b0..0c61d3f8 100644 --- a/bacnet-stack/demo/handler/s_rd.c +++ b/bacnet-stack/demo/handler/s_rd.c @@ -80,7 +80,11 @@ uint8_t Send_Reinitialize_Device_Request( invoke_id = tsm_next_free_invokeID(); if (invoke_id) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, diff --git a/bacnet-stack/demo/handler/s_rp.c b/bacnet-stack/demo/handler/s_rp.c index 240f16d3..511f4800 100644 --- a/bacnet-stack/demo/handler/s_rp.c +++ b/bacnet-stack/demo/handler/s_rp.c @@ -86,7 +86,11 @@ uint8_t Send_Read_Property_Request( invoke_id = tsm_next_free_invokeID(); if (invoke_id) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, diff --git a/bacnet-stack/demo/handler/s_rpm.c b/bacnet-stack/demo/handler/s_rpm.c index 25700f96..0b6fd9d2 100644 --- a/bacnet-stack/demo/handler/s_rpm.c +++ b/bacnet-stack/demo/handler/s_rpm.c @@ -81,7 +81,11 @@ uint8_t Send_Read_Property_Multiple_Request( invoke_id = tsm_next_free_invokeID(); if (invoke_id) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&pdu[0], &dest, &my_address, &npdu_data); /* encode the APDU portion of the packet */ diff --git a/bacnet-stack/demo/handler/s_ts.c b/bacnet-stack/demo/handler/s_ts.c index eaefd658..8f7e06c1 100644 --- a/bacnet-stack/demo/handler/s_ts.c +++ b/bacnet-stack/demo/handler/s_ts.c @@ -54,7 +54,11 @@ void Send_TimeSync( BACNET_ADDRESS dest; int bytes_sent = 0; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif if (!dcc_communication_enabled()) return; @@ -62,8 +66,13 @@ void Send_TimeSync( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); +#else pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); +#endif /* encode the APDU portion of the packet */ len = timesync_encode_apdu(&Handler_Transmit_Buffer[pdu_len], bdate, btime); @@ -87,7 +96,11 @@ void Send_TimeSyncUTC( BACNET_ADDRESS dest; int bytes_sent = 0; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif if (!dcc_communication_enabled()) return; @@ -95,8 +108,13 @@ void Send_TimeSyncUTC( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); +#else pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); +#endif /* encode the APDU portion of the packet */ pdu_len = timesync_utc_encode_apdu(&Handler_Transmit_Buffer[0], bdate, btime); diff --git a/bacnet-stack/demo/handler/s_uevent.c b/bacnet-stack/demo/handler/s_uevent.c index 4821e419..669e8e96 100644 --- a/bacnet-stack/demo/handler/s_uevent.c +++ b/bacnet-stack/demo/handler/s_uevent.c @@ -28,6 +28,7 @@ #include "event.h" #include "datalink.h" #include "client.h" +#include "device.h" /** @file s_uevent.c Send an Unconfirmed Event Notification. */ @@ -48,10 +49,18 @@ int Send_UEvent_Notify( int pdu_len = 0; int bytes_sent = 0; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = npdu_encode_pdu(buffer, dest, &my_address, &npdu_data); +#else pdu_len = npdu_encode_pdu(buffer, dest, NULL, &npdu_data); +#endif /* encode the APDU portion of the packet */ len = uevent_notify_encode_apdu(&buffer[pdu_len], data); pdu_len += len; diff --git a/bacnet-stack/demo/handler/s_whohas.c b/bacnet-stack/demo/handler/s_whohas.c index 7916a9cd..5417c354 100644 --- a/bacnet-stack/demo/handler/s_whohas.c +++ b/bacnet-stack/demo/handler/s_whohas.c @@ -66,7 +66,11 @@ void Send_WhoHas_Name( int bytes_sent = 0; BACNET_WHO_HAS_DATA data; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif /* if we are forbidden to send, don't send! */ if (!dcc_communication_enabled()) return; @@ -74,8 +78,13 @@ void Send_WhoHas_Name( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); +#else pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); +#endif /* encode the APDU portion of the packet */ data.low_limit = low_limit; data.high_limit = high_limit; @@ -117,7 +126,11 @@ void Send_WhoHas_Object( int bytes_sent = 0; BACNET_WHO_HAS_DATA data; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif /* if we are forbidden to send, don't send! */ if (!dcc_communication_enabled()) return; @@ -125,8 +138,13 @@ void Send_WhoHas_Object( datalink_get_broadcast_address(&dest); /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); +#if BAC_ROUTING + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); +#else pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, NULL, &npdu_data); +#endif /* encode the APDU portion of the packet */ data.low_limit = low_limit; data.high_limit = high_limit; diff --git a/bacnet-stack/demo/handler/s_whois.c b/bacnet-stack/demo/handler/s_whois.c index 0c2ea97d..403361e0 100644 --- a/bacnet-stack/demo/handler/s_whois.c +++ b/bacnet-stack/demo/handler/s_whois.c @@ -65,12 +65,21 @@ void Send_WhoIs_To_Network( int pdu_len = 0; int bytes_sent = 0; BACNET_NPDU_DATA npdu_data; +#if BAC_ROUTING + BACNET_ADDRESS my_address; + my_address = *Get_Routed_Device_Address(-1); +#endif /* encode the NPDU portion of the packet */ npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL); + +#if BAC_ROUTING pdu_len = - npdu_encode_pdu(&Handler_Transmit_Buffer[0], target_address, NULL, - &npdu_data); + npdu_encode_pdu(&Handler_Transmit_Buffer[0], target_address, &my_address, &npdu_data); +#else + pdu_len = + npdu_encode_pdu(&Handler_Transmit_Buffer[0], target_address, NULL, &npdu_data); +#endif /* encode the APDU portion of the packet */ len = whois_encode_apdu(&Handler_Transmit_Buffer[pdu_len], low_limit, diff --git a/bacnet-stack/demo/handler/s_wp.c b/bacnet-stack/demo/handler/s_wp.c index d6e46192..77459c57 100644 --- a/bacnet-stack/demo/handler/s_wp.c +++ b/bacnet-stack/demo/handler/s_wp.c @@ -77,7 +77,11 @@ uint8_t Send_Write_Property_Request_Data( invoke_id = tsm_next_free_invokeID(); if (invoke_id) { /* encode the NPDU portion of the packet */ +#if BAC_ROUTING + my_address = *Get_Routed_Device_Address(-1); +#else datalink_get_my_address(&my_address); +#endif npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL); pdu_len = npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,