From 350736f6bb4628049215d16dcf1924cb1b42be35 Mon Sep 17 00:00:00 2001 From: skarg Date: Sat, 18 Dec 2010 17:30:58 +0000 Subject: [PATCH] Corrected DeviceCommunicationControl (DCC) for DISABLE_INITIATION state, which now allows I-Am in response to Who-Is. Did not add keep out for other initiated services like COV (to do). --- bacnet-stack/demo/object/device.c | 2 +- bacnet-stack/src/apdu.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bacnet-stack/demo/object/device.c b/bacnet-stack/demo/object/device.c index b192471c..e5b88aab 100644 --- a/bacnet-stack/demo/object/device.c +++ b/bacnet-stack/demo/object/device.c @@ -193,8 +193,8 @@ bool Device_Reinitialize( if (characterstring_ansi_same(&rd_data->password, "Jesus")) { switch (rd_data->state) { case BACNET_REINIT_COLDSTART: - break; case BACNET_REINIT_WARMSTART: + dcc_set_status_duration(COMMUNICATION_ENABLE, 0); break; case BACNET_REINIT_STARTBACKUP: break; diff --git a/bacnet-stack/src/apdu.c b/bacnet-stack/src/apdu.c index d81cceeb..c0bd200a 100644 --- a/bacnet-stack/src/apdu.c +++ b/bacnet-stack/src/apdu.c @@ -361,7 +361,7 @@ void apdu_retries_set( * to manage the received request. * Almost all requests and ACKs invoke this function. * @ingroup MISCHNDLR - * + * * @param src [in] The BACNET_ADDRESS of the message's source. * @param apdu [in] The apdu portion of the request, to be processed. * @param apdu_len [in] The total (remaining) length of the apdu. @@ -396,7 +396,8 @@ void apdu_handler( /* When network communications are completely disabled, only DeviceCommunicationControl and ReinitializeDevice APDUs shall be processed and no messages shall be initiated. */ - if (dcc_communication_disabled() && + if ((dcc_communication_disabled() || + dcc_communication_initiation_disabled()) && ((service_choice != SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL) && (service_choice != @@ -411,11 +412,19 @@ void apdu_handler( service_request_len, src, &service_data); break; case PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST: + /* When network communications are completely disabled, + only DeviceCommunicationControl and ReinitializeDevice APDUs + shall be processed and no messages shall be initiated. */ if (dcc_communication_disabled()) break; service_choice = apdu[1]; service_request = &apdu[2]; service_request_len = apdu_len - 2; + /* When network communications have initiation disabled, + WhoIs will be processed and I-Am initiated as response. */ + if (dcc_communication_initiation_disabled() && + (service_choice != SERVICE_UNCONFIRMED_WHO_IS)) + break; if (service_choice < MAX_BACNET_UNCONFIRMED_SERVICE) { if (Unconfirmed_Function[service_choice]) Unconfirmed_Function[service_choice] (service_request,