47 lines
781 B
C
Raw Permalink Normal View History

2014-02-23 21:12:13 +01:00
#ifndef CMD_H_
#define CMD_H_
#include <Arduino.h>
#include <stdint.h>
#include <WString.h>
#include <Print.h>
#include <Stream.h>
static const uint8_t NUM_OF_COMMANDS = 10;
class CmdServer;
class Cmd {
public:
virtual ~Cmd() {};
void setClient(Stream *p_stream) { m_stream = p_stream; };
virtual String exec(String params) =0;
virtual String getCmdName() =0;
virtual String getHelp() =0;
virtual void registerYourself(CmdServer *cmdServer);
protected:
Stream *m_stream;
};
class CmdServer {
public:
CmdServer(Stream *p_stream);
void begin();
void exec();
void registerCmd(Cmd *cmdObj);
private:
void parseCommand();
Stream *m_stream;
String cmd;
String params;
uint8_t cmdListIdx;
Cmd *cmdList[NUM_OF_COMMANDS];
};
#endif /* CMD_H_ */