Added getter API function to timer object for state-change-value (#1134)

* Added a new getter API function Timer_State_Change_Value_Get() to the timer object that returns state-change values by copying them to a caller-provided buffer, providing a safer alternative to the existing Timer_State_Change_Value() function which returns a direct pointer to internal data.
This commit is contained in:
Steve Karg
2025-11-10 12:12:23 -06:00
committed by GitHub
parent 28a30be5ec
commit 5574c9d3f1
4 changed files with 77 additions and 19 deletions
+24 -3
View File
@@ -559,7 +559,9 @@ static void test_Timer_Operation(void)
bool status = false;
BACNET_DEVICE_OBJECT_PROPERTY_REFERENCE member = { 0 };
BACNET_TIMER_STATE_CHANGE_VALUE *value = NULL;
BACNET_TIMER_STATE_CHANGE_VALUE state_change_value = { 0 };
BACNET_TIMER_STATE test_state = TIMER_STATE_IDLE;
BACNET_TIMER_TRANSITION transition;
BACNET_DATE_TIME bdatetime = { 0 };
uint32_t elapsed_time = 0;
unsigned members = 0, i = 0;
@@ -615,9 +617,28 @@ static void test_Timer_Operation(void)
value->tag = BACNET_APPLICATION_TAG_ENUMERATED;
value->type.Enumerated = BINARY_ACTIVE;
/* alternate API */
status = Timer_State_Change_Value_Set(
instance, TIMER_TRANSITION_EXPIRED_TO_RUNNING, value);
zassert_true(status, NULL);
transition = TIMER_TRANSITION_NONE;
while (transition != TIMER_TRANSITION_MAX) {
status = Timer_State_Change_Value_Get(
instance, transition, &state_change_value);
if (transition == TIMER_TRANSITION_NONE) {
zassert_false(status, NULL);
} else {
zassert_true(
status, "transition=%s",
bactext_timer_transition_name(transition));
}
status = Timer_State_Change_Value_Set(
instance, transition, &state_change_value);
if (transition == TIMER_TRANSITION_NONE) {
zassert_false(status, NULL);
} else {
zassert_true(
status, "transition=%s",
bactext_timer_transition_name(transition));
}
transition++;
}
/* start timer using a write to timer-running property to use defaults */
/* IDLE_TO_RUNNING */
status = Timer_State_Set(instance, TIMER_STATE_IDLE);