summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-10-04 13:39:50 +0200
committerAleksander Morgado <aleksander@aleksander.es>2015-10-06 19:24:51 +0200
commit47d83f020ae3d2f4eddb701860e24bb39e1fb029 (patch)
tree2009144f000f0c1ffdea615d2224d07dde3a885d
parent7adcbf1234ecb7420910a666199e05d534a2e5e3 (diff)
wds: new 'WDS Set Autoconnect Setting' command support
-rw-r--r--data/qmi-service-wds.json22
-rw-r--r--docs/reference/libqmi-glib/libqmi-glib-docs.xml1
-rw-r--r--src/qmicli/qmicli-helpers.c43
-rw-r--r--src/qmicli/qmicli-helpers.h43
-rw-r--r--src/qmicli/qmicli-wds.c108
5 files changed, 197 insertions, 20 deletions
diff --git a/data/qmi-service-wds.json b/data/qmi-service-wds.json
index e303b21..e0949e9 100644
--- a/data/qmi-service-wds.json
+++ b/data/qmi-service-wds.json
@@ -1148,6 +1148,26 @@
"type" : "TLV",
"format" : "guint8",
"public-format" : "QmiWdsIpFamily" } ],
- "output" : [ { "common-ref" : "Operation Result" } ] }
+ "output" : [ { "common-ref" : "Operation Result" } ] },
+
+ // *********************************************************************************
+ { "name" : "Set Autoconnect Settings",
+ "type" : "Message",
+ "service" : "WDS",
+ "id" : "0x0051",
+ "version" : "1.12",
+ "input" : [ { "name" : "Status",
+ "id" : "0x01",
+ "mandatory" : "yes",
+ "type" : "TLV",
+ "format" : "guint8",
+ "public-format" : "QmiWdsAutoconnectSetting" },
+ { "name" : "Roaming",
+ "id" : "0x10",
+ "mandatory" : "yes",
+ "type" : "TLV",
+ "format" : "guint8",
+ "public-format" : "QmiWdsAutoconnectSettingRoaming" } ],
+ "output" : [ { "common-ref" : "Operation Result" } ] }
]
diff --git a/docs/reference/libqmi-glib/libqmi-glib-docs.xml b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
index 0c91360..b907e7d 100644
--- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml
+++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml
@@ -169,6 +169,7 @@
<xi:include href="xml/qmi-message-wds-get-default-settings.xml"/>
<xi:include href="xml/qmi-message-wds-get-current-settings.xml"/>
<xi:include href="xml/qmi-message-wds-get-autoconnect-settings.xml"/>
+ <xi:include href="xml/qmi-message-wds-set-autoconnect-settings.xml"/>
<xi:include href="xml/qmi-message-wds-get-data-bearer-technology.xml"/>
<xi:include href="xml/qmi-message-wds-get-current-data-bearer-technology.xml"/>
<xi:include href="xml/qmi-message-wds-set-ip-family.xml"/>
diff --git a/src/qmicli/qmicli-helpers.c b/src/qmicli/qmicli-helpers.c
index 478307a..d5e9eee 100644
--- a/src/qmicli/qmicli-helpers.c
+++ b/src/qmicli/qmicli-helpers.c
@@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
+ * Copyright (C) 2015 Velocloud Inc.
* Copyright (C) 2012-2015 Aleksander Morgado <aleksander@aleksander.es>
*/
@@ -368,6 +369,48 @@ qmicli_read_link_layer_protocol_from_string (const gchar *str,
}
gboolean
+qmicli_read_autoconnect_setting_from_string (const gchar *str,
+ QmiWdsAutoconnectSetting *out)
+{
+ GType type;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ type = qmi_wds_autoconnect_setting_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 = (QmiWdsAutoconnectSetting)enum_value->value;
+ else
+ g_printerr ("error: invalid autoconnect setting value given: '%s'\n", str);
+
+ g_type_class_unref (enum_class);
+ return !!enum_value;
+}
+
+gboolean
+qmicli_read_autoconnect_setting_roaming_from_string (const gchar *str,
+ QmiWdsAutoconnectSettingRoaming *out)
+{
+ GType type;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ type = qmi_wds_autoconnect_setting_roaming_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 = (QmiWdsAutoconnectSettingRoaming)enum_value->value;
+ else
+ g_printerr ("error: invalid autoconnect setting roaming 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 3245207..0e6d567 100644
--- a/src/qmicli/qmicli-helpers.h
+++ b/src/qmicli/qmicli-helpers.h
@@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
+ * Copyright (C) 2015 Velocloud Inc.
* Copyright (C) 2012-2015 Aleksander Morgado <aleksander@aleksander.es>
*/
@@ -29,25 +30,29 @@ gchar *qmicli_get_raw_data_printable (const GArray *data,
gsize max_line_length,
const gchar *new_line_prefix);
-gboolean qmicli_read_pin_id_from_string (const gchar *str,
- QmiDmsUimPinId *out);
-gboolean qmicli_read_operating_mode_from_string (const gchar *str,
- QmiDmsOperatingMode *out);
-gboolean qmicli_read_rat_mode_pref_from_string (const gchar *str,
- QmiNasRatModePreference *out);
-gboolean qmicli_read_facility_from_string (const gchar *str,
- QmiDmsUimFacility *out);
-gboolean qmicli_read_enable_disable_from_string (const gchar *str,
- gboolean *out);
-gboolean qmicli_read_firmware_id_from_string (const gchar *str,
- QmiDmsFirmwareImageType *out_type,
- guint *out_index);
-gboolean qmicli_read_radio_interface_from_string (const gchar *str,
- QmiNasRadioInterface *out);
-gboolean qmicli_read_net_open_flags_from_string (const gchar *str,
- QmiDeviceOpenFlags *out);
-gboolean qmicli_read_link_layer_protocol_from_string (const gchar *str,
- QmiWdaLinkLayerProtocol *out);
+gboolean qmicli_read_pin_id_from_string (const gchar *str,
+ QmiDmsUimPinId *out);
+gboolean qmicli_read_operating_mode_from_string (const gchar *str,
+ QmiDmsOperatingMode *out);
+gboolean qmicli_read_rat_mode_pref_from_string (const gchar *str,
+ QmiNasRatModePreference *out);
+gboolean qmicli_read_facility_from_string (const gchar *str,
+ QmiDmsUimFacility *out);
+gboolean qmicli_read_enable_disable_from_string (const gchar *str,
+ gboolean *out);
+gboolean qmicli_read_firmware_id_from_string (const gchar *str,
+ QmiDmsFirmwareImageType *out_type,
+ guint *out_index);
+gboolean qmicli_read_radio_interface_from_string (const gchar *str,
+ QmiNasRadioInterface *out);
+gboolean qmicli_read_net_open_flags_from_string (const gchar *str,
+ QmiDeviceOpenFlags *out);
+gboolean qmicli_read_link_layer_protocol_from_string (const gchar *str,
+ QmiWdaLinkLayerProtocol *out);
+gboolean qmicli_read_autoconnect_setting_from_string (const gchar *str,
+ QmiWdsAutoconnectSetting *out);
+gboolean qmicli_read_autoconnect_setting_roaming_from_string (const gchar *str,
+ QmiWdsAutoconnectSettingRoaming *out);
gboolean qmicli_read_non_empty_string (const gchar *str,
const gchar *description,
diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c
index 0905160..5e90b4a 100644
--- a/src/qmicli/qmicli-wds.c
+++ b/src/qmicli/qmicli-wds.c
@@ -60,6 +60,7 @@ static gboolean get_current_data_bearer_technology_flag;
static gchar *get_profile_list_str;
static gchar *get_default_settings_str;
static gboolean get_autoconnect_settings_flag;
+static gchar *set_autoconnect_settings_str;
static gboolean get_supported_messages_flag;
static gboolean reset_flag;
static gboolean noop_flag;
@@ -109,6 +110,10 @@ static GOptionEntry entries[] = {
"Get autoconnect settings",
NULL
},
+ { "wds-set-autoconnect-settings", 0, 0, G_OPTION_ARG_STRING, &set_autoconnect_settings_str,
+ "Set autoconnect settings (roaming settings optional)",
+ "[(enabled|disabled|paused)[,(roaming-allowed|home-only)]]"
+ },
{ "wds-get-supported-messages", 0, 0, G_OPTION_ARG_NONE, &get_supported_messages_flag,
"Get supported messages",
NULL
@@ -158,6 +163,7 @@ qmicli_wds_options_enabled (void)
!!get_profile_list_str +
!!get_default_settings_str +
get_autoconnect_settings_flag +
+ !!set_autoconnect_settings_str +
get_supported_messages_flag +
reset_flag +
noop_flag);
@@ -1049,6 +1055,87 @@ get_autoconnect_settings_ready (QmiClientWds *client,
operation_shutdown (TRUE);
}
+static QmiMessageWdsSetAutoconnectSettingsInput *
+set_autoconnect_settings_input_create (const gchar *str)
+{
+ QmiMessageWdsSetAutoconnectSettingsInput *input = NULL;
+ gchar **split;
+ QmiWdsAutoconnectSetting status;
+ QmiWdsAutoconnectSettingRoaming roaming;
+ GError *error = NULL;
+
+ split = g_strsplit (str, ",", -1);
+ input = qmi_message_wds_set_autoconnect_settings_input_new ();
+
+ if (g_strv_length (split) != 2 && g_strv_length (split) != 1) {
+ g_printerr ("error: expected 1 or 2 options in autoconnect settings\n");
+ goto error_out;
+ }
+
+ g_strstrip (split[0]);
+ if (!qmicli_read_autoconnect_setting_from_string (split[0], &status)) {
+ g_printerr ("error: failed to parse autoconnect setting\n");
+ goto error_out;
+ }
+ if (!qmi_message_wds_set_autoconnect_settings_input_set_status (input, status, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n",
+ error->message);
+ goto error_out;
+ }
+
+ if (g_strv_length (split) == 2) {
+ g_strstrip (split[1]);
+ if (!qmicli_read_autoconnect_setting_roaming_from_string (g_str_equal (split[1], "roaming-allowed") ? "allowed" : split[1], &roaming)) {
+ g_printerr ("error: failed to parse autoconnect roaming setting\n");
+ goto error_out;
+ }
+ if (!qmi_message_wds_set_autoconnect_settings_input_set_roaming (input, roaming, &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n",
+ error->message);
+ goto error_out;
+ }
+ }
+
+ g_strfreev (split);
+ return input;
+
+error_out:
+ if (error)
+ g_error_free (error);
+ g_strfreev (split);
+ qmi_message_wds_set_autoconnect_settings_input_unref (input);
+ return NULL;
+}
+
+static void
+set_autoconnect_settings_ready (QmiClientWds *client,
+ GAsyncResult *res)
+{
+ QmiMessageWdsSetAutoconnectSettingsOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_wds_set_autoconnect_settings_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_wds_set_autoconnect_settings_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't set autoconnect settings: %s\n",
+ error->message);
+ g_error_free (error);
+ qmi_message_wds_set_autoconnect_settings_output_unref (output);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ g_print ("Autoconnect settings updated\n");
+ qmi_message_wds_set_autoconnect_settings_output_unref (output);
+ operation_shutdown (TRUE);
+}
+
static void
get_supported_messages_ready (QmiClientWds *client,
GAsyncResult *res)
@@ -1368,6 +1455,27 @@ qmicli_wds_run (QmiDevice *device,
return;
}
+ /* Request to print autoconnect settings? */
+ if (set_autoconnect_settings_str) {
+ QmiMessageWdsSetAutoconnectSettingsInput *input;
+
+ input = set_autoconnect_settings_input_create (set_autoconnect_settings_str);
+ if (!input) {
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ g_debug ("Asynchronously set autoconnect settings...");
+ qmi_client_wds_set_autoconnect_settings (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)set_autoconnect_settings_ready,
+ NULL);
+ qmi_message_wds_set_autoconnect_settings_input_unref (input);
+ return;
+ }
+
/* Request to list supported messages? */
if (get_supported_messages_flag) {
g_debug ("Asynchronously getting supported WDS messages...");