pfodParser 5.0.1 The pfodParser library is handles commands sent from the Android pfodApp, pfodApp supports WiFi, BLE, Bluetooth and SMS connections

pfodRawCmdParser.h
Go to the documentation of this file.
1 #ifndef pfodRawCmdParser_h
2 #define pfodRawCmdParser_h
25 /*
26 (c)2014-2017 Forward Computing and Control Pty. Ltd.
27 NSW Australia, www.forward.com.au
28 This code is not warranted to be fit for any purpose. You may only use it at your own risk.
29 This code may be freely used for both private and commercial use
30 Provide this copyright is maintained.
31 */
32
33 #include "Arduino.h"
34
35 #include "pfodStream.h"
36 #include "pfodParser.h"
37
38 // used to suppress warning
39 #define pfod_MAYBE_UNUSED(x) (void)(x)
40
41 class pfodRawCmdParser: public Stream {
42 public:
43 pfodRawCmdParser();
44 void connect(Stream* ioPtr);
45
46 byte parse();
47 byte* getRawCmd();
54 byte getParserState();
55 //void setCmd(byte cmd);
56 //void setDebugStream(Print* debugOut); // does nothing
57 size_t write(uint8_t c);
58 int available();
59 int read();
60 int peek();
61 void flush();
62 Stream* getPfodAppStream(); // get the command response stream we are writing to
63 // for pfodRawCmdParser this is also the rawData stream
64
65 // this is returned if pfodDevice should drop the connection
66 // only returned by pfodRawCmdParser in read() returns -1
67 void init();
68 byte parse(byte in);
69 void setDisconnect(); // sets parser to {!}
70 void closeConnection();
71 private:
72 //static const byte DisconnectNow = '!';
73 Stream* io;
74 // you can reduce this value in pfodParser.h if you are sending shorter commands. Most pfod commands are very short <20 bytes, but depends on the pfod menu items you serve.
75 // but never increase it.
76 static const byte pfodMaxMsgLen = pfodParser::pfodMaxMsgLen; //0xff; // == 255, if no closing } by now ignore msg
77 byte emptyVersion[1];
78 byte readIdx;
79 byte argsIdx;
80 byte argsCount; // no of arguments found in msg
81 byte parserState;
82 byte args[pfodMaxMsgLen + 1]; // allow for trailing null
83 byte *versionStart;
84 byte *cmdStart;
85 bool refresh;
86 static const byte pfodWaitingForStart = 0xff;
87 static const byte pfodMsgStarted = '{';
88 static const byte pfodRefresh = ':';
89 static const byte pfodInMsg = 0;
90 static const byte pfodMsgEnd = '}';
91 static const byte pfodBar = (byte)'|';
92 static const byte pfodTilda = (byte)'~';
93 static const byte pfodAccent = (byte)'`';
94 static const byte pfodArgStarted = 0xfe;
95 };
96
97 #endif // pfodParser_h
98
pfodParser::pfodMaxMsgLen
static const byte pfodMaxMsgLen
Definition: pfodParser.h:65
pfodRawCmdParser
Definition: pfodRawCmdParser.h:41
pfodRawCmdParser::flush
void flush()
pfodRawCmdParser::getRawCmd
byte * getRawCmd()
pfodRawCmdParser::write
size_t write(uint8_t c)
pfodRawCmdParser::getPfodAppStream
Stream * getPfodAppStream()
pfodRawCmdParser::parse
byte parse(byte in)
pfodRawCmdParser::parse
byte parse()
pfodRawCmdParser::pfodRawCmdParser
pfodRawCmdParser()
pfodRawCmdParser::connect
void connect(Stream *ioPtr)
pfodRawCmdParser::getParserState
byte getParserState()
pfodWaitingForStart if outside msg pfodMsgStarted if just seen opening { pfodInMsg in msg after { pfo...
pfodRawCmdParser::setDisconnect
void setDisconnect()
pfodRawCmdParser::available
int available()
pfodRawCmdParser::closeConnection
void closeConnection()
pfodRawCmdParser::peek
int peek()
pfodRawCmdParser::read
int read()
pfodRawCmdParser::init
void init()
pfodParser.h
pfodStream.h