![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/platform/ATCmdParser.h@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /* Copyright (c) 2017 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 2 | * |
kadonotakashi | 0:8fdf9a60065b | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 4 | * you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 5 | * You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 6 | * |
kadonotakashi | 0:8fdf9a60065b | 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 8 | * |
kadonotakashi | 0:8fdf9a60065b | 9 | * Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 12 | * See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 13 | * limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 14 | * |
kadonotakashi | 0:8fdf9a60065b | 15 | * @section DESCRIPTION |
kadonotakashi | 0:8fdf9a60065b | 16 | * |
kadonotakashi | 0:8fdf9a60065b | 17 | * Parser for the AT command syntax |
kadonotakashi | 0:8fdf9a60065b | 18 | * |
kadonotakashi | 0:8fdf9a60065b | 19 | */ |
kadonotakashi | 0:8fdf9a60065b | 20 | #ifndef MBED_ATCMDPARSER_H |
kadonotakashi | 0:8fdf9a60065b | 21 | #define MBED_ATCMDPARSER_H |
kadonotakashi | 0:8fdf9a60065b | 22 | |
kadonotakashi | 0:8fdf9a60065b | 23 | #include "mbed.h" |
kadonotakashi | 0:8fdf9a60065b | 24 | #include <cstdarg> |
kadonotakashi | 0:8fdf9a60065b | 25 | #include "Callback.h" |
kadonotakashi | 0:8fdf9a60065b | 26 | |
kadonotakashi | 0:8fdf9a60065b | 27 | namespace mbed { |
kadonotakashi | 0:8fdf9a60065b | 28 | |
kadonotakashi | 0:8fdf9a60065b | 29 | /** \addtogroup platform */ |
kadonotakashi | 0:8fdf9a60065b | 30 | /** @{*/ |
kadonotakashi | 0:8fdf9a60065b | 31 | /** |
kadonotakashi | 0:8fdf9a60065b | 32 | * \defgroup platform_ATCmdParser ATCmdParser class |
kadonotakashi | 0:8fdf9a60065b | 33 | * @{ |
kadonotakashi | 0:8fdf9a60065b | 34 | */ |
kadonotakashi | 0:8fdf9a60065b | 35 | |
kadonotakashi | 0:8fdf9a60065b | 36 | /** |
kadonotakashi | 0:8fdf9a60065b | 37 | * Parser class for parsing AT commands |
kadonotakashi | 0:8fdf9a60065b | 38 | * |
kadonotakashi | 0:8fdf9a60065b | 39 | * Here are some examples: |
kadonotakashi | 0:8fdf9a60065b | 40 | * @code |
kadonotakashi | 0:8fdf9a60065b | 41 | * UARTSerial serial = UARTSerial(D1, D0); |
kadonotakashi | 0:8fdf9a60065b | 42 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); |
kadonotakashi | 0:8fdf9a60065b | 43 | * int value; |
kadonotakashi | 0:8fdf9a60065b | 44 | * char buffer[100]; |
kadonotakashi | 0:8fdf9a60065b | 45 | * |
kadonotakashi | 0:8fdf9a60065b | 46 | * at.send("AT") && at.recv("OK"); |
kadonotakashi | 0:8fdf9a60065b | 47 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); |
kadonotakashi | 0:8fdf9a60065b | 48 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); |
kadonotakashi | 0:8fdf9a60065b | 49 | * at.recv("+IPD,%d:", &value); |
kadonotakashi | 0:8fdf9a60065b | 50 | * at.read(buffer, value); |
kadonotakashi | 0:8fdf9a60065b | 51 | * at.recv("OK"); |
kadonotakashi | 0:8fdf9a60065b | 52 | * @endcode |
kadonotakashi | 0:8fdf9a60065b | 53 | */ |
kadonotakashi | 0:8fdf9a60065b | 54 | |
kadonotakashi | 0:8fdf9a60065b | 55 | class ATCmdParser : private NonCopyable<ATCmdParser> { |
kadonotakashi | 0:8fdf9a60065b | 56 | private: |
kadonotakashi | 0:8fdf9a60065b | 57 | // File handle |
kadonotakashi | 0:8fdf9a60065b | 58 | // Not owned by ATCmdParser |
kadonotakashi | 0:8fdf9a60065b | 59 | FileHandle *_fh; |
kadonotakashi | 0:8fdf9a60065b | 60 | |
kadonotakashi | 0:8fdf9a60065b | 61 | int _buffer_size; |
kadonotakashi | 0:8fdf9a60065b | 62 | char *_buffer; |
kadonotakashi | 0:8fdf9a60065b | 63 | int _timeout; |
kadonotakashi | 0:8fdf9a60065b | 64 | |
kadonotakashi | 0:8fdf9a60065b | 65 | // Parsing information |
kadonotakashi | 0:8fdf9a60065b | 66 | const char *_output_delimiter; |
kadonotakashi | 0:8fdf9a60065b | 67 | int _output_delim_size; |
kadonotakashi | 0:8fdf9a60065b | 68 | char _in_prev; |
kadonotakashi | 0:8fdf9a60065b | 69 | bool _dbg_on; |
kadonotakashi | 0:8fdf9a60065b | 70 | bool _aborted; |
kadonotakashi | 0:8fdf9a60065b | 71 | |
kadonotakashi | 0:8fdf9a60065b | 72 | struct oob { |
kadonotakashi | 0:8fdf9a60065b | 73 | unsigned len; |
kadonotakashi | 0:8fdf9a60065b | 74 | const char *prefix; |
kadonotakashi | 0:8fdf9a60065b | 75 | mbed::Callback<void()> cb; |
kadonotakashi | 0:8fdf9a60065b | 76 | oob *next; |
kadonotakashi | 0:8fdf9a60065b | 77 | }; |
kadonotakashi | 0:8fdf9a60065b | 78 | oob *_oobs; |
kadonotakashi | 0:8fdf9a60065b | 79 | |
kadonotakashi | 0:8fdf9a60065b | 80 | public: |
kadonotakashi | 0:8fdf9a60065b | 81 | |
kadonotakashi | 0:8fdf9a60065b | 82 | /** |
kadonotakashi | 0:8fdf9a60065b | 83 | * Constructor |
kadonotakashi | 0:8fdf9a60065b | 84 | * |
kadonotakashi | 0:8fdf9a60065b | 85 | * @param fh A FileHandle to a digital interface to use for AT commands |
kadonotakashi | 0:8fdf9a60065b | 86 | * @param output_delimiter end of command line termination |
kadonotakashi | 0:8fdf9a60065b | 87 | * @param buffer_size size of internal buffer for transaction |
kadonotakashi | 0:8fdf9a60065b | 88 | * @param timeout timeout of the connection |
kadonotakashi | 0:8fdf9a60065b | 89 | * @param debug turns on/off debug output for AT commands |
kadonotakashi | 0:8fdf9a60065b | 90 | */ |
kadonotakashi | 0:8fdf9a60065b | 91 | ATCmdParser(FileHandle *fh, const char *output_delimiter = "\r", |
kadonotakashi | 0:8fdf9a60065b | 92 | int buffer_size = 256, int timeout = 8000, bool debug = false) |
kadonotakashi | 0:8fdf9a60065b | 93 | : _fh(fh), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) |
kadonotakashi | 0:8fdf9a60065b | 94 | { |
kadonotakashi | 0:8fdf9a60065b | 95 | _buffer = new char[buffer_size]; |
kadonotakashi | 0:8fdf9a60065b | 96 | set_timeout(timeout); |
kadonotakashi | 0:8fdf9a60065b | 97 | set_delimiter(output_delimiter); |
kadonotakashi | 0:8fdf9a60065b | 98 | debug_on(debug); |
kadonotakashi | 0:8fdf9a60065b | 99 | } |
kadonotakashi | 0:8fdf9a60065b | 100 | |
kadonotakashi | 0:8fdf9a60065b | 101 | /** |
kadonotakashi | 0:8fdf9a60065b | 102 | * Destructor |
kadonotakashi | 0:8fdf9a60065b | 103 | */ |
kadonotakashi | 0:8fdf9a60065b | 104 | ~ATCmdParser() |
kadonotakashi | 0:8fdf9a60065b | 105 | { |
kadonotakashi | 0:8fdf9a60065b | 106 | while (_oobs) { |
kadonotakashi | 0:8fdf9a60065b | 107 | struct oob *oob = _oobs; |
kadonotakashi | 0:8fdf9a60065b | 108 | _oobs = oob->next; |
kadonotakashi | 0:8fdf9a60065b | 109 | delete oob; |
kadonotakashi | 0:8fdf9a60065b | 110 | } |
kadonotakashi | 0:8fdf9a60065b | 111 | delete[] _buffer; |
kadonotakashi | 0:8fdf9a60065b | 112 | } |
kadonotakashi | 0:8fdf9a60065b | 113 | |
kadonotakashi | 0:8fdf9a60065b | 114 | /** |
kadonotakashi | 0:8fdf9a60065b | 115 | * Allows timeout to be changed between commands |
kadonotakashi | 0:8fdf9a60065b | 116 | * |
kadonotakashi | 0:8fdf9a60065b | 117 | * @param timeout timeout of the connection |
kadonotakashi | 0:8fdf9a60065b | 118 | */ |
kadonotakashi | 0:8fdf9a60065b | 119 | void set_timeout(int timeout) |
kadonotakashi | 0:8fdf9a60065b | 120 | { |
kadonotakashi | 0:8fdf9a60065b | 121 | _timeout = timeout; |
kadonotakashi | 0:8fdf9a60065b | 122 | } |
kadonotakashi | 0:8fdf9a60065b | 123 | |
kadonotakashi | 0:8fdf9a60065b | 124 | /** |
kadonotakashi | 0:8fdf9a60065b | 125 | * For backwards compatibility. |
kadonotakashi | 0:8fdf9a60065b | 126 | * @deprecated Do not use this function. This function has been replaced with set_timeout for consistency. |
kadonotakashi | 0:8fdf9a60065b | 127 | * |
kadonotakashi | 0:8fdf9a60065b | 128 | * Please use set_timeout(int) API only from now on. |
kadonotakashi | 0:8fdf9a60065b | 129 | * Allows timeout to be changed between commands |
kadonotakashi | 0:8fdf9a60065b | 130 | * |
kadonotakashi | 0:8fdf9a60065b | 131 | * @param timeout timeout of the connection |
kadonotakashi | 0:8fdf9a60065b | 132 | */ |
kadonotakashi | 0:8fdf9a60065b | 133 | MBED_DEPRECATED_SINCE("mbed-os-5.5.0", "Replaced with set_timeout for consistency") |
kadonotakashi | 0:8fdf9a60065b | 134 | void setTimeout(int timeout) |
kadonotakashi | 0:8fdf9a60065b | 135 | { |
kadonotakashi | 0:8fdf9a60065b | 136 | set_timeout(timeout); |
kadonotakashi | 0:8fdf9a60065b | 137 | } |
kadonotakashi | 0:8fdf9a60065b | 138 | |
kadonotakashi | 0:8fdf9a60065b | 139 | /** |
kadonotakashi | 0:8fdf9a60065b | 140 | * Sets string of characters to use as line delimiters |
kadonotakashi | 0:8fdf9a60065b | 141 | * |
kadonotakashi | 0:8fdf9a60065b | 142 | * @param output_delimiter string of characters to use as line delimiters |
kadonotakashi | 0:8fdf9a60065b | 143 | */ |
kadonotakashi | 0:8fdf9a60065b | 144 | void set_delimiter(const char *output_delimiter) |
kadonotakashi | 0:8fdf9a60065b | 145 | { |
kadonotakashi | 0:8fdf9a60065b | 146 | _output_delimiter = output_delimiter; |
kadonotakashi | 0:8fdf9a60065b | 147 | _output_delim_size = strlen(output_delimiter); |
kadonotakashi | 0:8fdf9a60065b | 148 | } |
kadonotakashi | 0:8fdf9a60065b | 149 | |
kadonotakashi | 0:8fdf9a60065b | 150 | /** |
kadonotakashi | 0:8fdf9a60065b | 151 | * For backwards compatibility. |
kadonotakashi | 0:8fdf9a60065b | 152 | * @deprecated Do not use this function. This function has been replaced with set_delimiter for consistency. |
kadonotakashi | 0:8fdf9a60065b | 153 | * |
kadonotakashi | 0:8fdf9a60065b | 154 | * Please use set_delimiter(const char *) API only from now on. |
kadonotakashi | 0:8fdf9a60065b | 155 | * Sets string of characters to use as line delimiters |
kadonotakashi | 0:8fdf9a60065b | 156 | * |
kadonotakashi | 0:8fdf9a60065b | 157 | * @param output_delimiter string of characters to use as line delimiters |
kadonotakashi | 0:8fdf9a60065b | 158 | */ |
kadonotakashi | 0:8fdf9a60065b | 159 | MBED_DEPRECATED_SINCE("mbed-os-5.5.0", "Replaced with set_delimiter for consistency") |
kadonotakashi | 0:8fdf9a60065b | 160 | void setDelimiter(const char *output_delimiter) |
kadonotakashi | 0:8fdf9a60065b | 161 | { |
kadonotakashi | 0:8fdf9a60065b | 162 | set_delimiter(output_delimiter); |
kadonotakashi | 0:8fdf9a60065b | 163 | } |
kadonotakashi | 0:8fdf9a60065b | 164 | |
kadonotakashi | 0:8fdf9a60065b | 165 | /** |
kadonotakashi | 0:8fdf9a60065b | 166 | * Allows traces from modem to be turned on or off |
kadonotakashi | 0:8fdf9a60065b | 167 | * |
kadonotakashi | 0:8fdf9a60065b | 168 | * @param on set as 1 to turn on traces and vice versa. |
kadonotakashi | 0:8fdf9a60065b | 169 | */ |
kadonotakashi | 0:8fdf9a60065b | 170 | void debug_on(uint8_t on) |
kadonotakashi | 0:8fdf9a60065b | 171 | { |
kadonotakashi | 0:8fdf9a60065b | 172 | _dbg_on = (on) ? 1 : 0; |
kadonotakashi | 0:8fdf9a60065b | 173 | } |
kadonotakashi | 0:8fdf9a60065b | 174 | |
kadonotakashi | 0:8fdf9a60065b | 175 | /** |
kadonotakashi | 0:8fdf9a60065b | 176 | * For backwards compatibility. |
kadonotakashi | 0:8fdf9a60065b | 177 | * @deprecated Do not use this function. This function has been replaced with debug_on for consistency. |
kadonotakashi | 0:8fdf9a60065b | 178 | * |
kadonotakashi | 0:8fdf9a60065b | 179 | * Allows traces from modem to be turned on or off |
kadonotakashi | 0:8fdf9a60065b | 180 | * |
kadonotakashi | 0:8fdf9a60065b | 181 | * @param on set as 1 to turn on traces and vice versa. |
kadonotakashi | 0:8fdf9a60065b | 182 | */ |
kadonotakashi | 0:8fdf9a60065b | 183 | MBED_DEPRECATED_SINCE("mbed-os-5.5.0", "Replaced with debug_on for consistency") |
kadonotakashi | 0:8fdf9a60065b | 184 | void debugOn(uint8_t on) |
kadonotakashi | 0:8fdf9a60065b | 185 | { |
kadonotakashi | 0:8fdf9a60065b | 186 | debug_on(on); |
kadonotakashi | 0:8fdf9a60065b | 187 | } |
kadonotakashi | 0:8fdf9a60065b | 188 | |
kadonotakashi | 0:8fdf9a60065b | 189 | /** |
kadonotakashi | 0:8fdf9a60065b | 190 | * Sends an AT command |
kadonotakashi | 0:8fdf9a60065b | 191 | * |
kadonotakashi | 0:8fdf9a60065b | 192 | * Sends a formatted command using printf style formatting |
kadonotakashi | 0:8fdf9a60065b | 193 | * @see printf |
kadonotakashi | 0:8fdf9a60065b | 194 | * |
kadonotakashi | 0:8fdf9a60065b | 195 | * @param command printf-like format string of command to send which |
kadonotakashi | 0:8fdf9a60065b | 196 | * is appended with a newline |
kadonotakashi | 0:8fdf9a60065b | 197 | * @param ... all printf-like arguments to insert into command |
kadonotakashi | 0:8fdf9a60065b | 198 | * @return true only if command is successfully sent |
kadonotakashi | 0:8fdf9a60065b | 199 | */ |
kadonotakashi | 0:8fdf9a60065b | 200 | bool send(const char *command, ...) MBED_PRINTF_METHOD(1, 2); |
kadonotakashi | 0:8fdf9a60065b | 201 | |
kadonotakashi | 0:8fdf9a60065b | 202 | bool vsend(const char *command, va_list args); |
kadonotakashi | 0:8fdf9a60065b | 203 | |
kadonotakashi | 0:8fdf9a60065b | 204 | /** |
kadonotakashi | 0:8fdf9a60065b | 205 | * Receive an AT response |
kadonotakashi | 0:8fdf9a60065b | 206 | * |
kadonotakashi | 0:8fdf9a60065b | 207 | * Receives a formatted response using scanf style formatting |
kadonotakashi | 0:8fdf9a60065b | 208 | * @see scanf |
kadonotakashi | 0:8fdf9a60065b | 209 | * |
kadonotakashi | 0:8fdf9a60065b | 210 | * Responses are parsed line at a time. |
kadonotakashi | 0:8fdf9a60065b | 211 | * Any received data that does not match the response is ignored until |
kadonotakashi | 0:8fdf9a60065b | 212 | * a timeout occurs. |
kadonotakashi | 0:8fdf9a60065b | 213 | * |
kadonotakashi | 0:8fdf9a60065b | 214 | * @param response scanf-like format string of response to expect |
kadonotakashi | 0:8fdf9a60065b | 215 | * @param ... all scanf-like arguments to extract from response |
kadonotakashi | 0:8fdf9a60065b | 216 | * @return true only if response is successfully matched |
kadonotakashi | 0:8fdf9a60065b | 217 | */ |
kadonotakashi | 0:8fdf9a60065b | 218 | bool recv(const char *response, ...) MBED_SCANF_METHOD(1, 2); |
kadonotakashi | 0:8fdf9a60065b | 219 | |
kadonotakashi | 0:8fdf9a60065b | 220 | bool vrecv(const char *response, va_list args); |
kadonotakashi | 0:8fdf9a60065b | 221 | |
kadonotakashi | 0:8fdf9a60065b | 222 | /** |
kadonotakashi | 0:8fdf9a60065b | 223 | * Write a single byte to the underlying stream |
kadonotakashi | 0:8fdf9a60065b | 224 | * |
kadonotakashi | 0:8fdf9a60065b | 225 | * @param c The byte to write |
kadonotakashi | 0:8fdf9a60065b | 226 | * @return The byte that was written or -1 during a timeout |
kadonotakashi | 0:8fdf9a60065b | 227 | */ |
kadonotakashi | 0:8fdf9a60065b | 228 | int putc(char c); |
kadonotakashi | 0:8fdf9a60065b | 229 | |
kadonotakashi | 0:8fdf9a60065b | 230 | /** |
kadonotakashi | 0:8fdf9a60065b | 231 | * Get a single byte from the underlying stream |
kadonotakashi | 0:8fdf9a60065b | 232 | * |
kadonotakashi | 0:8fdf9a60065b | 233 | * @return The byte that was read or -1 during a timeout |
kadonotakashi | 0:8fdf9a60065b | 234 | */ |
kadonotakashi | 0:8fdf9a60065b | 235 | int getc(); |
kadonotakashi | 0:8fdf9a60065b | 236 | |
kadonotakashi | 0:8fdf9a60065b | 237 | /** |
kadonotakashi | 0:8fdf9a60065b | 238 | * Write an array of bytes to the underlying stream |
kadonotakashi | 0:8fdf9a60065b | 239 | * |
kadonotakashi | 0:8fdf9a60065b | 240 | * @param data the array of bytes to write |
kadonotakashi | 0:8fdf9a60065b | 241 | * @param size number of bytes to write |
kadonotakashi | 0:8fdf9a60065b | 242 | * @return number of bytes written or -1 on failure |
kadonotakashi | 0:8fdf9a60065b | 243 | */ |
kadonotakashi | 0:8fdf9a60065b | 244 | int write(const char *data, int size); |
kadonotakashi | 0:8fdf9a60065b | 245 | |
kadonotakashi | 0:8fdf9a60065b | 246 | /** |
kadonotakashi | 0:8fdf9a60065b | 247 | * Read an array of bytes from the underlying stream |
kadonotakashi | 0:8fdf9a60065b | 248 | * |
kadonotakashi | 0:8fdf9a60065b | 249 | * @param data the destination for the read bytes |
kadonotakashi | 0:8fdf9a60065b | 250 | * @param size number of bytes to read |
kadonotakashi | 0:8fdf9a60065b | 251 | * @return number of bytes read or -1 on failure |
kadonotakashi | 0:8fdf9a60065b | 252 | */ |
kadonotakashi | 0:8fdf9a60065b | 253 | int read(char *data, int size); |
kadonotakashi | 0:8fdf9a60065b | 254 | |
kadonotakashi | 0:8fdf9a60065b | 255 | /** |
kadonotakashi | 0:8fdf9a60065b | 256 | * Direct printf to underlying stream |
kadonotakashi | 0:8fdf9a60065b | 257 | * @see printf |
kadonotakashi | 0:8fdf9a60065b | 258 | * |
kadonotakashi | 0:8fdf9a60065b | 259 | * @param format format string to pass to printf |
kadonotakashi | 0:8fdf9a60065b | 260 | * @param ... arguments to printf |
kadonotakashi | 0:8fdf9a60065b | 261 | * @return number of bytes written or -1 on failure |
kadonotakashi | 0:8fdf9a60065b | 262 | */ |
kadonotakashi | 0:8fdf9a60065b | 263 | int printf(const char *format, ...) MBED_PRINTF_METHOD(1, 2); |
kadonotakashi | 0:8fdf9a60065b | 264 | |
kadonotakashi | 0:8fdf9a60065b | 265 | int vprintf(const char *format, va_list args); |
kadonotakashi | 0:8fdf9a60065b | 266 | |
kadonotakashi | 0:8fdf9a60065b | 267 | /** |
kadonotakashi | 0:8fdf9a60065b | 268 | * Direct scanf on underlying stream |
kadonotakashi | 0:8fdf9a60065b | 269 | * @see scanf |
kadonotakashi | 0:8fdf9a60065b | 270 | * |
kadonotakashi | 0:8fdf9a60065b | 271 | * @param format format string to pass to scanf |
kadonotakashi | 0:8fdf9a60065b | 272 | * @param ... arguments to scanf |
kadonotakashi | 0:8fdf9a60065b | 273 | * @return number of bytes read or -1 on failure |
kadonotakashi | 0:8fdf9a60065b | 274 | */ |
kadonotakashi | 0:8fdf9a60065b | 275 | int scanf(const char *format, ...) MBED_SCANF_METHOD(1, 2); |
kadonotakashi | 0:8fdf9a60065b | 276 | |
kadonotakashi | 0:8fdf9a60065b | 277 | int vscanf(const char *format, va_list args); |
kadonotakashi | 0:8fdf9a60065b | 278 | |
kadonotakashi | 0:8fdf9a60065b | 279 | /** |
kadonotakashi | 0:8fdf9a60065b | 280 | * Attach a callback for out-of-band data |
kadonotakashi | 0:8fdf9a60065b | 281 | * |
kadonotakashi | 0:8fdf9a60065b | 282 | * @param prefix string on when to initiate callback |
kadonotakashi | 0:8fdf9a60065b | 283 | * @param func callback to call when string is read |
kadonotakashi | 0:8fdf9a60065b | 284 | * @note out-of-band data is only processed during a scanf call |
kadonotakashi | 0:8fdf9a60065b | 285 | */ |
kadonotakashi | 0:8fdf9a60065b | 286 | void oob(const char *prefix, mbed::Callback<void()> func); |
kadonotakashi | 0:8fdf9a60065b | 287 | |
kadonotakashi | 0:8fdf9a60065b | 288 | /** |
kadonotakashi | 0:8fdf9a60065b | 289 | * Flushes the underlying stream |
kadonotakashi | 0:8fdf9a60065b | 290 | */ |
kadonotakashi | 0:8fdf9a60065b | 291 | void flush(); |
kadonotakashi | 0:8fdf9a60065b | 292 | |
kadonotakashi | 0:8fdf9a60065b | 293 | /** |
kadonotakashi | 0:8fdf9a60065b | 294 | * Abort current recv |
kadonotakashi | 0:8fdf9a60065b | 295 | * |
kadonotakashi | 0:8fdf9a60065b | 296 | * Can be called from oob handler to interrupt the current |
kadonotakashi | 0:8fdf9a60065b | 297 | * recv operation. |
kadonotakashi | 0:8fdf9a60065b | 298 | */ |
kadonotakashi | 0:8fdf9a60065b | 299 | void abort(); |
kadonotakashi | 0:8fdf9a60065b | 300 | |
kadonotakashi | 0:8fdf9a60065b | 301 | /** |
kadonotakashi | 0:8fdf9a60065b | 302 | * Process out-of-band data |
kadonotakashi | 0:8fdf9a60065b | 303 | * |
kadonotakashi | 0:8fdf9a60065b | 304 | * Process out-of-band data in the receive buffer. This function |
kadonotakashi | 0:8fdf9a60065b | 305 | * returns immediately if there is no data to process. |
kadonotakashi | 0:8fdf9a60065b | 306 | * |
kadonotakashi | 0:8fdf9a60065b | 307 | * @return true if oob data processed, false otherwise |
kadonotakashi | 0:8fdf9a60065b | 308 | */ |
kadonotakashi | 0:8fdf9a60065b | 309 | bool process_oob(void); |
kadonotakashi | 0:8fdf9a60065b | 310 | }; |
kadonotakashi | 0:8fdf9a60065b | 311 | |
kadonotakashi | 0:8fdf9a60065b | 312 | /**@}*/ |
kadonotakashi | 0:8fdf9a60065b | 313 | |
kadonotakashi | 0:8fdf9a60065b | 314 | /**@}*/ |
kadonotakashi | 0:8fdf9a60065b | 315 | |
kadonotakashi | 0:8fdf9a60065b | 316 | } //namespace mbed |
kadonotakashi | 0:8fdf9a60065b | 317 | |
kadonotakashi | 0:8fdf9a60065b | 318 | #endif //MBED_ATCMDPARSER_H |