1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.bluetooth;
18
19import android.bluetooth.AtCommandResult;
20
21/**
22 * Handler Interface for {@link AtParser}.<p>
23 * @hide
24 */
25public abstract class AtCommandHandler {
26
27    /**
28     * Handle Basic commands "ATA".<p>
29     * These are single letter commands such as ATA and ATD. Anything following
30     * the single letter command ('A' and 'D' respectively) will be passed as
31     * 'arg'.<p>
32     * For example, "ATDT1234" would result in the call
33     * handleBasicCommand("T1234").<p>
34     * @param arg Everything following the basic command character.
35     * @return    The result of this command.
36     */
37    public AtCommandResult handleBasicCommand(String arg) {
38        return new AtCommandResult(AtCommandResult.ERROR);
39    }
40
41    /**
42     * Handle Actions command "AT+FOO".<p>
43     * Action commands are part of the Extended command syntax, and are
44     * typically used to signal an action on "FOO".<p>
45     * @return The result of this command.
46     */
47    public AtCommandResult handleActionCommand() {
48        return new AtCommandResult(AtCommandResult.ERROR);
49    }
50
51    /**
52     * Handle Read command "AT+FOO?".<p>
53     * Read commands are part of the Extended command syntax, and are
54     * typically used to read the value of "FOO".<p>
55     * @return The result of this command.
56     */
57    public AtCommandResult handleReadCommand() {
58        return new AtCommandResult(AtCommandResult.ERROR);
59    }
60
61    /**
62     * Handle Set command "AT+FOO=...".<p>
63     * Set commands are part of the Extended command syntax, and are
64     * typically used to set the value of "FOO". Multiple arguments can be
65     * sent.<p>
66     * AT+FOO=[<arg1>[,<arg2>[,...]]]<p>
67     * Each argument will be either numeric (Integer) or String.
68     * handleSetCommand is passed a generic Object[] array in which each
69     * element will be an Integer (if it can be parsed with parseInt()) or
70     * String.<p>
71     * Missing arguments ",," are set to empty Strings.<p>
72     * @param args Array of String and/or Integer's. There will always be at
73     *             least one element in this array.
74     * @return     The result of this command.
75     */
76    // Typically used to set this paramter
77    public AtCommandResult handleSetCommand(Object[] args) {
78        return new AtCommandResult(AtCommandResult.ERROR);
79    }
80
81    /**
82     * Handle Test command "AT+FOO=?".<p>
83     * Test commands are part of the Extended command syntax, and are typically
84     * used to request an indication of the range of legal values that "FOO"
85     * can take.<p>
86     * By defualt we return an OK result, to indicate that this command is at
87     * least recognized.<p>
88     * @return The result of this command.
89     */
90    public AtCommandResult handleTestCommand() {
91        return new AtCommandResult(AtCommandResult.OK);
92    }
93}
94