Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BufferedSerial
Dependents: SPWF01SA-lapi-1 SPWF01SA Nucleo-AWS-IoT-mbed
Fork of ATParser by
Revision 8:91515b168c70, committed 2015-07-20
- Comitter:
- geky
- Date:
- Mon Jul 20 20:56:30 2015 +0000
- Parent:
- 7:d1b193880af1
- Child:
- 9:9bcb87c27208
- Commit message:
- Removed broken command method. Command calls can be replaced by anded send/recv calls.
Changed in this revision
| ATParser.cpp | Show annotated file Show diff for this revision Revisions of this file |
| ATParser.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ATParser.cpp Mon Jul 20 18:23:54 2015 +0000
+++ b/ATParser.cpp Mon Jul 20 20:56:30 2015 +0000
@@ -195,20 +195,6 @@
return true;
}
-bool ATParser::vcommand(const char *command, const char *response, va_list args) {
- if (command) {
- if (!vsend(command, args))
- return false;
- }
-
- if (response) {
- if (!vrecv(response, args))
- return false;
- }
-
- return true;
-}
-
// Mapping to vararg functions
bool ATParser::send(const char *command, ...) {
@@ -226,11 +212,3 @@
va_end(args);
return res;
}
-
-bool ATParser::command(const char *command, const char *response, ...) {
- va_list args;
- va_start(args, response);
- bool res = vcommand(command, response, args);
- va_end(args);
- return res;
-}
--- a/ATParser.h Mon Jul 20 18:23:54 2015 +0000
+++ b/ATParser.h Mon Jul 20 20:56:30 2015 +0000
@@ -25,8 +25,22 @@
/**
-* The ATParser class wraps information about the serial in use
-*/
+ * Parser class for parsing AT commands
+ *
+ * Here are some examples:
+ * @code
+ * ATParser at = ATParser(serial, "\r\n");
+ * int value;
+ * char buffer[100];
+ *
+ * at.send("AT") && at.recv("OK");
+ * at.send("AT+CWMODE=%d", 3) && at.recv("OK");
+ * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value);
+ * at.recv("+IPD,%d:", &value);
+ * at.read(buffer, value);
+ * at.recv("OK");
+ * @endcode
+ */
class ATParser {
private:
// Serial information
@@ -48,8 +62,8 @@
* @param timeout timeout of the connection
* @param delimiter string of characters to use as line delimiters
*/
- ATParser(BufferedSerial *serial, int buffer_size = 256, int timeout = 8000,
- const char *delimiter = "\r\n") :
+ ATParser(BufferedSerial *serial, const char *delimiter = "\r\n",
+ int buffer_size = 256, int timeout = 8000) :
_serial(serial),
_buffer_size(buffer_size) {
_buffer = new char[buffer_size];
@@ -113,29 +127,6 @@
*/
bool recv(const char *response, ...);
bool vrecv(const char *response, va_list args);
-
- /**
- * Issue AT commands
- *
- * Issues formatted commands and parses formatted responses.
- * A command call is identical to a send call followed by a recv call.
- * @see send, recv
- *
- * Here are some examples:
- * @code
- * at.command("AT", "OK");
- * at.command("AT+CWMODE=%d", "OK", 3);
- * at.command("AT+CWMODE?", "+CWMODE:%d\r\nOK", &result);
- * @endcode
- *
- * @param command printf-like format string of command to send
- * @param response scanf-like format string of response to expect
- * @param ... all printf-like arguments to insert into command followed by
- * all scanf-like arguments to extract from response
- * @return true only if response is successfully matched
- */
- bool command(const char *command, const char *response, ...);
- bool vcommand(const char *command, const char *response, va_list args);
/**
* Write a single byte to the underlying stream
