LSH-Core
A robust C++ framework for Arduino-based home automation nodes
Loading...
Searching...
No Matches
Deserializer Namespace Reference

Provides a function to deserialize and dispatch a received Json payload. More...

Classes

struct  DispatchResult
 Represents the result of a dispatch operation. More...
 

Functions

auto deserializeAndDispatch (const JsonDocument &doc) -> DispatchResult
 Main entry point for command processing. Deserializes a JSON document and immediately dispatches the corresponding action.
 

Detailed Description

Provides a function to deserialize and dispatch a received Json payload.

Function Documentation

◆ deserializeAndDispatch()

auto Deserializer::deserializeAndDispatch ( const JsonDocument &  doc) -> DispatchResult

Main entry point for command processing. Deserializes a JSON document and immediately dispatches the corresponding action.

Main entry point for command processing.

This function acts as a command dispatcher. It reads the command ID from the 'p' key and uses a switch statement for O(1) dispatching. It directly calls functions in other modules (Serializer, Actuators, NetworkClicks) to execute the command. This avoids intermediate state storage (like ResultsHolder) and multiple switch statements in the main loop, maximizing performance. The validation relies on a "validation by convention" approach, where a value of 0 for IDs or commands is treated as invalid, eliminating the need for containsKey checks.

Parameters
docA const reference to the parsed JsonDocument from EspCom.
Returns
DispatchResult A struct indicating the side-effects of the command, telling the main loop if a general state update needs to be sent or if network click timers need to be checked.
Here is the call graph for this function:
Here is the caller graph for this function: