timeout Helper

template<size_t MaxDeps = 8, size_t HistorySize = 0, typename Source>
TimeoutSignal<Source, MaxDeps, HistorySize> RxESP32::Helpers::Temporal::timeout(Source &source, const uint32_t timeout_ms, const decltype(source.get()) &fallback_value, const typename Effect<1>::Options &options = {})

Create a timeout-monitored signal that falls back to a default value.

Wraps a source Signal with timeout monitoring using FreeRTOS timers. If the source doesn’t update within the specified timeout period, the Signal automatically switches to the fallback value. The timer resets whenever the source updates.

Since

v0.1.0

Signal<float> temperature;
auto monitored = timeout(temperature, 10000, -999.0f); // 10s timeout

temperature.set(22.5);         // monitored.signal().get() == 22.5
delay(11000);                  // Timeout!
                               // monitored.signal().get() == -999.0
temperature.set(23.0);         // monitored.signal().get() == 23.0 (recovered)

Note

  • Uses a FreeRTOS one-shot timer that resets on each source update.

  • The internal Effect occupies 1 dependency slot on the source.

Template Parameters:
size_t MaxDeps = 8

Maximum number of dependents for the result Signal.

size_t HistorySize = 0

Size of the history buffer (0 disables history).

Parameters:
Source &source

Source Signal to monitor.

const uint32_t timeout_ms

Timeout duration in milliseconds.

const decltype(source.get()) &fallback_value

Value to use when timeout expires.

const typename Effect<1>::Options &options = {}

Effect options for the internal monitor (name, priority, lazy).

Returns:

TimeoutSignal wrapper providing access to the monitored Signal.

See Also