diff --git a/src/bacnet/basic/service/h_rpm.c b/src/bacnet/basic/service/h_rpm.c index 53ccb5c0..21bdc7ad 100644 --- a/src/bacnet/basic/service/h_rpm.c +++ b/src/bacnet/basic/service/h_rpm.c @@ -130,7 +130,16 @@ static int RPM_Encode_Property( rpdata.array_index = rpmdata->array_index; rpdata.application_data = &Temp_Buf[0]; rpdata.application_data_len = sizeof(Temp_Buf); - len = Device_Read_Property(&rpdata); + + if ((rpmdata->object_property == PROP_ALL) || + (rpmdata->object_property == PROP_REQUIRED) || + (rpmdata->object_property == PROP_OPTIONAL)) { + /* special properties only get ERROR encoding */ + len = BACNET_STATUS_ERROR; + } else { + len = Device_Read_Property(&rpdata); + } + if (len < 0) { if ((len == BACNET_STATUS_ABORT) || (len == BACNET_STATUS_REJECT)) { rpmdata->error_code = rpdata.error_code; @@ -301,7 +310,26 @@ void handler_read_property_multiple(uint8_t *service_request, unsigned index = 0; BACNET_PROPERTY_ID special_object_property; - if (rpmdata.array_index != BACNET_ARRAY_ALL) { + if (!Device_Valid_Object_Id(rpmdata.object_type, + rpmdata.object_instance)) { + len = RPM_Encode_Property( + &Handler_Transmit_Buffer[npdu_len], + (uint16_t)apdu_len, MAX_APDU, &rpmdata); + if (len > 0) { + apdu_len += len; + } else { +#if PRINT_ENABLED + fprintf(stderr, + "RPM: Too full for property!\r\n"); +#endif + error = len; + /* The berror flag ensures that + both loops will be broken! */ + berror = true; + break; + } + } else if (rpmdata.array_index != BACNET_ARRAY_ALL) { + /* No array index options for this special property. Encode error for this object property response */ len = rpm_ack_encode_apdu_object_property( @@ -361,7 +389,27 @@ void handler_read_property_multiple(uint8_t *service_request, response on OPTIONAL when empty. */ /* If no optional properties are supported then an empty 'List of Results' shall be returned - for the specified property.*/ + for the specified property, except if the + object does not exist. */ + if (!Device_Valid_Object_Id(rpmdata.object_type, + rpmdata.object_instance)) { + len = RPM_Encode_Property( + &Handler_Transmit_Buffer[npdu_len], + (uint16_t)apdu_len, MAX_APDU, &rpmdata); + if (len > 0) { + apdu_len += len; + } else { +#if PRINT_ENABLED + fprintf(stderr, + "RPM: Too full for property!\r\n"); +#endif + error = len; + /* The berror flag ensures that + both loops will be broken! */ + berror = true; + break; + } + } } else { for (index = 0; index < property_count; index++) {