summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-06-27 18:30:06 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-03 16:08:57 +0200
commite639816b53ec073b8ba54fc6daff49d294e49304 (patch)
tree61fd47137cd620800d5ddb9e8bd739e084607124
parent18461a70b3c774e69b015e236f73d0c4b37bb2a3 (diff)
cli: new `--dms-get-hardware-revision' action
-rw-r--r--cli/qmicli-dms.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/cli/qmicli-dms.c b/cli/qmicli-dms.c
index 7d1f2ca..4f8438d 100644
--- a/cli/qmicli-dms.c
+++ b/cli/qmicli-dms.c
@@ -53,6 +53,7 @@ static gchar *verify_pin_str;
static gchar *unblock_pin_str;
static gchar *change_pin_str;
static gboolean get_pin_status_flag;
+static gboolean get_hardware_revision_flag;
static gboolean noop_flag;
static GOptionEntry entries[] = {
@@ -104,6 +105,10 @@ static GOptionEntry entries[] = {
"Get PIN status",
NULL
},
+ { "dms-get-hardware-revision", 0, 0, G_OPTION_ARG_NONE, &get_hardware_revision_flag,
+ "Get the HW revision",
+ NULL
+ },
{ "dms-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag,
"Just allocate or release a DMS client. Use with `--client-no-release-cid' and/or `--client-cid'",
NULL
@@ -147,6 +152,7 @@ qmicli_dms_options_enabled (void)
!!unblock_pin_str +
!!change_pin_str +
get_pin_status_flag +
+ get_hardware_revision_flag +
noop_flag);
if (n_actions > 1) {
@@ -859,6 +865,44 @@ get_pin_status_ready (QmiClientDms *client,
shutdown (TRUE);
}
+static void
+get_hardware_revision_ready (QmiClientDms *client,
+ GAsyncResult *res)
+{
+ const gchar *str = NULL;
+ QmiMessageDmsGetHardwareRevisionOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_dms_get_hardware_revision_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ g_error_free (error);
+ shutdown (FALSE);
+ return;
+ }
+
+ if (!qmi_message_dms_get_hardware_revision_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't get the HW revision: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_dms_get_hardware_revision_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+#undef VALIDATE_UNKNOWN
+#define VALIDATE_UNKNOWN(str) (str ? str : "unknown")
+
+ qmi_message_dms_get_hardware_revision_output_get_revision (output, &str, NULL);
+
+ g_print ("[%s] Hardware revision retrieved:\n"
+ "\tRevision: '%s'\n",
+ qmi_device_get_path_display (ctx->device),
+ VALIDATE_UNKNOWN (str));
+
+ qmi_message_dms_get_hardware_revision_output_unref (output);
+ shutdown (TRUE);
+}
+
static gboolean
noop_cb (gpointer unused)
{
@@ -1038,6 +1082,18 @@ qmicli_dms_run (QmiDevice *device,
return;
}
+ /* Request to get hardware revision? */
+ if (get_hardware_revision_flag) {
+ g_debug ("Asynchronously getting hardware revision...");
+ qmi_client_dms_get_hardware_revision (ctx->client,
+ NULL,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_hardware_revision_ready,
+ NULL);
+ return;
+ }
+
/* Just client allocate/release? */
if (noop_flag) {
g_idle_add (noop_cb, NULL);