diff --git a/src/bacnet/bacapp.c b/src/bacnet/bacapp.c index 4b0fdf63..c5eef123 100644 --- a/src/bacnet/bacapp.c +++ b/src/bacnet/bacapp.c @@ -1546,6 +1546,8 @@ int bacapp_data_len( } else if (tag_number == opening_tag_number) { total_len_enable = true; opening_tag_number_counter++; + } else { + total_len_enable = true; } } else if (bacnet_is_closing_tag(apdu, apdu_len_max)) { len = bacnet_tag_number_and_value_decode( diff --git a/test/bacnet/bacapp/src/main.c b/test/bacnet/bacapp/src/main.c index 047caf84..6e1a2bfe 100644 --- a/test/bacnet/bacapp/src/main.c +++ b/test/bacnet/bacapp/src/main.c @@ -811,6 +811,23 @@ static void testBACnetApplicationDataLength(void) /* verify the length of the data inside the opening/closing tags */ len = bacapp_data_len(&apdu[0], apdu_len, PROP_REQUESTED_SHED_LEVEL); zassert_equal(test_len, len, NULL); + + /* 7. context opening & closing tag */ + test_len = 0; + apdu_len = 0; + len = encode_opening_tag(&apdu[apdu_len], 3); + apdu_len += len; + len = encode_opening_tag(&apdu[apdu_len], 0); + apdu_len += len; + test_len += len; + len = encode_closing_tag(&apdu[apdu_len], 0); + apdu_len += len; + test_len += len; + len = encode_closing_tag(&apdu[apdu_len], 3); + apdu_len += len; + /* verify the length of the data inside the opening/closing tags */ + len = bacapp_data_len(&apdu[0], apdu_len, PROP_WEEKLY_SCHEDULE); + zassert_equal(test_len, len, NULL); } /**