Resolved more code where we didn't need to define separate BAC_ROUTING functionality, since the npdu_encode_pdu() will do the right thing if our source address is for the gateway (root device), because src->net and/or src->len will be 0.
For the important Device_Object_Instance_Number(), will redirect to the Routed_Device_Object_Instance_Number() function if this is a routing build. This leaves only the Who-Is and Who-Has handlers to be dealt with.
This commit is contained in:
@@ -56,23 +56,16 @@ int iam_encode_pdu(
|
||||
{
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
#if BAC_ROUTING
|
||||
BACNET_ADDRESS my_address;
|
||||
datalink_get_my_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(),
|
||||
#endif
|
||||
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
|
||||
pdu_len += len;
|
||||
|
||||
@@ -146,12 +139,8 @@ int iam_unicast_encode_pdu(
|
||||
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 */
|
||||
#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());
|
||||
MAX_APDU, SEGMENTATION_NONE, Device_Vendor_Identifier());
|
||||
pdu_len = npdu_len + apdu_len;
|
||||
|
||||
return pdu_len;
|
||||
|
||||
Reference in New Issue
Block a user