#include <MessageProcessors.h>
Public Member Functions | |
CombinedMessageProcessor () | |
void | initialise () |
void | newMsg (uint16_t msgType) |
void | fieldUpdate (TagValueRemoteConnector *connector, FieldAndValue *field) |
void | addCustomMsgHandler (uint16_t msgType, FieldUpdateFunction callback) |
Static Public Member Functions | |
static void | setFormTemplatesInFlash (const EmbedControlFlashedForm **formTemplatesInFlash) |
static const EmbedControlFlashedForm ** | getFormTemplatesInFlash () |
This message processor is responsible for handling messages coming off the wire and processing them into usable events by the rest of the system. Usually, the message processor actually handles the event in full.
When a new message arrives, this class attempts to find a suitable processor function (or ignore if we can't process), then each field in the message is passed to the function to processed.
You can customize a message process by adding your own additional message types that it can process using the addCustomMsgHandler(..) function.
CombinedMessageProcessor::CombinedMessageProcessor | ( | ) |
Constructor takes an array of processors and the number of processors in the array.
void CombinedMessageProcessor::initialise | ( | ) |
Called by the remote server component to initialise the message handlers before use.
void CombinedMessageProcessor::newMsg | ( | uint16_t | msgType | ) |
Whenever there is a new message, this will be called, to re-initialise the internal state
void CombinedMessageProcessor::fieldUpdate | ( | TagValueRemoteConnector * | connector, |
FieldAndValue * | field | ||
) |
Called whenever a field has been processed in the current message, after a call to newMsg
|
inline |
If you want to be able to process a custom incoming message, simply add it here as a MsgHandler, see above. It can be a local, even inline object as it will be copy constructed to an internal list. Step 1. You define a custom message type using something similar to
`#define MSG_CUSTOM msgFieldToWord('Z','Z')`
Step 2. You create a function that is called back for each field as it arrives
Step 3. Register the processor