21 #ifndef MBED_ATCMDPARSER_H 22 #define MBED_ATCMDPARSER_H 25 #include "platform/Callback.h" 26 #include "platform/NonCopyable.h" 27 #include "platform/FileHandle.h" 67 const char *_output_delimiter;
68 int _output_delim_size;
94 int buffer_size = 256,
int timeout = 8000,
bool debug =
false)
95 : _fh(fh), _buffer_size(buffer_size), _oob_cb_count(0), _in_prev(0), _aborted(false), _oobs(NULL)
97 _buffer =
new char[buffer_size];
151 _output_delimiter = output_delimiter;
152 _output_delim_size = strlen(output_delimiter);
177 _dbg_on = (on) ? 1 : 0;
205 bool send(
const char *command, ...) MBED_PRINTF_METHOD(1, 2);
207 bool vsend(
const char *command, std::va_list args);
223 bool recv(
const char *response, ...) MBED_SCANF_METHOD(1, 2);
225 bool vrecv(
const char *response, std::va_list args);
249 int write(
const char *data,
int size);
258 int read(
char *data,
int size);
268 int printf(
const char *format, ...) MBED_PRINTF_METHOD(1, 2);
270 int vprintf(
const char *format, std::va_list args);
283 int scanf(
const char *format, ...) MBED_SCANF_METHOD(1, 2);
285 int vscanf(
const char *format, std::va_list args);
326 #endif //MBED_ATCMDPARSER_H void debug_on(uint8_t on)
Allows traces from modem to be turned on or off.
void setTimeout(int timeout)
For backward compatibility.
int getc()
Get a single byte from the underlying stream.
void set_timeout(int timeout)
Allows timeout to be changed between commands.
int scanf(const char *format,...) MBED_SCANF_METHOD(1
Direct scanf on underlying stream This function does not itself match whitespace in its format string...
int putc(char c)
Write a single byte to the underlying stream.
Prevents generation of copy constructor and copy assignment operator in derived classes.
void abort()
Abort current recv.
ATCmdParser(FileHandle *fh, const char *output_delimiter="\r", int buffer_size=256, int timeout=8000, bool debug=false)
Constructor.
void oob(const char *prefix, mbed::Callback< void()> func)
Attach a callback for out-of-band data.
bool recv(const char *response,...) MBED_SCANF_METHOD(1
Receive an AT response.
void debugOn(uint8_t on)
For backward compatibility.
int write(const char *data, int size)
Write an array of bytes to the underlying stream.
void set_delimiter(const char *output_delimiter)
Sets string of characters to use as line delimiters.
~ATCmdParser()
Destructor.
void flush()
Flushes the underlying stream.
Parser class for parsing AT commands.
bool process_oob(void)
Process out-of-band data.
int read(char *data, int size)
Read an array of bytes from the underlying stream.
int printf(const char *format,...) MBED_PRINTF_METHOD(1
Direct printf to underlying stream.
bool send(const char *command,...) MBED_PRINTF_METHOD(1
Sends an AT command.
void setDelimiter(const char *output_delimiter)
For backwards compatibility.