3 * AT chat library with GLib integration
5 * Copyright (C) 2008-2009 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"
33 typedef struct _GAtChat GAtChat;
35 typedef void (*GAtResultFunc)(gboolean success, GAtResult *result,
37 typedef void (*GAtNotifyFunc)(GAtResult *result, gpointer user_data);
38 typedef void (*GAtDisconnectFunc)(gpointer user_data);
41 G_AT_CHAT_FLAG_NO_LEADING_CRLF = 1, /* Some emulators are broken */
44 typedef enum _GAtChatFlags GAtChatFlags;
46 GAtChat *g_at_chat_new(GIOChannel *channel, int flags);
48 GAtChat *g_at_chat_ref(GAtChat *chat);
49 void g_at_chat_unref(GAtChat *chat);
51 gboolean g_at_chat_shutdown(GAtChat *chat);
53 gboolean g_at_chat_set_disconnect_function(GAtChat *chat,
54 GAtDisconnectFunc disconnect, gpointer user_data);
57 * Queue an AT command for execution. The command contents are given
58 * in cmd. Once the command executes, the callback function given by
59 * func is called with user provided data in user_data.
61 * Returns an id of the queued command which can be canceled using
62 * g_at_chat_cancel. If an error occurred, an id of 0 is returned.
64 * This function can be used in three ways:
65 * - Send a simple command such as g_at_chat_send(p, "AT+CGMI?", ...
67 * - Send a compound command: g_at_chat_send(p, "AT+CMD1;+CMD2", ...
69 * - Send a command requiring a prompt. The command up to '\r' is sent
70 * after which time a '> ' prompt is expected from the modem. Further
71 * contents of the command are sent until a '\r' or end of string is
72 * encountered. If end of string is encountered, the Ctrl-Z character
73 * is sent automatically. There is no need to include the Ctrl-Z
76 * The valid_resp field can be used to send an array of strings which will
77 * be accepted as a valid response for this command. This is treated as a
78 * simple prefix match. If a response line comes in from the modem and it
79 * does not match any of the prefixes in valid_resp, it is treated as an
80 * unsolicited notification. If valid_resp is NULL, then all response
81 * lines after command submission and final response line are treated as
82 * part of the command response. This can be used to get around broken
83 * modems which send unsolicited notifications during command processing.
85 guint g_at_chat_send(GAtChat *chat, const char *cmd,
86 const char **valid_resp, GAtResultFunc func,
87 gpointer user_data, GDestroyNotify notify);
89 gboolean g_at_chat_cancel(GAtChat *chat, guint id);
91 guint g_at_chat_register(GAtChat *chat, const char *prefix,
92 GAtNotifyFunc func, gboolean expect_pdu,
93 gpointer user_data, GDestroyNotify notify);
95 gboolean g_at_chat_unregister(GAtChat *chat, guint id);
97 gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
98 guint timeout, guint msec);
105 #endif /* __GATCHAT_H */