DAAPI B (b02)
- Java ME Embedded 3.3 Release

Package com.oracle.deviceaccess.atcmd

Interfaces and classes for controlling a Data Communication Equipment such as a modem or a cellular module using AT commands.

See: Description

Package com.oracle.deviceaccess.atcmd Description

Interfaces and classes for controlling a Data Communication Equipment such as a modem or a cellular module using AT commands.

AT commands for GSM phone or modem are standardized through ETSI GSM 07.07 and ETSI GSM 07.05 specifications. A typical modem or an cellular module supports most of its features through AT commands and many manufactures provide additional features by adding proprietary extensions to the AT commands set.

In this specification, a device that can be controlled using AT commands is generically referred to as an AT device.

To control a specific AT device, an application should first open and obtain an ATDevice or ATModem instance for the device the application wants to control, using its numerical ID, name, type (interface) and/or properties:

Using its ID
 ATDevice device = (ATDevice) PeripheralManager.open(15);
Using its name, properties and interface
 ATDevice device = (ATDevice) PeripheralManager.open("MODEM", ATDevice.class, new String[] {
         "javax.deviceaccess.atcmd.psd=true", "javax.deviceaccess.atcmd.sms=true" });
Or (with modem signals control properties),
 ATModem device = (ATModem) PeripheralManager.open("MODEM", ATModem.class, new String[] {
         "javax.deviceaccess.atcmd.psd=true", "javax.deviceaccess.atcmd.sms=true" });
Once the peripheral opened, the application can issue AT commands to the peripheral using methods of the ATDevice interface such as the sendCommand() methods.
When done, the application should call the ATDevice.close() method to release AT device.
The following sample codes give examples of using the AT API to send an SMS:
 public static final int SUBMITTED = 1;
 public static final int SENT = 2;
 public static final int ERROR = 3;
 private ATDevice modem = null;
 private int status = 0;
 private class SMSHandler implements CommandResponseHandler {
     String text;
     public SMSHandler(String text) {
         this.text = text;
     public String processResponse(ATDevice modem, String response) {
         // Assume that command echo has been previously disabled (such as with an ATE0 command).
         if (response.equals("> \n")) { // Prompt for text
             return text;
         } else if (response.equals("OK\n")) {
             status = SENT;  // Sent succesfully
         } else if (response.indexOf("ERROR") >= 0) {
             status = ERROR; // Failed to send
         return null;
 public boolean sendSMS(final String number, final String text) {
     // Acquire a modem with "sms" properties
     try {
         if (modem == null) {
             modem = (ATDevice) PeripheralManager.open(null, ATDevice.class,
                     new String[] { "javax.deviceaccess.atcmd.sms=true" });
         // Send SMS command
         SMSHandler sh = new SMSHandler(text);
         modem.sendCommand("AT+CMGS=\"" + number + "\"\n", sh);
         status = SUBMITTED;
         return true; // Submitted succesfully
     } catch (IOException ex) {
     } catch (PeripheralNotFoundException ex) {
     } catch (PeripheralTypeNotSupportedException ex) {
     } catch (PeripheralNotAvailableException ex) {
     return false;
 public int getStatus() {
     return status;
 public void close() {
     if (modem != null) {
         try {
         } catch (IOException ex) {
             // Ignored


AT devices are opened by invoking one of the com.oracle.deviceaccess.PeripheralManager.open methods. The permissions below allow access to be granted to AT devices as a whole as well as to to some of their protected functions.
Permission Function
"com.oracle.deviceaccess.atcmd" Access to AT devices and modems (as a whole)
"com.oracle.deviceaccess.atcmd.ATDevice.openDataConnection" Opening data connections
DAAPI B (b02)
5-February-2013 04:40

Copyright (c) 2012, Oracle and/or its affiliates. All Rights Reserved. Use of this specification is subject to license terms.