/* * SPDX-FileCopyrightText: 2025 Kozmotronik Tech * * SPDX-License-Identifier: MIT */ #include "test_relay_chn_notify_common.h" listener_callback_info_t listener1_info; listener_callback_info_t listener2_info; // --- Globals for Advanced Tests --- SemaphoreHandle_t blocking_listener_sem = NULL; SemaphoreHandle_t log_check_sem = NULL; volatile int blocking_listener_call_count = 0; vprintf_like_t original_vprintf = NULL; // --- Listener Test Helper Functions --- // Clear the memory from possible garbage values void reset_listener_info(listener_callback_info_t* info) { memset(info, 0, sizeof(listener_callback_info_t)); } void test_listener_1(uint8_t chn_id, relay_chn_state_t old_state, relay_chn_state_t new_state) { listener1_info.chn_id = chn_id; listener1_info.old_state = old_state; listener1_info.new_state = new_state; listener1_info.call_count++; } void test_listener_2(uint8_t chn_id, relay_chn_state_t old_state, relay_chn_state_t new_state) { listener2_info.chn_id = chn_id; listener2_info.old_state = old_state; listener2_info.new_state = new_state; listener2_info.call_count++; } void blocking_listener(uint8_t chn_id, relay_chn_state_t old_state, relay_chn_state_t new_state) { blocking_listener_call_count++; // Block until the main test task unblocks us xSemaphoreTake(blocking_listener_sem, portMAX_DELAY); } int log_check_vprintf(const char *format, va_list args) { // Buffer to hold the formatted log message char buffer[256]; vsnprintf(buffer, sizeof(buffer), format, args); if (strstr(buffer, "Notify queue is full")) { xSemaphoreGive(log_check_sem); } return original_vprintf(format, args); }