3
* RIL library with GLib integration
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
6
* Copyright (C) 2012 Canonical Ltd.
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License version 2 as
10
* published by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33
#include "ril_constants.h"
34
#include "drivers/rilmodem/vendor.h"
36
#define RIL_MAX_NUM_ACTIVE_DATA_CALLS 2
40
typedef struct _GRil GRil;
43
* This struct represents an entire RIL message read
44
* from the command socket. It can hold responses or
45
* unsolicited requests from RILD.
56
typedef void (*GRilResponseFunc)(struct ril_msg *message, gpointer user_data);
58
typedef void (*GRilNotifyFunc)(struct ril_msg *message, gpointer user_data);
60
typedef const char *(*GRilMsgIdToStrFunc)(int msg_id);
65
* @arg...: list of arguments
67
* Simple macro around ofono_debug() used for tracing RIL messages
68
* name it is called in.
70
#define G_RIL_TRACE(gril, fmt, arg...) do { \
71
if (gril && g_ril_get_trace(gril)) \
72
ofono_debug(fmt, ## arg); \
75
extern char print_buf[];
77
#define g_ril_print_request(gril, token, req) \
78
G_RIL_TRACE(gril, "[%04d]> %s %s", token, \
79
g_ril_request_id_to_string(gril, req), print_buf)
80
#define g_ril_print_request_no_args(gril, token, req) \
81
G_RIL_TRACE(gril, "[%04d]> %s", token, \
82
g_ril_request_id_to_string(gril, req))
83
#define g_ril_print_response(gril, message) \
84
G_RIL_TRACE(gril, "[%04d]< %s %s", message->serial_no, \
85
g_ril_request_id_to_string(gril, message->req), \
87
#define g_ril_print_response_no_args(gril, message) \
88
G_RIL_TRACE(gril, "[%04d]< %s", message->serial_no, \
89
g_ril_request_id_to_string(gril, message->req))
91
#define g_ril_append_print_buf(gril, x...) do { \
92
if (gril && g_ril_get_trace(gril)) \
93
sprintf(print_buf, x); \
96
#define g_ril_print_unsol(gril, message) \
97
G_RIL_TRACE(gril, "[UNSOL]< %s %s", \
98
g_ril_unsol_request_to_string(gril, \
101
#define g_ril_print_unsol_no_args(gril, message) \
102
G_RIL_TRACE(gril, "[UNSOL]< %s", \
103
g_ril_unsol_request_to_string(gril, message->req))
105
void g_ril_init_parcel(const struct ril_msg *message, struct parcel *rilp);
107
GRil *g_ril_new(const char *sock_path, enum ofono_ril_vendor vendor);
109
GIOChannel *g_ril_get_channel(GRil *ril);
110
GRilIO *g_ril_get_io(GRil *ril);
112
GRil *g_ril_ref(GRil *ril);
113
void g_ril_unref(GRil *ril);
115
GRil *g_ril_clone(GRil *ril);
117
void g_ril_set_disconnect_function(GRil *ril, GRilDisconnectFunc disconnect,
120
gboolean g_ril_get_trace(GRil *ril);
121
gboolean g_ril_set_trace(GRil *ril, gboolean trace);
124
* If the function is not NULL, then on every read/write from the GIOChannel
125
* provided to GRil the logging function will be called with the
126
* input/output string and user data
128
gboolean g_ril_set_debugf(GRil *ril, GRilDebugFunc func, gpointer user_data);
130
gboolean g_ril_set_vendor_print_msg_id_funcs(GRil *ril,
131
GRilMsgIdToStrFunc req_to_string,
132
GRilMsgIdToStrFunc unsol_to_string);
136
* Queue an RIL request for execution. The request contents are given
137
* in data. Once the command executes, the callback function given by
138
* func is called with user provided data in user_data.
140
* Returns an id of the queued command which can be canceled using
141
* g_ril_cancel. If an error occurred, an id of 0 is returned.
144
gint g_ril_send(GRil *ril, const gint reqid, struct parcel *rilp,
145
GRilResponseFunc func, gpointer user_data,
146
GDestroyNotify notify);
148
guint g_ril_register(GRil *ril, const int req,
149
GRilNotifyFunc func, gpointer user_data);
151
gboolean g_ril_unregister(GRil *ril, guint id);
152
gboolean g_ril_unregister_all(GRil *ril);
154
enum ofono_ril_vendor g_ril_vendor(GRil *ril);
156
const char *g_ril_request_id_to_string(GRil *ril, int req);
157
const char *g_ril_unsol_request_to_string(GRil *ril, int req);
163
#endif /* __GRIL_H */