mirror of git://git.sysmocom.de/ofono
gisi: Add debugging hooks
This commit is contained in:
parent
53e575bd5c
commit
197cefbba5
|
@ -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,
|
||||
|
@ -135,6 +139,23 @@ uint8_t g_isi_client_resource(GIsiClient *client)
|
|||
return client->resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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];
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue