summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAki Niemi <aki.niemi@nokia.com>2009-08-22 18:01:24 +0300
committerAki Niemi <aki.niemi@nokia.com>2009-08-22 18:01:24 +0300
commit197cefbba552845955b7cde4c9646fc7940b568e (patch)
tree22070ba832b861a799b7c37bc8f2d87b5cfab3bc
parent53e575bd5c0817029e756fe386632255ea0a4855 (diff)
downloadofono-197cefbba552845955b7cde4c9646fc7940b568e.tar.bz2
gisi: Add debugging hooks
-rw-r--r--gisi/client.c28
-rw-r--r--gisi/client.h6
2 files changed, 34 insertions, 0 deletions
diff --git a/gisi/client.c b/gisi/client.c
index 8f425659..06454c49 100644
--- a/gisi/client.c
+++ b/gisi/client.c
@@ -58,6 +58,10 @@ struct _GIsiClient {
GIsiIndicationFunc func[256];
void *data[256];
} ind;
+
+ /* Debugging */
+ GIsiDebugFunc debug_func;
+ void *debug_data;
};
static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond,
@@ -136,6 +140,23 @@ uint8_t g_isi_client_resource(GIsiClient *client)
}
/**
+ * Set a debugging function for @a client. This function will be
+ * called whenever an ISI protocol message is sent or received.
+ * @param client client to debug
+ * @param func debug function
+ * @param opaque user data
+ */
+void g_isi_client_set_debug(GIsiClient *client, GIsiDebugFunc func,
+ void *opaque)
+{
+ if (!client)
+ return;
+
+ client->debug_func = func;
+ client->debug_data = opaque;
+}
+
+/**
* Destroys an ISI client, cancels all pending transactions and subscriptions.
* @param client client to destroy
*/
@@ -202,6 +223,9 @@ GIsiRequest *g_isi_request_make(GIsiClient *cl, const void *__restrict buf,
return NULL;
}
+ if (cl->debug_func)
+ cl->debug_func(buf, len, cl->debug_data);
+
cl->func[id] = cb;
cl->data[id] = opaque;
@@ -360,6 +384,10 @@ static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond,
return TRUE;
msg = (uint8_t *)buf;
+
+ if (cl->debug_func)
+ cl->debug_func(msg, len, cl->debug_data);
+
if (indication) {
/* Message ID at offset 1 */
id = msg[1];
diff --git a/gisi/client.h b/gisi/client.h
index 8f9c7bfd..448f9e5c 100644
--- a/gisi/client.h
+++ b/gisi/client.h
@@ -46,10 +46,16 @@ typedef void (*GIsiIndicationFunc) (GIsiClient *client,
const void *restrict data, size_t len,
uint16_t object, void *opaque);
+typedef void (*GIsiDebugFunc) (const void *restrict data, size_t len,
+ void *opaque);
+
GIsiClient *g_isi_client_create(GIsiModem *modem, uint8_t resource);
uint8_t g_isi_client_resource(GIsiClient *client);
+void g_isi_client_set_debug(GIsiClient *client, GIsiDebugFunc func,
+ void *opaque);
+
void g_isi_client_destroy(GIsiClient *client);
int g_isi_client_error(const GIsiClient *client);