Added Send_I_Am_Broadcast() function to Who-Is handler so that other Send_I_Am() will honor DCC Disable-Initiatiation. (#918)
This commit is contained in:
@@ -38,12 +38,12 @@ void handler_who_is(
|
||||
len = whois_decode_service_request(
|
||||
service_request, service_len, &low_limit, &high_limit);
|
||||
if (len == 0) {
|
||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||
Send_I_Am_Broadcast(&Handler_Transmit_Buffer[0]);
|
||||
} 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)) {
|
||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||
Send_I_Am_Broadcast(&Handler_Transmit_Buffer[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ static void check_who_is_for_routing(
|
||||
if (is_unicast) {
|
||||
Send_I_Am_Unicast(&Handler_Transmit_Buffer[0], src);
|
||||
} else {
|
||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||
Send_I_Am_Broadcast(&Handler_Transmit_Buffer[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,29 +91,17 @@ int iam_encode_pdu(
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
/** Broadcast an I Am message.
|
||||
* @ingroup DMDDB
|
||||
*
|
||||
/**
|
||||
* @brief Send an I-Am broadcast message in response to Who-Is message
|
||||
* @param buffer [in] The buffer to use for building and sending the message.
|
||||
*/
|
||||
void Send_I_Am(uint8_t *buffer)
|
||||
void Send_I_Am_Broadcast(uint8_t *buffer)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
BACNET_ADDRESS dest;
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
#if 0
|
||||
/* note: there is discussion in the BACnet committee
|
||||
that we should allow a device to reply with I-Am
|
||||
so that dynamic binding always work. If the DCC
|
||||
initiator loses the MAC address and routing info,
|
||||
they can never re-enable DCC because they can't
|
||||
find the device with WhoIs/I-Am */
|
||||
/* are we are forbidden to send? */
|
||||
if (!dcc_communication_enabled())
|
||||
return 0;
|
||||
#endif
|
||||
/* encode the data */
|
||||
pdu_len = iam_encode_pdu(buffer, &dest, &npdu_data);
|
||||
/* send data */
|
||||
@@ -123,6 +111,23 @@ void Send_I_Am(uint8_t *buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send an I-Am broadcast message NOT in response to Who-Is message
|
||||
* @param buffer [in] The buffer to use for building and sending the message.
|
||||
*/
|
||||
void Send_I_Am(uint8_t *buffer)
|
||||
{
|
||||
/* This function is sending a broadcast I-Am
|
||||
that is not in response to a Who-Is.
|
||||
This is common at device power up. */
|
||||
if (dcc_communication_initiation_disabled()) {
|
||||
/* we are forbidden to send */
|
||||
debug_print("I-Am: Communication Disabled!\n");
|
||||
return;
|
||||
}
|
||||
Send_I_Am_Broadcast(buffer);
|
||||
}
|
||||
|
||||
/** Encode an I Am message to be unicast directly back to the src.
|
||||
*
|
||||
* @param buffer [in,out] The buffer to use for building the message.
|
||||
@@ -177,17 +182,6 @@ void Send_I_Am_Unicast(uint8_t *buffer, const BACNET_ADDRESS *src)
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
#if 0
|
||||
/* note: there is discussion in the BACnet committee
|
||||
that we should allow a device to reply with I-Am
|
||||
so that dynamic binding always work. If the DCC
|
||||
initiator loses the MAC address and routing info,
|
||||
they can never re-enable DCC because they can't
|
||||
find the device with WhoIs/I-Am */
|
||||
/* are we are forbidden to send? */
|
||||
if (!dcc_communication_enabled())
|
||||
return 0;
|
||||
#endif
|
||||
/* encode the data */
|
||||
pdu_len = iam_unicast_encode_pdu(buffer, src, &dest, &npdu_data);
|
||||
/* send data */
|
||||
|
||||
@@ -39,6 +39,8 @@ int iam_encode_pdu(
|
||||
BACNET_STACK_EXPORT
|
||||
void Send_I_Am(uint8_t *buffer);
|
||||
BACNET_STACK_EXPORT
|
||||
void Send_I_Am_Broadcast(uint8_t *buffer);
|
||||
BACNET_STACK_EXPORT
|
||||
int iam_unicast_encode_pdu(
|
||||
uint8_t *buffer,
|
||||
const BACNET_ADDRESS *src,
|
||||
|
||||
Reference in New Issue
Block a user