aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-10-24 12:31:52 +0200
committerAleksander Morgado <aleksander@aleksander.es>2016-10-24 12:31:52 +0200
commitfa39dc14a6b8bdea736239da9fee59a65e289b1d (patch)
treeb5df2a2659d3dccd31ac2fa420bc9b8149137a34
parentc847091b17b87b3499d049a4aedf96330c99fc8d (diff)
dms: new 'Change Device Download Mode' command
Based on a patch from Aliaksandr Barouski <alex.borovsky@gmail.com> https://bugs.freedesktop.org/show_bug.cgi?id=96465
-rw-r--r--data/qmi-service-dms.json13
-rw-r--r--docs/reference/libqmi-glib/libqmi-glib-docs.xml1
-rw-r--r--src/qmicli/qmicli-dms.c79
3 files changed, 93 insertions, 0 deletions
diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json
index e6f77ad..1db1ef9 100644
--- a/data/qmi-service-dms.json
+++ b/data/qmi-service-dms.json
@@ -1188,6 +1188,19 @@
"prerequisites" : [ { "common-ref" : "Success" } ] } ] },
// *********************************************************************************
+ { "name" : "Change Device Download Mode",
+ "type" : "Message",
+ "service" : "DMS",
+ "id" : "0x5556",
+ "version" : "1.0",
+ "input" : [ { "name" : "Mode",
+ "id" : "0x01",
+ "mandatory" : "yes",
+ "type" : "TLV",
+ "format" : "guint8" } ],
+ "output" : [ { "common-ref" : "Operation Result" } ] },
+
+ // *********************************************************************************
{ "name" : "Set FCC Authentication",
"type" : "Message",
"service" : "DMS",
diff --git a/docs/reference/libqmi-glib/libqmi-glib-docs.xml b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
index 817048d..1567e22 100644
--- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml
+++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
@@ -111,6 +111,7 @@
<xi:include href="xml/qmi-message-dms-set-alt-net-config.xml"/>
<xi:include href="xml/qmi-message-dms-get-software-version.xml"/>
<xi:include href="xml/qmi-message-dms-set-service-programming-code.xml"/>
+ <xi:include href="xml/qmi-message-dms-change-device-download-mode.xml"/>
<xi:include href="xml/qmi-message-dms-set-fcc-authentication.xml"/>
<xi:include href="xml/qmi-message-dms-get-supported-messages.xml"/>
</section>
diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c
index c5736cf..2d20b1a 100644
--- a/src/qmicli/qmicli-dms.c
+++ b/src/qmicli/qmicli-dms.c
@@ -84,6 +84,7 @@ static gchar *delete_stored_image_str;
static gchar *set_firmware_preference_str;
static gboolean set_fcc_authentication_flag;
static gboolean get_supported_messages_flag;
+static gchar *change_device_download_mode_str;
static gboolean reset_flag;
static gboolean noop_flag;
@@ -256,6 +257,10 @@ static GOptionEntry entries[] = {
"Get supported messages",
NULL
},
+ { "dms-change-device-download-mode", 0, 0, G_OPTION_ARG_STRING, &change_device_download_mode_str,
+ "Change device download mode",
+ "[mode]"
+ },
{ "dms-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag,
"Reset the service state",
NULL
@@ -333,6 +338,7 @@ qmicli_dms_options_enabled (void)
!!set_firmware_preference_str +
set_fcc_authentication_flag +
get_supported_messages_flag +
+ !!change_device_download_mode_str +
reset_flag +
noop_flag);
@@ -3097,6 +3103,57 @@ get_supported_messages_ready (QmiClientDms *client,
operation_shutdown (TRUE);
}
+static QmiMessageDmsChangeDeviceDownloadModeInput *
+change_device_download_mode_input_create (const gchar *str)
+{
+ QmiMessageDmsChangeDeviceDownloadModeInput *input = NULL;
+ guint mode;
+ GError *error = NULL;
+
+ if (!qmicli_read_uint_from_string (str, &mode) || mode > G_MAXUINT8) {
+ g_printerr ("error: couldn't parse input data : '%s'\n", str);
+ return NULL;
+ }
+
+ input = qmi_message_dms_change_device_download_mode_input_new ();
+ if (!qmi_message_dms_change_device_download_mode_input_set_mode (input, mode, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n",
+ error->message);
+ g_error_free (error);
+ qmi_message_dms_change_device_download_mode_input_unref (input);
+ return NULL;
+ }
+
+ return input;
+}
+
+static void
+change_device_download_mode_ready (QmiClientDms *client,
+ GAsyncResult *res)
+{
+ QmiMessageDmsChangeDeviceDownloadModeOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_dms_change_device_download_mode_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ g_error_free (error);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ if (!qmi_message_dms_change_device_download_mode_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't change device download mode: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_dms_change_device_download_mode_output_unref (output);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ qmi_message_dms_change_device_download_mode_output_unref (output);
+ operation_shutdown (TRUE);
+}
+
static void
reset_ready (QmiClientDms *client,
GAsyncResult *res)
@@ -3776,6 +3833,28 @@ qmicli_dms_run (QmiDevice *device,
return;
}
+ /* Request to change device download mode */
+ if (change_device_download_mode_str) {
+ QmiMessageDmsChangeDeviceDownloadModeInput *input;
+
+ g_debug ("Asynchronously changing device download mode...");
+
+ input = change_device_download_mode_input_create (change_device_download_mode_str);
+ if (!input) {
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ qmi_client_dms_change_device_download_mode (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)change_device_download_mode_ready,
+ NULL);
+ qmi_message_dms_change_device_download_mode_input_unref (input);
+ return;
+ }
+
/* Request to reset DMS service? */
if (reset_flag) {
g_debug ("Asynchronously resetting DMS service...");