diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-10-19 15:34:44 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2017-10-30 17:16:31 +0100 |
commit | e682bf61ceb46bdd79d8e5e57965c4fce5e44399 (patch) | |
tree | 013054c7e6b246dba27270183fe174c691280e89 | |
parent | 8bf89ec9dc36220a76f0c6af4ce947a26a350908 (diff) |
dms: new 'Swi Get/Set USB Composition' messages
And corresponding '--dms-swi-get-usb-composition' and
'--dms-swi-set-usb-composition=[x]' qmicli actions.
Based on Bjørn Mork's swi_setusbcomp.pl tool:
https://git.mork.no/?p=wwan.git;a=blob_plain;f=scripts/swi_setusbcomp.pl
$ sudo qmicli -d /dev/cdc-wdm2 --dms-swi-get-usb-composition
[/dev/cdc-wdm2] Successfully retrieved USB compositions:
USB composition 6: DM, NMEA, AT, QMI
[*] USB composition 8: DM, NMEA, AT, MBIM
USB composition 9: MBIM
$ sudo qmicli -d /dev/cdc-wdm2 --dms-swi-set-usb-composition=9
[/dev/cdc-wdm2] Successfully set USB composition
You may want to power-cycle the modem now, or just set it offline and reset it:
$> sudo qmicli ... --dms-set-operating-mode=offline
$> sudo qmicli ... --dms-set-operating-mode=reset
$ sudo qmicli -d /dev/cdc-wdm2 --dms-set-operating-mode=offline
[/dev/cdc-wdm2] Operating mode set successfully
$ sudo qmicli -d /dev/cdc-wdm2 --dms-set-operating-mode=reset
[/dev/cdc-wdm2] Operating mode set successfully
(module reboots)
$ sudo qmicli -d /dev/cdc-wdm2 --dms-swi-get-usb-composition
[/dev/cdc-wdm2] Successfully retrieved USB compositions:
USB composition 6: DM, NMEA, AT, QMI
USB composition 8: DM, NMEA, AT, MBIM
[*] USB composition 9: MBIM
-rw-r--r-- | data/qmi-service-dms.json | 43 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/libqmi-glib-common.sections | 6 | ||||
-rw-r--r-- | docs/reference/libqmi-glib/libqmi-glib-docs.xml | 2 | ||||
-rw-r--r-- | src/libqmi-glib/Makefile.am | 2 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-enums-dms.c | 59 | ||||
-rw-r--r-- | src/libqmi-glib/qmi-enums-dms.h | 80 | ||||
-rw-r--r-- | src/qmicli/qmicli-dms.c | 155 | ||||
-rw-r--r-- | src/qmicli/qmicli-helpers.c | 21 | ||||
-rw-r--r-- | src/qmicli/qmicli-helpers.h | 2 |
9 files changed, 369 insertions, 1 deletions
diff --git a/data/qmi-service-dms.json b/data/qmi-service-dms.json index 38ce16b..72ebb6e 100644 --- a/data/qmi-service-dms.json +++ b/data/qmi-service-dms.json @@ -1463,6 +1463,49 @@ "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, // ********************************************************************************* + { "name" : "Swi Get USB Composition", + "type" : "Message", + "service" : "DMS", + "id" : "0x555B", + "vendor" : "0x1199", + "since" : "1.20", + "output" : [ { "common-ref" : "Operation Result" }, + { "name" : "Current", + "id" : "0x10", + "mandatory" : "no", + "type" : "TLV", + "since" : "1.20", + "format" : "guint8", + "public-format" : "QmiDmsSwiUsbComposition", + "prerequisites" : [ { "common-ref" : "Success" } ] }, + { "name" : "Supported", + "id" : "0x11", + "mandatory" : "no", + "type" : "TLV", + "since" : "1.20", + "format" : "array", + "array-element" : { "format" : "guint8", + "public-format" : "QmiDmsSwiUsbComposition" }, + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, + + // ********************************************************************************* + { "name" : "Swi Set USB Composition", + "type" : "Message", + "service" : "DMS", + "id" : "0x555C", + "vendor" : "0x1199", + "since" : "1.20", + "input" : [ { "name" : "Current", + "id" : "0x01", + "mandatory" : "yes", + "type" : "TLV", + "since" : "1.20", + "format" : "guint8", + "public-format" : "QmiDmsSwiUsbComposition" + } ], + "output" : [ { "common-ref" : "Operation Result" } ] }, + + // ********************************************************************************* { "name" : "Set FCC Authentication", "type" : "Message", "service" : "DMS", diff --git a/docs/reference/libqmi-glib/libqmi-glib-common.sections b/docs/reference/libqmi-glib/libqmi-glib-common.sections index d194120..6ce1e37 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-common.sections +++ b/docs/reference/libqmi-glib/libqmi-glib-common.sections @@ -164,6 +164,7 @@ QmiDmsTimeReferenceType QmiDmsFirmwareImageType QmiDmsBootImageDownloadMode QmiDmsHpDeviceMode +QmiDmsSwiUsbComposition <SUBSECTION Methods> qmi_dms_data_service_capability_get_string qmi_dms_sim_capability_get_string @@ -184,6 +185,8 @@ qmi_dms_time_reference_type_get_string qmi_dms_firmware_image_type_get_string qmi_dms_boot_image_download_mode_get_string qmi_dms_hp_device_mode_get_string +qmi_dms_swi_usb_composition_get_string +qmi_dms_swi_usb_composition_get_description <SUBSECTION Private> qmi_dms_data_service_capability_build_string_from_mask qmi_dms_sim_capability_build_string_from_mask @@ -202,6 +205,7 @@ qmi_dms_time_reference_type_build_string_from_mask qmi_dms_firmware_image_type_build_string_from_mask qmi_dms_boot_image_download_mode_build_string_from_mask qmi_dms_hp_device_mode_build_string_from_mask +qmi_dms_swi_usb_composition_build_string_from_mask <SUBSECTION Standard> QMI_TYPE_DMS_ACTIVATION_STATE QMI_TYPE_DMS_BOOT_IMAGE_DOWNLOAD_MODE @@ -220,6 +224,7 @@ QMI_TYPE_DMS_UIM_PIN_ID QMI_TYPE_DMS_UIM_PIN_STATUS QMI_TYPE_DMS_UIM_STATE QMI_TYPE_DMS_HP_DEVICE_MODE +QMI_TYPE_DMS_SWI_USB_COMPOSITION qmi_dms_activation_state_get_type qmi_dms_boot_image_download_mode_get_type qmi_dms_data_service_capability_get_type @@ -237,6 +242,7 @@ qmi_dms_uim_pin_id_get_type qmi_dms_uim_pin_status_get_type qmi_dms_uim_state_get_type qmi_dms_hp_device_mode_get_type +qmi_dms_swi_usb_composition_get_type </SECTION> <SECTION> diff --git a/docs/reference/libqmi-glib/libqmi-glib-docs.xml b/docs/reference/libqmi-glib/libqmi-glib-docs.xml index 9f1f83f..c636b5b 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml +++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml @@ -118,6 +118,8 @@ <xi:include href="xml/qmi-message-dms-set-service-programming-code.xml"/> <xi:include href="xml/qmi-message-dms-hp-change-device-mode.xml"/> <xi:include href="xml/qmi-message-dms-swi-get-current-firmware.xml"/> + <xi:include href="xml/qmi-message-dms-swi-get-usb-composition.xml"/> + <xi:include href="xml/qmi-message-dms-swi-set-usb-composition.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/libqmi-glib/Makefile.am b/src/libqmi-glib/Makefile.am index 43e60cc..63723b0 100644 --- a/src/libqmi-glib/Makefile.am +++ b/src/libqmi-glib/Makefile.am @@ -21,7 +21,7 @@ libqmi_glib_la_SOURCES = \ qmi-version.h \ qmi-errors.h \ qmi-enums-wds.h qmi-enums-wds.c \ - qmi-enums-dms.h qmi-flags64-dms.h \ + qmi-enums-dms.h qmi-flags64-dms.h qmi-enums-dms.c \ qmi-enums-nas.h qmi-flags64-nas.h\ qmi-enums-wms.h \ qmi-enums-pds.h \ diff --git a/src/libqmi-glib/qmi-enums-dms.c b/src/libqmi-glib/qmi-enums-dms.c new file mode 100644 index 0000000..6cff21d --- /dev/null +++ b/src/libqmi-glib/qmi-enums-dms.c @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * libqmi-glib -- GLib/GIO based library to control QMI devices + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + * Copyright (C) 2017 Aleksander Morgado <aleksander@aleksander.es> + */ + +#include <glib.h> +#include "qmi-enums-dms.h" + +/*****************************************************************************/ +/* Helper for the 'QMI DMS Swi Get USB Composition' message */ + +static const gchar *usb_composition_description[] = { + [QMI_DMS_SWI_USB_COMPOSITION_0] = "HIP, DM, NMEA, AT, MDM1, MDM2, MDM3, MS", + [QMI_DMS_SWI_USB_COMPOSITION_1] = "HIP, DM, NMEA, AT, MDM1, MS", + [QMI_DMS_SWI_USB_COMPOSITION_2] = "HIP, DM, NMEA, AT, NIC1, MS", + [QMI_DMS_SWI_USB_COMPOSITION_3] = "HIP, DM, NMEA, AT, MDM1, NIC1, MS", + [QMI_DMS_SWI_USB_COMPOSITION_4] = "HIP, DM, NMEA, AT, NIC1, NIC2, NIC3, MS", + [QMI_DMS_SWI_USB_COMPOSITION_5] = "HIP, DM, NMEA, AT, ECM1, MS", + [QMI_DMS_SWI_USB_COMPOSITION_6] = "DM, NMEA, AT, QMI", + [QMI_DMS_SWI_USB_COMPOSITION_7] = "DM, NMEA, AT, RMNET1, RMNET2, RMNET3", + [QMI_DMS_SWI_USB_COMPOSITION_8] = "DM, NMEA, AT, MBIM", + [QMI_DMS_SWI_USB_COMPOSITION_9] = "MBIM", + [QMI_DMS_SWI_USB_COMPOSITION_10] = "NMEA, MBIM", + [QMI_DMS_SWI_USB_COMPOSITION_11] = "DM, MBIM", + [QMI_DMS_SWI_USB_COMPOSITION_12] = "DM, NMEA, MBIM", + [QMI_DMS_SWI_USB_COMPOSITION_13] = "Dual configuration: USB composition 6 and USB composition 8", + [QMI_DMS_SWI_USB_COMPOSITION_14] = "Dual configuration: USB composition 6 and USB composition 9", + [QMI_DMS_SWI_USB_COMPOSITION_15] = "Dual configuration: USB composition 6 and USB composition 10", + [QMI_DMS_SWI_USB_COMPOSITION_16] = "Dual configuration: USB composition 6 and USB composition 11", + [QMI_DMS_SWI_USB_COMPOSITION_17] = "Dual configuration: USB composition 6 and USB composition 12", + [QMI_DMS_SWI_USB_COMPOSITION_18] = "Dual configuration: USB composition 7 and USB composition 8", + [QMI_DMS_SWI_USB_COMPOSITION_19] = "Dual configuration: USB composition 7 and USB composition 9", + [QMI_DMS_SWI_USB_COMPOSITION_20] = "Dual configuration: USB composition 7 and USB composition 10", + [QMI_DMS_SWI_USB_COMPOSITION_21] = "Dual configuration: USB composition 7 and USB composition 11", + [QMI_DMS_SWI_USB_COMPOSITION_22] = "Dual configuration: USB composition 7 and USB composition 12", +}; + +const gchar * +qmi_dms_swi_usb_composition_get_description (QmiDmsSwiUsbComposition value) +{ + return ((value > QMI_DMS_SWI_USB_COMPOSITION_UNKNOWN && value < G_N_ELEMENTS (usb_composition_description)) ? usb_composition_description[value] : NULL); +} diff --git a/src/libqmi-glib/qmi-enums-dms.h b/src/libqmi-glib/qmi-enums-dms.h index dcd8aa3..523415e 100644 --- a/src/libqmi-glib/qmi-enums-dms.h +++ b/src/libqmi-glib/qmi-enums-dms.h @@ -24,6 +24,8 @@ #ifndef _LIBQMI_GLIB_QMI_ENUMS_DMS_H_ #define _LIBQMI_GLIB_QMI_ENUMS_DMS_H_ +#include <glib.h> + #if !defined (__LIBQMI_GLIB_H_INSIDE__) && !defined (LIBQMI_GLIB_COMPILATION) #error "Only <libqmi-glib.h> can be included directly." #endif @@ -502,4 +504,82 @@ typedef enum { * Since: 1.18 */ +/*****************************************************************************/ +/* Helper enums for the 'QMI DMS Swi Get USB Composition' message */ + +/** + * QmiDmsSwiUsbComposition: + * @QMI_DMS_SWI_USB_COMPOSITION_UNKNOWN: Unknown. + * @QMI_DMS_SWI_USB_COMPOSITION_0: HIP, DM, NMEA, AT, MDM1, MDM2, MDM3, MS. + * @QMI_DMS_SWI_USB_COMPOSITION_1: HIP, DM, NMEA, AT, MDM1, MS. + * @QMI_DMS_SWI_USB_COMPOSITION_2: HIP, DM, NMEA, AT, NIC1, MS. + * @QMI_DMS_SWI_USB_COMPOSITION_3: HIP, DM, NMEA, AT, MDM1, NIC1, MS. + * @QMI_DMS_SWI_USB_COMPOSITION_4: HIP, DM, NMEA, AT, NIC1, NIC2, NIC3, MS. + * @QMI_DMS_SWI_USB_COMPOSITION_5: HIP, DM, NMEA, AT, ECM1, MS. + * @QMI_DMS_SWI_USB_COMPOSITION_6: DM, NMEA, AT, QMI. + * @QMI_DMS_SWI_USB_COMPOSITION_7: DM, NMEA, AT, RMNET1, RMNET2, RMNET3. + * @QMI_DMS_SWI_USB_COMPOSITION_8: DM, NMEA, AT, MBIM. + * @QMI_DMS_SWI_USB_COMPOSITION_9: MBIM. + * @QMI_DMS_SWI_USB_COMPOSITION_10: NMEA, MBIM. + * @QMI_DMS_SWI_USB_COMPOSITION_11: DM, MBIM. + * @QMI_DMS_SWI_USB_COMPOSITION_12: DM, NMEA, MBIM. + * @QMI_DMS_SWI_USB_COMPOSITION_13: Dual configuration: USB composition 6 and USB composition 8. + * @QMI_DMS_SWI_USB_COMPOSITION_14: Dual configuration: USB composition 6 and USB composition 9. + * @QMI_DMS_SWI_USB_COMPOSITION_15: Dual configuration: USB composition 6 and USB composition 10. + * @QMI_DMS_SWI_USB_COMPOSITION_16: Dual configuration: USB composition 6 and USB composition 11. + * @QMI_DMS_SWI_USB_COMPOSITION_17: Dual configuration: USB composition 6 and USB composition 12. + * @QMI_DMS_SWI_USB_COMPOSITION_18: Dual configuration: USB composition 7 and USB composition 8. + * @QMI_DMS_SWI_USB_COMPOSITION_19: Dual configuration: USB composition 7 and USB composition 9. + * @QMI_DMS_SWI_USB_COMPOSITION_20: Dual configuration: USB composition 7 and USB composition 10. + * @QMI_DMS_SWI_USB_COMPOSITION_21: Dual configuration: USB composition 7 and USB composition 11. + * @QMI_DMS_SWI_USB_COMPOSITION_22: Dual configuration: USB composition 7 and USB composition 12. + * + * Sierra Wireless USB composition modes. + * + * Since: 1.20 + */ +typedef enum { + QMI_DMS_SWI_USB_COMPOSITION_UNKNOWN = -1, + QMI_DMS_SWI_USB_COMPOSITION_0 = 0, + QMI_DMS_SWI_USB_COMPOSITION_1 = 1, + QMI_DMS_SWI_USB_COMPOSITION_2 = 2, + QMI_DMS_SWI_USB_COMPOSITION_3 = 3, + QMI_DMS_SWI_USB_COMPOSITION_4 = 4, + QMI_DMS_SWI_USB_COMPOSITION_5 = 5, + QMI_DMS_SWI_USB_COMPOSITION_6 = 6, + QMI_DMS_SWI_USB_COMPOSITION_7 = 7, + QMI_DMS_SWI_USB_COMPOSITION_8 = 8, + QMI_DMS_SWI_USB_COMPOSITION_9 = 9, + QMI_DMS_SWI_USB_COMPOSITION_10 = 10, + QMI_DMS_SWI_USB_COMPOSITION_11 = 11, + QMI_DMS_SWI_USB_COMPOSITION_12 = 12, + QMI_DMS_SWI_USB_COMPOSITION_13 = 13, + QMI_DMS_SWI_USB_COMPOSITION_14 = 14, + QMI_DMS_SWI_USB_COMPOSITION_15 = 15, + QMI_DMS_SWI_USB_COMPOSITION_16 = 16, + QMI_DMS_SWI_USB_COMPOSITION_17 = 17, + QMI_DMS_SWI_USB_COMPOSITION_18 = 18, + QMI_DMS_SWI_USB_COMPOSITION_19 = 19, + QMI_DMS_SWI_USB_COMPOSITION_20 = 20, + QMI_DMS_SWI_USB_COMPOSITION_21 = 21, + QMI_DMS_SWI_USB_COMPOSITION_22 = 22, +} QmiDmsSwiUsbComposition; + +/** + * qmi_dms_swi_usb_composition_get_description: + * @value: a #QmiDmsSwiUsbComposition. + * + * Gets a text description of the Sierra Wireless USB composition. + * + * Since: 1.20 + * Returns: a string. + */ +const gchar *qmi_dms_swi_usb_composition_get_description (QmiDmsSwiUsbComposition value); + +/** + * qmi_dms_swi_usb_composition_get_string: + * + * Since: 1.20 + */ + #endif /* _LIBQMI_GLIB_QMI_ENUMS_DMS_H_ */ diff --git a/src/qmicli/qmicli-dms.c b/src/qmicli/qmicli-dms.c index bc1fde5..46b684b 100644 --- a/src/qmicli/qmicli-dms.c +++ b/src/qmicli/qmicli-dms.c @@ -94,6 +94,8 @@ static gboolean set_fcc_authentication_flag; static gboolean get_supported_messages_flag; static gchar *hp_change_device_mode_str; static gboolean swi_get_current_firmware_flag; +static gboolean swi_get_usb_composition_flag; +static gchar *swi_set_usb_composition_str; static gboolean reset_flag; static gboolean noop_flag; @@ -294,6 +296,14 @@ static GOptionEntry entries[] = { "Get Current Firmware (Sierra Wireless specific)", NULL }, + { "dms-swi-get-usb-composition", 0, 0, G_OPTION_ARG_NONE, &swi_get_usb_composition_flag, + "Get current and supported USB compositions (Sierra Wireless specific)", + NULL + }, + { "dms-swi-set-usb-composition", 0, 0, G_OPTION_ARG_STRING, &swi_set_usb_composition_str, + "Set USB composition (Sierra Wireless specific)", + "[#]" + }, { "dms-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag, "Reset the service state", NULL @@ -378,6 +388,8 @@ qmicli_dms_options_enabled (void) get_supported_messages_flag + !!hp_change_device_mode_str + swi_get_current_firmware_flag + + swi_get_usb_composition_flag + + !!swi_set_usb_composition_str + reset_flag + noop_flag); @@ -3514,6 +3526,115 @@ swi_get_current_firmware_ready (QmiClientDms *client, } static void +swi_get_usb_composition_ready (QmiClientDms *client, + GAsyncResult *res) +{ + QmiMessageDmsSwiGetUsbCompositionOutput *output; + GError *error = NULL; + GArray *supported = NULL; + QmiDmsSwiUsbComposition current = QMI_DMS_SWI_USB_COMPOSITION_UNKNOWN; + guint i; + + output = qmi_client_dms_swi_get_usb_composition_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_swi_get_usb_composition_output_get_result (output, &error)) { + g_printerr ("error: couldn't get USB composite modes: %s\n", error->message); + g_error_free (error); + qmi_message_dms_swi_get_usb_composition_output_unref (output); + operation_shutdown (FALSE); + return; + } + + g_print ("[%s] Successfully retrieved USB compositions:\n", + qmi_device_get_path_display (ctx->device)); + + if (!qmi_message_dms_swi_get_usb_composition_output_get_current (output, ¤t, &error)) { + g_printerr ("error: couldn't get current USB composition: %s\n", error->message); + g_clear_error (&error); + } + + if (!qmi_message_dms_swi_get_usb_composition_output_get_supported (output, &supported, &error)) { + g_printerr ("error: couldn't get list of USB compositions: %s\n", error->message); + g_clear_error (&error); + } + + for (i = 0; i < supported->len; i++) { + QmiDmsSwiUsbComposition value; + + value = g_array_index (supported, QmiDmsSwiUsbComposition, i); + g_print ("\t%sUSB composition %s: %s\n", + (value == current ? "[*] " : " "), + qmi_dms_swi_usb_composition_get_string (value), + qmi_dms_swi_usb_composition_get_description (value)); + } + + qmi_message_dms_swi_get_usb_composition_output_unref (output); + operation_shutdown (TRUE); +} + +static void +swi_set_usb_composition_ready (QmiClientDms *client, + GAsyncResult *res) +{ + QmiMessageDmsSwiSetUsbCompositionOutput *output; + GError *error = NULL; + + output = qmi_client_dms_swi_set_usb_composition_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_swi_set_usb_composition_output_get_result (output, &error)) { + g_printerr ("error: couldn't set USB composite modes: %s\n", error->message); + g_error_free (error); + qmi_message_dms_swi_set_usb_composition_output_unref (output); + operation_shutdown (FALSE); + return; + } + + g_print ("[%s] Successfully set USB composition\n" + "\n" + "\tYou may want to power-cycle the modem now, or just set it offline and reset it:\n" + "\t\t$> sudo qmicli ... --dms-set-operating-mode=offline\n" + "\t\t$> sudo qmicli ... --dms-set-operating-mode=reset\n" + "\n", + qmi_device_get_path_display (ctx->device)); + + qmi_message_dms_swi_set_usb_composition_output_unref (output); + operation_shutdown (TRUE); +} + +static QmiMessageDmsSwiSetUsbCompositionInput * +swi_set_usb_composition_input_create (const gchar *str) +{ + QmiMessageDmsSwiSetUsbCompositionInput *input = NULL; + QmiDmsSwiUsbComposition value; + GError *error = NULL; + + if (!qmicli_read_swi_usb_composition_from_string (str, &value)) + return NULL; + + input = qmi_message_dms_swi_set_usb_composition_input_new (); + if (!qmi_message_dms_swi_set_usb_composition_input_set_current (input, value, &error)) { + g_printerr ("error: couldn't create input bundle: '%s'\n", error->message); + g_error_free (error); + qmi_message_dms_swi_set_usb_composition_input_unref (input); + return NULL; + } + + return input; +} + +static void reset_ready (QmiClientDms *client, GAsyncResult *res) { @@ -4298,6 +4419,40 @@ qmicli_dms_run (QmiDevice *device, return; } + /* Request to get current USB composition */ + if (swi_get_usb_composition_flag) { + g_debug ("Asynchronously getting USB compositionss (Sierra Wireless specific)..."); + qmi_client_dms_swi_get_usb_composition (ctx->client, + NULL, + 10, + ctx->cancellable, + (GAsyncReadyCallback)swi_get_usb_composition_ready, + NULL); + return; + } + + /* Request to set current USB composition */ + if (swi_set_usb_composition_str) { + QmiMessageDmsSwiSetUsbCompositionInput *input; + + g_debug ("Asynchronously setting USB composition (Sierra Wireless specific)..."); + + input = swi_set_usb_composition_input_create (swi_set_usb_composition_str); + if (!input) { + operation_shutdown (FALSE); + return; + } + + qmi_client_dms_swi_set_usb_composition (ctx->client, + input, + 10, + ctx->cancellable, + (GAsyncReadyCallback)swi_set_usb_composition_ready, + NULL); + qmi_message_dms_swi_set_usb_composition_input_unref (input); + return; + } + /* Request to reset DMS service? */ if (reset_flag) { g_debug ("Asynchronously resetting DMS service..."); diff --git a/src/qmicli/qmicli-helpers.c b/src/qmicli/qmicli-helpers.c index 0711253..00f7122 100644 --- a/src/qmicli/qmicli-helpers.c +++ b/src/qmicli/qmicli-helpers.c @@ -691,6 +691,27 @@ qmicli_read_hp_device_mode_from_string (const gchar *str, } gboolean +qmicli_read_swi_usb_composition_from_string (const gchar *str, + QmiDmsSwiUsbComposition *out) +{ + GType type; + GEnumClass *enum_class; + GEnumValue *enum_value; + + type = qmi_dms_swi_usb_composition_get_type (); + enum_class = G_ENUM_CLASS (g_type_class_ref (type)); + enum_value = g_enum_get_value_by_nick (enum_class, str); + + if (enum_value) + *out = (QmiDmsSwiUsbComposition)enum_value->value; + else + g_printerr ("error: invalid SWI USB Composition value given: '%s'\n", str); + + g_type_class_unref (enum_class); + return !!enum_value; +} + +gboolean qmicli_read_uint_from_string (const gchar *str, guint *out) { diff --git a/src/qmicli/qmicli-helpers.h b/src/qmicli/qmicli-helpers.h index 3ae880b..e8fac1d 100644 --- a/src/qmicli/qmicli-helpers.h +++ b/src/qmicli/qmicli-helpers.h @@ -73,6 +73,8 @@ gboolean qmicli_read_boot_image_download_mode_from_string (const gchar *str, QmiDmsBootImageDownloadMode *out); gboolean qmicli_read_hp_device_mode_from_string (const gchar *str, QmiDmsHpDeviceMode *out); +gboolean qmicli_read_swi_usb_composition_from_string (const gchar *str, + QmiDmsSwiUsbComposition *out); gboolean qmicli_read_non_empty_string (const gchar *str, const gchar *description, |