From 08a12769bdd9bfdd68730873317f6171a35c83dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Thu, 26 May 2022 15:51:29 +0200 Subject: [PATCH] Add option to subscribe to single property COV (#283) --- src/bacnet/basic/service/s_cov.c | 11 +++++++++-- src/bacnet/cov.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bacnet/basic/service/s_cov.c b/src/bacnet/basic/service/s_cov.c index ccc12a81..aedb1fd4 100644 --- a/src/bacnet/basic/service/s_cov.c +++ b/src/bacnet/basic/service/s_cov.c @@ -142,8 +142,15 @@ uint8_t Send_COV_Subscribe( pdu_len = npdu_encode_pdu( &Handler_Transmit_Buffer[0], &dest, &my_address, &npdu_data); /* encode the APDU portion of the packet */ - len = cov_subscribe_encode_apdu(&Handler_Transmit_Buffer[pdu_len], - sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id, cov_data); + if (cov_data->covSubscribeToProperty) { + // subscribe to 1 property + len = cov_subscribe_property_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id, cov_data); + } else { + // subscribe to object + len = cov_subscribe_encode_apdu(&Handler_Transmit_Buffer[pdu_len], + sizeof(Handler_Transmit_Buffer) - pdu_len, invoke_id, cov_data); + } pdu_len += len; /* will it fit in the sender? note: if there is a bottleneck router in between diff --git a/src/bacnet/cov.h b/src/bacnet/cov.h index 06d9697e..92c450fb 100644 --- a/src/bacnet/cov.h +++ b/src/bacnet/cov.h @@ -45,6 +45,7 @@ typedef struct BACnet_Subscribe_COV_Data { bool cancellationRequest; /* true if this is a cancellation request */ bool issueConfirmedNotifications; /* optional */ uint32_t lifetime; /* seconds, optional */ + bool covSubscribeToProperty; /* true to use per-property subscription */ BACNET_PROPERTY_REFERENCE monitoredProperty; bool covIncrementPresent; /* true if present */ float covIncrement; /* optional */