From 73fb522ce812762b2e63c3b60a54ec5692f193be Mon Sep 17 00:00:00 2001 From: Aliaksandr Barouski Date: Thu, 7 Jul 2016 15:46:38 -0700 Subject: [PATCH] Added call to change device download mode --- data/qmi-service-dms.json | 14 +++++ docs/reference/libqmi-glib/libqmi-glib-docs.xml | 1 + src/qmicli/qmicli-dms.c | 75 +++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json index b5937c5..4d5ad9b 100644 --- a/data/qmi-service-dms.json +++ b/data/qmi-service-dms.json @@ -1188,6 +1188,20 @@ "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 15298e7..d4daf86 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml +++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml @@ -111,6 +111,7 @@ + diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c index 7f1593f..50a2222 100644 --- a/src/qmicli/qmicli-dms.c +++ b/src/qmicli/qmicli-dms.c @@ -83,6 +83,7 @@ static gchar *select_stored_image_str; static gchar *delete_stored_image_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; @@ -251,6 +252,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 @@ -327,6 +332,7 @@ qmicli_dms_options_enabled (void) !!delete_stored_image_str + set_fcc_authentication_flag + get_supported_messages_flag + + !!change_device_download_mode_str + reset_flag + noop_flag); @@ -3028,6 +3034,67 @@ get_supported_messages_ready (QmiClientDms *client, } 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 +change_device_download_mode (QmiClientDms *client, + const gchar *str) +{ + QmiMessageDmsChangeDeviceDownloadModeInput *input = NULL; + guint8 mode; + + if (qmicli_read_uint8_from_string(str, &mode)) { + GError *error = 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); + 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); + } else { + g_printerr ("error: couldn't parse input data : '%s'\n", + str); + operation_shutdown (FALSE); + } +} + +static void reset_ready (QmiClientDms *client, GAsyncResult *res) { @@ -3684,6 +3751,14 @@ qmicli_dms_run (QmiDevice *device, return; } + /* Request to change device download mode */ + if (change_device_download_mode_str) { + g_debug ("Asynchronously changing device download mode..."); + change_device_download_mode (ctx->client, + change_device_download_mode_str); + return; + } + /* Request to reset DMS service? */ if (reset_flag) { g_debug ("Asynchronously resetting DMS service..."); -- 2.8.0.rc3.226.g39d4020