diff options
Diffstat (limited to 'src/qmicli/qmicli-wds.c')
-rw-r--r-- | src/qmicli/qmicli-wds.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c index aba7f0d..4705530 100644 --- a/src/qmicli/qmicli-wds.c +++ b/src/qmicli/qmicli-wds.c @@ -31,6 +31,7 @@ #include <libqmi-glib.h> #include "qmicli.h" +#include "qmicli-helpers.h" /* Context */ typedef struct { @@ -862,7 +863,7 @@ get_supported_messages_ready (QmiClientWds *client, QmiMessageWdsGetSupportedMessagesOutput *output; GError *error = NULL; GArray *bytearray = NULL; - GString *str = NULL; + gchar *str; output = qmi_client_wds_get_supported_messages_finish (client, res, &error); if (!output) { @@ -883,30 +884,11 @@ get_supported_messages_ready (QmiClientWds *client, g_print ("[%s] Successfully got supported WDS messages:\n", qmi_device_get_path_display (ctx->device)); - if (qmi_message_wds_get_supported_messages_output_get_list (output, &bytearray, NULL)) { - - guint bytearray_i; - - for (bytearray_i = 0; bytearray_i < bytearray->len; bytearray_i++) { - guint bit_i; - guint8 bytevalue; - - bytevalue = g_array_index (bytearray, guint8, bytearray_i); - for (bit_i = 0; bit_i < 8; bit_i++) { - if (bytevalue & (1 << bit_i)) { - if (!str) - str = g_string_new (""); - g_string_append_printf (str, "\t0x%04X\n", (bit_i + (8 * bytearray_i))); - } - } - } - } - - if (str) { - g_print ("%s", str->str); - g_string_free (str, TRUE); - } else - g_print ("\tnone\n"); + qmi_message_wds_get_supported_messages_output_get_list (output, &bytearray, NULL); + str = qmicli_get_supported_messages_list (bytearray ? (const guint8 *)bytearray->data : NULL, + bytearray ? bytearray->len : 0); + g_print ("%s", str); + g_free (str); qmi_message_wds_get_supported_messages_output_unref (output); shutdown (TRUE); |