diff --git a/src/qmicli/qmicli-pdc.c b/src/qmicli/qmicli-pdc.c index 2e53d57..61b1442 100644 --- a/src/qmicli/qmicli-pdc.c +++ b/src/qmicli/qmicli-pdc.c @@ -60,6 +60,7 @@ typedef struct { GCancellable *cancellable; /* local data */ + guint timeout_id; GArray *config_list; guint configs_loaded; GArray *active_config_id; @@ -248,6 +249,27 @@ status_string (GArray *id) return "Inactive"; } +static char * +printable_id (GArray * id) +{ + if (!id) { + return g_strdup ("null"); + } else if (id->len == 0) { + return g_strdup ("none"); + } else { + GString *printable; + int i; + + printable = g_string_new (""); + for (i = 0; i < id->len; i++) { + guint8 ch = g_array_index (id, guint8, i); + + g_string_append_printf (printable, "%02hhX", ch); + } + return g_string_free (printable, FALSE); + } +} + static void print_configs (GArray *configs) { @@ -266,8 +288,9 @@ print_configs (GArray *configs) g_printf ("\tSize: %u\n", current_config->total_size); g_printf ("\tStatus: %s\n", status_string (current_config->id)); g_printf ("\tVersion: 0x%X\n", current_config->version); - id_str = qmicli_get_raw_data_printable (current_config->id, 80, ""); - g_printf ("\tID: %s\n", id_str ? "none" : ""); + g_printf ("\tIDX: %u\n", current_config->id->len); + id_str = printable_id (current_config->id); + g_printf ("\tID: %s\n", id_str); g_free (id_str); } } @@ -276,7 +299,7 @@ static void check_list_config_completed (void) { if (ctx->configs_loaded == ctx->config_list->len && - ctx->ids_loaded) { + (ctx->configs_loaded == 0 || ctx->ids_loaded)) { print_configs (ctx->config_list); operation_shutdown (TRUE); } @@ -367,6 +390,18 @@ get_config_info_ready_indication (QmiClientPdc *client, check_list_config_completed (); } +static gboolean +list_configs_timeout (gpointer userdata) +{ + // No indication yet, cancelling + if (ctx->config_list == NULL) { + g_printf ("Total configurations: 0\n"); + operation_shutdown (TRUE); + } + + return FALSE; +} + static void list_configs_ready (QmiClientPdc *client, GAsyncResult *res) @@ -442,7 +477,6 @@ list_configs_ready_indication (QmiClientPdc *client, current_info->config_type = element->config_type; input = qmi_message_pdc_get_config_info_input_new (); - g_print ("Fetching config type: %s\n", qmi_pdc_configuration_type_get_string (current_info->config_type)); /* Add type with id */ type_with_id.config_type = element->config_type; @@ -1174,6 +1208,9 @@ qmicli_pdc_run (QmiDevice *device, return; } + /* We need timeout, because no indication if no configs loaded*/ + ctx->timeout_id = g_timeout_add(2000, list_configs_timeout, NULL); + qmi_client_pdc_list_configs (ctx->client, input, 10,