3 * AT Server library with GLib integration
5 * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "gatresult.h"
35 typedef struct _GAtServer GAtServer;
37 /* V.250 Table 1/V.250 Result codes */
38 enum _GAtServerResult {
39 G_AT_SERVER_RESULT_OK = 0,
40 G_AT_SERVER_RESULT_CONNECT = 1,
41 G_AT_SERVER_RESULT_RING = 2,
42 G_AT_SERVER_RESULT_NO_CARRIER = 3,
43 G_AT_SERVER_RESULT_ERROR = 4,
44 G_AT_SERVER_RESULT_NO_DIALTONE = 6,
45 G_AT_SERVER_RESULT_BUSY = 7,
46 G_AT_SERVER_RESULT_NO_ANSWER = 8,
47 G_AT_SERVER_RESULT_EXT_ERROR = 256,
50 typedef enum _GAtServerResult GAtServerResult;
52 /* Types of AT command:
53 * COMMAND_ONLY: command without any sub-parameters, e.g. ATA, AT+CLCC
54 * QUERY: command followed by '?', e.g. AT+CPIN?
55 * SUPPORT: command followed by '=?', e.g. AT+CSMS=?
56 * SET: command followed by '=', e.g. AT+CLIP=1
57 * or, basic command followed with sub-parameters, e.g. ATD12345;
59 enum _GAtServerRequestType {
60 G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY,
61 G_AT_SERVER_REQUEST_TYPE_QUERY,
62 G_AT_SERVER_REQUEST_TYPE_SUPPORT,
63 G_AT_SERVER_REQUEST_TYPE_SET,
66 typedef enum _GAtServerRequestType GAtServerRequestType;
68 typedef void (*GAtServerNotifyFunc)(GAtServer *server,
69 GAtServerRequestType type,
70 GAtResult *result, gpointer user_data);
72 typedef void (*GAtServerFinishFunc)(GAtServer *server, gpointer user_data);
74 GAtServer *g_at_server_new(GIOChannel *io);
75 GIOChannel *g_at_server_get_channel(GAtServer *server);
76 GAtIO *g_at_server_get_io(GAtServer *server);
78 GAtServer *g_at_server_ref(GAtServer *server);
79 void g_at_server_suspend(GAtServer *server);
80 void g_at_server_resume(GAtServer *server);
81 void g_at_server_unref(GAtServer *server);
83 gboolean g_at_server_shutdown(GAtServer *server);
85 gboolean g_at_server_set_echo(GAtServer *server, gboolean echo);
86 gboolean g_at_server_set_disconnect_function(GAtServer *server,
87 GAtDisconnectFunc disconnect,
89 gboolean g_at_server_set_debug(GAtServer *server,
93 gboolean g_at_server_register(GAtServer *server, const char *prefix,
94 GAtServerNotifyFunc notify,
96 GDestroyNotify destroy_notify);
97 gboolean g_at_server_unregister(GAtServer *server, const char *prefix);
99 /* Send a final result code. E.g. G_AT_SERVER_RESULT_NO_DIALTONE */
100 void g_at_server_send_final(GAtServer *server, GAtServerResult result);
102 /* Send an extended final result code. E.g. +CME ERROR: SIM failure. */
103 void g_at_server_send_ext_final(GAtServer *server, const char *result);
105 /* Send an intermediate result code to report the progress. E.g. CONNECT */
106 void g_at_server_send_intermediate(GAtServer *server, const char *result);
108 /* Send an unsolicited result code. E.g. RING */
109 void g_at_server_send_unsolicited(GAtServer *server, const char *result);
112 * Send a single response line for the command. The line should be no longer
113 * than 2048 characters. If the response contains multiple lines, use
114 * FALSE for the 'last' parameter for lines 1 .. n -1, and 'TRUE' for the last
115 * line. This is required for formatting of 27.007 compliant multi-line
118 void g_at_server_send_info(GAtServer *server, const char *line, gboolean last);
120 gboolean g_at_server_set_finish_callback(GAtServer *server,
121 GAtServerFinishFunc finishf,
123 gboolean g_at_server_command_pending(GAtServer *server);
129 #endif /* __GATSERVER_H */