summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-02-25 14:15:07 +0100
committerAleksander Morgado <aleksander@aleksander.es>2015-02-25 15:47:14 +0100
commit5dfa2198d0354d4fb8b035b1d6a86f2094efc336 (patch)
tree4335f4489b49343f7d3b494fd2487413a2df7f0d
parent52a660aec9f58b37d1fcaa4c827102dbec76dd63 (diff)
downloadlibqmi-5dfa2198d0354d4fb8b035b1d6a86f2094efc336.tar.gz
dms: implement 'Get Supported Messages'
-rw-r--r--data/qmi-service-dms.json16
-rw-r--r--docs/reference/libqmi-glib/libqmi-glib-docs.xml1
-rw-r--r--src/qmicli/qmicli-dms.c75
3 files changed, 92 insertions, 0 deletions
diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json
index c62b4310..706c41ae 100644
--- a/data/qmi-service-dms.json
+++ b/data/qmi-service-dms.json
@@ -1172,6 +1172,22 @@
"output" : [ { "common-ref" : "Operation Result" } ] },
// *********************************************************************************
+ { "name" : "Get Supported Messages",
+ "type" : "Message",
+ "service" : "DMS",
+ "id" : "0x001E",
+ "version" : "1.16",
+ "output" : [ { "common-ref" : "Operation Result" },
+ { "name" : "List",
+ "id" : "0x10",
+ "mandatory" : "no",
+ "type" : "TLV",
+ "format" : "array",
+ "size-prefix-format" : "guint16",
+ "array-element" : { "format" : "guint8" },
+ "prerequisites" : [ { "common-ref" : "Success" } ] } ] },
+
+ // *********************************************************************************
{ "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 6a38d5fb..b241b79f 100644
--- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml
+++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
@@ -108,6 +108,7 @@
<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-set-fcc-authentication.xml"/>
+ <xi:include href="xml/qmi-message-dms-get-supported-messages.xml"/>
</section>
</chapter>
diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c
index 6042badd..13b6a396 100644
--- a/src/qmicli/qmicli-dms.c
+++ b/src/qmicli/qmicli-dms.c
@@ -82,6 +82,7 @@ static gboolean list_stored_images_flag;
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 gboolean reset_flag;
static gboolean noop_flag;
@@ -246,6 +247,10 @@ static GOptionEntry entries[] = {
"Set FCC authentication",
NULL
},
+ { "dms-get-supported-messages", 0, 0, G_OPTION_ARG_NONE, &get_supported_messages_flag,
+ "Get supported messages",
+ NULL
+ },
{ "dms-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag,
"Reset the service state",
NULL
@@ -321,6 +326,7 @@ qmicli_dms_options_enabled (void)
!!select_stored_image_str +
!!delete_stored_image_str +
set_fcc_authentication_flag +
+ get_supported_messages_flag +
reset_flag +
noop_flag);
@@ -2984,6 +2990,63 @@ set_fcc_authentication_ready (QmiClientDms *client,
}
static void
+get_supported_messages_ready (QmiClientDms *client,
+ GAsyncResult *res)
+{
+ QmiMessageDmsGetSupportedMessagesOutput *output;
+ GError *error = NULL;
+ GArray *bytearray = NULL;
+ GString *str = NULL;
+
+ output = qmi_client_dms_get_supported_messages_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_supported_messages_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't get supported DMS messages: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_dms_get_supported_messages_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+ g_print ("[%s] Successfully got supported DMS messages:\n",
+ qmi_device_get_path_display (ctx->device));
+
+ if (qmi_message_dms_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_dms_get_supported_messages_output_unref (output);
+ shutdown (TRUE);
+}
+
+static void
reset_ready (QmiClientDms *client,
GAsyncResult *res)
{
@@ -3628,6 +3691,18 @@ qmicli_dms_run (QmiDevice *device,
return;
}
+ /* Request to list supported messages? */
+ if (get_supported_messages_flag) {
+ g_debug ("Asynchronously getting supported DMS messages...");
+ qmi_client_dms_get_supported_messages (ctx->client,
+ NULL,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_supported_messages_ready,
+ NULL);
+ return;
+ }
+
/* Request to reset DMS service? */
if (reset_flag) {
g_debug ("Asynchronously resetting DMS service...");