Remove obsolete file.
[connman] / gatchat / gatchat.h
1 /*
2  *
3  *  AT chat library with GLib integration
4  *
5  *  Copyright (C) 2008-2009  Intel Corporation. All rights reserved.
6  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef __GATCHAT_H
23 #define __GATCHAT_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include "gatresult.h"
30
31 struct _GAtChat;
32
33 typedef struct _GAtChat GAtChat;
34
35 typedef void (*GAtResultFunc)(gboolean success, GAtResult *result,
36                                 gpointer user_data);
37 typedef void (*GAtNotifyFunc)(GAtResult *result, gpointer user_data);
38 typedef void (*GAtDisconnectFunc)(gpointer user_data);
39
40 enum _GAtChatFlags {
41         G_AT_CHAT_FLAG_NO_LEADING_CRLF = 1,     /* Some emulators are broken */
42 };
43
44 typedef enum _GAtChatFlags GAtChatFlags;
45
46 GAtChat *g_at_chat_new(GIOChannel *channel, int flags);
47
48 GAtChat *g_at_chat_ref(GAtChat *chat);
49 void g_at_chat_unref(GAtChat *chat);
50
51 gboolean g_at_chat_shutdown(GAtChat *chat);
52
53 gboolean g_at_chat_set_disconnect_function(GAtChat *chat,
54                         GAtDisconnectFunc disconnect, gpointer user_data);
55
56 /*!
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.
60  *
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.
63  *
64  * This function can be used in three ways:
65  *      - Send a simple command such as g_at_chat_send(p, "AT+CGMI?", ...
66  *
67  *      - Send a compound command: g_at_chat_send(p, "AT+CMD1;+CMD2", ...
68  *
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
74  *        by the caller.
75  *
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.
84  */
85 guint g_at_chat_send(GAtChat *chat, const char *cmd,
86                                 const char **valid_resp, GAtResultFunc func,
87                                 gpointer user_data, GDestroyNotify notify);
88
89 gboolean g_at_chat_cancel(GAtChat *chat, guint id);
90
91 guint g_at_chat_register(GAtChat *chat, const char *prefix,
92                                 GAtNotifyFunc func, gboolean expect_pdu,
93                                 gpointer user_data, GDestroyNotify notify);
94
95 gboolean g_at_chat_unregister(GAtChat *chat, guint id);
96
97 gboolean g_at_chat_set_wakeup_command(GAtChat *chat, const char *cmd,
98                                         guint timeout, guint msec);
99
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* __GATCHAT_H */