Build 1.0_r1(from source)

android.bluetooth
Class AtParser

java.lang.Object
  extended by android.bluetooth.AtParser

public class AtParser
extends Object

An AT (Hayes command) Parser based on (a subset of) the ITU-T V.250 standard.

Conforment with the subset of V.250 required for implementation of the Bluetooth Headset and Handsfree Profiles, as per Bluetooth SIP specifications. Also implements some V.250 features not required by Bluetooth - such as chained commands.

Command handlers are registered with an AtParser object. These handlers are invoked when command lines are processed by AtParser's process() method.

The AtParser object accepts a new command line to parse via its process() method. It breaks each command line into one or more commands. Each command is parsed for name, type, and (optional) arguments, and an appropriate external handler method is called through the AtCommandHandler interface. The command types are

In V.250 the last four command types are known as Extended Commands, and they are used heavily in Bluetooth.

Basic commands cannot be chained in this implementation. For Bluetooth headset/handsfree use this is acceptable, because they only use the basic commands ATA and ATD, which are not allowed to be chained. For general V.250 use we would need to improve this class to allow Basic command chaining - however its tricky to get right becuase there is no deliminator for Basic command chaining.

Extended commands can be chained. For example:

AT+VGM?;+VGM=14;+CIMI

This is equivalent to:

AT+VGM? AT+VGM=14 AT+CIMI Except that only one final result code is return (although several intermediate responses may be returned), and as soon as one command in the chain fails the rest are abandonded.

Handlers are registered by there command name via register(Char c, ...) or register(String s, ...). Handlers for Basic command should be registered by the basic command character, and handlers for Extended commands should be registered by String.

Refer to:


Constructor Summary
AtParser()
          Create a new AtParser.
 
Method Summary
 AtCommandResult process(String raw_input)
          Processes an incoming AT command line.
 void register(Character command, AtCommandHandler handler)
          Register a Basic command handler.
 void register(String command, AtCommandHandler handler)
          Register an Extended command handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AtParser

public AtParser()
Create a new AtParser.

No handlers are registered.

Method Detail

register

public void register(Character command,
                     AtCommandHandler handler)
Register a Basic command handler.

Basic command handlers are later called via their handleBasicCommand(String args) method.

Parameters:
command - Command name - a single character
handler - Handler to register

register

public void register(String command,
                     AtCommandHandler handler)
Register an Extended command handler.

Extended command handlers are later called via:

Only one method will be called for each command processed.

Parameters:
command - Command name - can be multiple characters
handler - Handler to register

process

public AtCommandResult process(String raw_input)
Processes an incoming AT command line.

This method will invoke zero or one command handler methods for each command in the command line.

Parameters:
raw_input - The AT input, without EOL deliminator (e.g. ).
Returns:
Result object for this command line. This can be converted to a String[] response with toStrings().

Build 1.0_r1(from source)

Please submit a feedback, bug or feature