Mistake on this page?
Report an issue in GitHub or email us


ATCmdParser is an Mbed OS compatible AT command parser. AT commands are instructions used to communicate with a communication device such as a modem, phone or Wi-Fi module. Each command is a text string in ASCII format, and every command starts with "AT" characters followed by a command specifying the operation to be carried out.

The ATCmdParser class in Mbed OS implements functionality to send and receive AT commands to devices capable of communicating using AT commands. The ATCmdParser internally uses the driver for the communication channel to talk to the device. It expects the driver to implement the FileHandle interface to invoke the functions on the driver.

For example, the UARTSerial communication driver implements the FileHandle interface, and you can use it with ATCmdParser to send and receive AT commands to a device connected through UART. ATCmdParser also does AT command parsing, which validates the data format and separates command and data portion of AT transactions. The actual command set and the format of AT commands used depends on the communication device used. The vendor of the device you are communcating with specifies this command set and format.

To use the ATCmdParser, the entity creating the ATCmdParser object passes a reference of object implementing FileHandle interface as an argument to the ATCmdParser constructor. The ATCmdParser also supports configuring a specific output delimiter character sequence, depending on the interface or device connected to the communication interface.

ATCmdParser class reference

Public Member Functions
 ATCmdParser (FileHandle *fh, const char *output_delimiter="\r", int buffer_size=256, int timeout=8000, bool debug=false)
 ~ATCmdParser ()
void set_timeout (int timeout)
void setTimeout (int timeout)
void set_delimiter (const char *output_delimiter)
void setDelimiter (const char *output_delimiter)
void debug_on (uint8_t on)
void debugOn (uint8_t on)
bool send (const char *command,...) MBED_PRINTF_METHOD(1
bool bool vsend (const char *command, va_list args)
bool recv (const char *response,...) MBED_SCANF_METHOD(1
bool bool vrecv (const char *response, va_list args)
int putc (char c)
int getc ()
int write (const char *data, int size)
int read (char *data, int size)
int printf (const char *format,...) MBED_PRINTF_METHOD(1
int int vprintf (const char *format, va_list args)
int scanf (const char *format,...) MBED_SCANF_METHOD(1
int int vscanf (const char *format, va_list args)
void oob (const char *prefix, mbed::Callback< void()> func)
void flush ()
void abort ()
bool process_oob (void)

ATCmdParser examples

Example 1

/* ATCmdParser usage example
 * Copyright (c) 2016 ARM Limited
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

#include "mbed.h"
#include "platform\ATCmdParser.h"
#include "drivers\UARTSerial.h"

#define   ESP8266_DEFAULT_BAUD_RATE   115200

UARTSerial *_serial;
ATCmdParser *_parser;

int main()
    printf("\nATCmdParser with ESP8266 example");
    _serial = new UARTSerial(D1, D0, ESP8266_DEFAULT_BAUD_RATE);
    _parser = new ATCmdParser(_serial);
    _parser->debug_on( 1 );
    _parser->set_delimiter( "\r\n" );
    //Now get the FW version number of ESP8266 by sending an AT command 
    printf("\nATCmdParser: Retrieving FW version");
    int version;
    if(_parser->recv("SDK version:%d", &version) && _parser->recv("OK")) {
        printf("\nATCmdParser: FW version: %d", version);
        printf("\nATCmdParser: Retrieving FW version success");
    } else { 
        printf("\nATCmdParser: Retrieving FW version failed");
        return -1;


Example 2

You can find another real world example in the Wi-Fi driver implementation for an ESP8266 device. ESP8266 is a Wi-Fi module that you can connect to an SoC over UART for Wi-Fi support.

The above diagram shows how the ESP8266 Wi-Fi driver uses ATCmdParser to communicate with an ESP8266 device.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.