Extended the test for supported services for routed devices to the device's PROP_PROTOCOL_SERVICES_SUPPORTED.

Support calling of Routed_Device_Service_Approval() with a NULL buffer if just testing for support.
This commit is contained in:
tbrennan3
2011-10-27 20:34:45 +00:00
parent 1eeaeda585
commit cbc62dd6c0
2 changed files with 34 additions and 8 deletions
+16 -6
View File
@@ -604,8 +604,10 @@ void Routed_Device_Inc_Database_Revision(
* @param service [in] The service being requested.
* @param service_argument [in] An optional argument (eg, service type).
* @param apdu_buff [in,out] The buffer where we will encode a Reject message.
* May be NULL if don't want an encoded response.
* @param invoke_id [in] The invoke_id of the service request.
* @return Length of bytes encoded in apdu_buff[] for a Reject message,
* just 1 if no apdu_buff was supplied and service is not supported,
* else 0 if service is approved for the current device.
*/
int Routed_Device_Service_Approval(
@@ -619,15 +621,23 @@ int Routed_Device_Service_Approval(
{
case SERVICE_CONFIRMED_REINITIALIZE_DEVICE:
/* If not the gateway device, we don't support RD */
if ( iCurrent_Device_Idx > 0 )
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
if ( iCurrent_Device_Idx > 0 ) {
if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
else
len = 1; /* Non-zero return */
}
break;
case SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL:
/* If not the gateway device, we don't support DCC */
if ( iCurrent_Device_Idx > 0 )
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
if ( iCurrent_Device_Idx > 0 ) {
if (apdu_buff != NULL)
len = reject_encode_apdu(apdu_buff,
invoke_id, REJECT_REASON_UNRECOGNIZED_SERVICE);
else
len = 1; /* Non-zero return */
}
break;
default:
/* Everything else is a pass, at this time. */
+18 -2
View File
@@ -45,6 +45,13 @@
/** @file apdu.c Handles APDU services */
extern int Routed_Device_Service_Approval(
BACNET_CONFIRMED_SERVICE service,
int service_argument,
uint8_t *apdu_buff,
uint8_t invoke_id );
/* APDU Timeout in Milliseconds */
static uint16_t Timeout_Milliseconds = 3000;
/* Number of APDU Retries */
@@ -145,9 +152,18 @@ bool apdu_service_supported(
/* is it a confirmed service? */
for (i = 0; i < MAX_BACNET_CONFIRMED_SERVICE; i++) {
if (confirmed_service_supported[i] == service_supported) {
if (Confirmed_Function[i] != NULL)
status = true;
found = true;
if (Confirmed_Function[i] != NULL) {
#if BAC_ROUTING
/* Check to see if the current Device supports this service. */
int len = Routed_Device_Service_Approval(
service_supported, 0, NULL, 0);
if ( len > 0 )
break; /* Not supported - return false */
#endif
status = true;
}
break;
}
}