3#include <avr/pgmspace.h>
4#ifndef CommandCatcher_h
5#define CommandCatcher_h
33 virtual void notify(
char* cmd,
char* param);
61 void init(Stream& serial=Serial, uint8_t bufsize=16);
136 Stream& ser = Serial;
137 bool initialized =
false;
144 bool overrun =
false;
146 char terminator =
'\n';
147 char separator =
' ';
151 FListener(
void method(
char*,
char*)) : method(method) {}
153 void notify(
char* cmd,
char* param)
override {
157 void (*method)(
char*,
char*);
160 static const uint8_t maxListeners = 4;
161 CommandListener* listeners[maxListeners];
162 uint8_t numListeners = 0;
166 void notifyListeners();
CommandCatcher CCatcher
Definition CommandCatcher.cpp:17
Project: CommandCatcher for Arduino.
Definition CommandCatcher.h:37
void(* CCListener)(char *, char *)
Definition CommandCatcher.h:43
CommandCatcher()
default constructor
Definition CommandCatcher.cpp:19
bool ready()
Returns true if a command is ready to be processed.
Definition CommandCatcher.cpp:85
char * getParameter()
Returns the parameter string.
Definition CommandCatcher.cpp:93
void addListener(CCListener myListener)
Adds a listener to be called when a command is available.
Definition CommandCatcher.cpp:66
void setTerminator(char term)
Sets the terminator character.
Definition CommandCatcher.cpp:47
char * getCommand()
Returns the command.
Definition CommandCatcher.cpp:89
void update(bool close=true)
checks the Serial input stream and processes any command info available.
Definition CommandCatcher.cpp:55
void init(Stream &serial=Serial, uint8_t bufsize=16)
Initializes the serial interface for communication.
Definition CommandCatcher.cpp:22
void close()
Closes out the current command.
Definition CommandCatcher.cpp:78
void setSeparator(char sep)
Sets the separator character.
Definition CommandCatcher.cpp:51
abstract class to be implemented by listening class.
Definition CommandCatcher.h:23
virtual ~CommandListener()=default
virtual void notify(char *cmd, char *param)
called when a command s ready.