diff options
Diffstat (limited to 'gisi/client.c')
-rw-r--r-- | gisi/client.c | 28 |
1 files changed, 28 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]; |