Added routing support for virtual network so that source addresses are transmitted when required and the correct object ID is used.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user