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;
98 int vrecvscanf(
const char *response, std::va_list args,
bool multiline);
112 int buffer_size = 256,
int timeout = 8000,
bool debug =
false)
113 : _fh(fh), _buffer_size(buffer_size), _oob_cb_count(0), _in_prev(0), _aborted(false), _oobs(NULL)
115 _buffer =
new char[buffer_size];
152 _output_delimiter = output_delimiter;
153 _output_delim_size = strlen(output_delimiter);
163 _dbg_on = (on) ? 1 : 0;
177 bool send(
const char *command, ...) MBED_PRINTF_METHOD(1, 2);
179 bool vsend(const
char *command, std::va_list args);
195 bool recv(const
char *response, ...) MBED_SCANF_METHOD(1, 2);
197 bool vrecv(const
char *response, std::va_list args);
221 int write(const
char *data,
int size);
230 int read(
char *data,
int size);
240 int printf(const
char *format, ...) MBED_PRINTF_METHOD(1, 2);
242 int vprintf(const
char *format, std::va_list args);
255 int scanf(const
char *format, ...) MBED_SCANF_METHOD(1, 2);
257 int vscanf(const
char *format, std::va_list args);
266 void oob(const
char *prefix, mbed::
Callback<
void()> func);
Parser class for parsing AT commands.
void debug_on(uint8_t on)
Allows traces from modem to be turned on or off.
void set_delimiter(const char *output_delimiter)
Sets string of characters to use as line delimiters.
int getc()
Get a single byte from the underlying stream.
int write(const char *data, int size)
Write an array of bytes to the underlying stream.
int read(char *data, int size)
Read an array of bytes from the underlying stream.
~ATCmdParser()
Destructor.
bool send(const char *command,...) MBED_PRINTF_METHOD(1
Sends an AT command.
void set_timeout(int timeout)
Allows timeout to be changed between commands.
void oob(const char *prefix, mbed::Callback< void()> func)
Attach a callback for out-of-band data.
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 printf(const char *format,...) MBED_PRINTF_METHOD(1
Direct printf to underlying stream.
ATCmdParser(FileHandle *fh, const char *output_delimiter="\r", int buffer_size=256, int timeout=8000, bool debug=false)
Constructor.
void remove_oob(const char *prefix)
remove_oob Removes oob callback handler
bool recv(const char *response,...) MBED_SCANF_METHOD(1
Receive an AT response.
bool process_oob(void)
Process out-of-band data.
void abort()
Abort current recv.
int putc(char c)
Write a single byte to the underlying stream.
void flush()
Flushes the underlying stream.
Callback class based on template specialization.
Prevents generation of copy constructor and copy assignment operator in derived classes.