summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-05-21 11:29:21 +0200
committerAleksander Morgado <aleksander@aleksander.es>2014-05-21 11:42:04 +0200
commit8e24ca194d885f882398d3212283bffef64c9959 (patch)
treed86fee6e04e391b8ae6e6f4fba48f77008d0f63b
parenta4d592e81ca8bddeae923351b009b61f6dd7fce0 (diff)
downloadlibqmi-8e24ca194d885f882398d3212283bffef64c9959.tar.gz
cli,wda: new '--wda-set-data-format' action
For now, we just allow setting the Link Layer Protocol. If we ever update the command to allow more or different settings, we can do so by just making it a list of comma separated values.
-rw-r--r--src/qmicli/qmicli-helpers.c21
-rw-r--r--src/qmicli/qmicli-helpers.h36
-rw-r--r--src/qmicli/qmicli-wda.c131
3 files changed, 170 insertions, 18 deletions
diff --git a/src/qmicli/qmicli-helpers.c b/src/qmicli/qmicli-helpers.c
index b57ac68d..c6911c69 100644
--- a/src/qmicli/qmicli-helpers.c
+++ b/src/qmicli/qmicli-helpers.c
@@ -347,6 +347,27 @@ qmicli_read_net_open_flags_from_string (const gchar *str,
}
gboolean
+qmicli_read_link_layer_protocol_from_string (const gchar *str,
+ QmiWdaLinkLayerProtocol *out)
+{
+ GType type;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ type = qmi_wda_link_layer_protocol_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 = (QmiWdaLinkLayerProtocol)enum_value->value;
+ else
+ g_printerr ("error: invalid link layer protocol 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 22ff3302..72f88255 100644
--- a/src/qmicli/qmicli-helpers.h
+++ b/src/qmicli/qmicli-helpers.h
@@ -29,23 +29,25 @@ 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_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_non_empty_string (const gchar *str,
const gchar *description,
diff --git a/src/qmicli/qmicli-wda.c b/src/qmicli/qmicli-wda.c
index 75571db3..be5c1c35 100644
--- a/src/qmicli/qmicli-wda.c
+++ b/src/qmicli/qmicli-wda.c
@@ -42,10 +42,15 @@ typedef struct {
static Context *ctx;
/* Options */
+static gchar *set_data_format_str;
static gboolean get_data_format_flag;
static gboolean noop_flag;
static GOptionEntry entries[] = {
+ { "wda-set-data-format", 0, 0, G_OPTION_ARG_STRING, &set_data_format_str,
+ "Set data format",
+ "[raw-ip|802-3]"
+ },
{ "wda-get-data-format", 0, 0, G_OPTION_ARG_NONE, &get_data_format_flag,
"Get data format",
NULL
@@ -81,7 +86,8 @@ qmicli_wda_options_enabled (void)
if (checked)
return !!n_actions;
- n_actions = (get_data_format_flag +
+ n_actions = (!!set_data_format_str +
+ get_data_format_flag +
noop_flag);
if (n_actions > 1) {
@@ -201,6 +207,112 @@ get_data_format_ready (QmiClientWda *client,
shutdown (TRUE);
}
+static void
+set_data_format_ready (QmiClientWda *client,
+ GAsyncResult *res)
+{
+ QmiMessageWdaSetDataFormatOutput *output;
+ GError *error = NULL;
+ gboolean qos_format;
+ QmiWdaLinkLayerProtocol link_layer_protocol;
+ QmiWdaDataAggregationProtocol data_aggregation_protocol;
+ guint32 ndp_signature;
+ guint32 data_aggregation_max_datagrams;
+ guint32 data_aggregation_max_size;
+
+ output = qmi_client_wda_set_data_format_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_wda_set_data_format_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't set data format: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_wda_set_data_format_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+ g_print ("[%s] Successfully set data format\n",
+ qmi_device_get_path_display (ctx->device));
+
+ if (qmi_message_wda_set_data_format_output_get_qos_format (
+ output,
+ &qos_format,
+ NULL))
+ g_print (" QoS flow header: %s\n", qos_format ? "yes" : "no");
+
+ if (qmi_message_wda_set_data_format_output_get_link_layer_protocol (
+ output,
+ &link_layer_protocol,
+ NULL))
+ g_print (" Link layer protocol: '%s'\n",
+ qmi_wda_link_layer_protocol_get_string (link_layer_protocol));
+
+ if (qmi_message_wda_set_data_format_output_get_uplink_data_aggregation_protocol (
+ output,
+ &data_aggregation_protocol,
+ NULL))
+ g_print (" Uplink data aggregation protocol: '%s'\n",
+ qmi_wda_data_aggregation_protocol_get_string (data_aggregation_protocol));
+
+ if (qmi_message_wda_set_data_format_output_get_downlink_data_aggregation_protocol (
+ output,
+ &data_aggregation_protocol,
+ NULL))
+ g_print (" Downlink data aggregation protocol: '%s'\n",
+ qmi_wda_data_aggregation_protocol_get_string (data_aggregation_protocol));
+
+ if (qmi_message_wda_set_data_format_output_get_ndp_signature (
+ output,
+ &ndp_signature,
+ NULL))
+ g_print (" NDP signature: '%u'\n", ndp_signature);
+
+ if (qmi_message_wda_set_data_format_output_get_downlink_data_aggregation_max_datagrams (
+ output,
+ &data_aggregation_max_datagrams,
+ NULL))
+ g_print ("Downlink data aggregation max datagrams: '%u'\n", data_aggregation_max_datagrams);
+
+ if (qmi_message_wda_set_data_format_output_get_downlink_data_aggregation_max_size (
+ output,
+ &data_aggregation_max_size,
+ NULL))
+ g_print (" Downlink data aggregation max size: '%u'\n", data_aggregation_max_size);
+
+ qmi_message_wda_set_data_format_output_unref (output);
+ shutdown (TRUE);
+}
+
+static QmiMessageWdaSetDataFormatInput *
+set_data_format_input_create (const gchar *str)
+{
+ QmiMessageWdaSetDataFormatInput *input = NULL;
+ QmiWdaLinkLayerProtocol link_layer_protocol;
+
+ if (qmicli_read_link_layer_protocol_from_string (str, &link_layer_protocol)) {
+ GError *error = NULL;
+
+ input = qmi_message_wda_set_data_format_input_new ();
+ if (!qmi_message_wda_set_data_format_input_set_link_layer_protocol (
+ input,
+ link_layer_protocol,
+ &error)) {
+ g_printerr ("error: couldn't create input data bundle: '%s'\n",
+ error->message);
+ g_error_free (error);
+ qmi_message_wda_set_data_format_input_unref (input);
+ input = NULL;
+ }
+ }
+
+ return input;
+}
+
void
qmicli_wda_run (QmiDevice *device,
QmiClientWda *client,
@@ -212,6 +324,23 @@ qmicli_wda_run (QmiDevice *device,
ctx->client = g_object_ref (client);
ctx->cancellable = g_object_ref (cancellable);
+ /* Request to set data format? */
+ if (set_data_format_str) {
+ QmiMessageWdaSetDataFormatInput *input;
+
+ input = set_data_format_input_create (set_data_format_str);
+
+ g_debug ("Asynchronously setting data format...");
+ qmi_client_wda_set_data_format (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)set_data_format_ready,
+ NULL);
+ qmi_message_wda_set_data_format_input_unref (input);
+ return;
+ }
+
/* Request to read data format? */
if (get_data_format_flag) {
g_debug ("Asynchronously getting data format...");