aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-07 16:21:51 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-07 16:32:05 +0200
commit60b96a2ee14bb2fbe981cee70c5bf2f85c6a24f3 (patch)
tree4a05741012617f8202243697a7f73665eeae5413
parentba166b4a47cba4074dc625e66b77e83a7b38efb5 (diff)
downloadexternal_libqmi-60b96a2ee14bb2fbe981cee70c5bf2f85c6a24f3.zip
external_libqmi-60b96a2ee14bb2fbe981cee70c5bf2f85c6a24f3.tar.gz
external_libqmi-60b96a2ee14bb2fbe981cee70c5bf2f85c6a24f3.tar.bz2
cli: new `--nas-get-home-network' action
-rw-r--r--TODO2
-rw-r--r--cli/qmicli-nas.c107
2 files changed, 109 insertions, 0 deletions
diff --git a/TODO b/TODO
index 0fb4d67..aef401d 100644
--- a/TODO
+++ b/TODO
@@ -39,5 +39,7 @@ List of things left for later:
* qmicli: Implement `--dms-get-software-version'.
* qmicli: Implement `--dms-set-service-programming-code'.
+ * qmicli: Print 3GPP2 network description in "Get Home Network"
+
* nas: Define the 'QmiNasRegistrationRejectCause' enum for the "Event Report"
indication and "Get System Info" response.
diff --git a/cli/qmicli-nas.c b/cli/qmicli-nas.c
index 994fcb3..c1e2d86 100644
--- a/cli/qmicli-nas.c
+++ b/cli/qmicli-nas.c
@@ -43,6 +43,7 @@ static Context *ctx;
/* Options */
static gboolean get_signal_strength_flag;
static gboolean get_signal_info_flag;
+static gboolean get_home_network_flag;
static gboolean get_serving_system_flag;
static gboolean get_system_info_flag;
static gboolean get_technology_preference_flag;
@@ -60,6 +61,10 @@ static GOptionEntry entries[] = {
"Get signal info",
NULL
},
+ { "nas-get-home-network", 0, 0, G_OPTION_ARG_NONE, &get_home_network_flag,
+ "Get home network",
+ NULL
+ },
{ "nas-get-serving-system", 0, 0, G_OPTION_ARG_NONE, &get_serving_system_flag,
"Get serving system",
NULL
@@ -117,6 +122,7 @@ qmicli_nas_options_enabled (void)
n_actions = (get_signal_strength_flag +
get_signal_info_flag +
+ get_home_network_flag +
get_serving_system_flag +
get_system_info_flag +
get_technology_preference_flag +
@@ -457,6 +463,95 @@ get_signal_strength_ready (QmiClientNas *client,
}
static void
+get_home_network_ready (QmiClientNas *client,
+ GAsyncResult *res)
+{
+ QmiMessageNasGetHomeNetworkOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_nas_get_home_network_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_nas_get_home_network_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't get home network: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_nas_get_home_network_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+ g_print ("[%s] Successfully got home network:\n",
+ qmi_device_get_path_display (ctx->device));
+
+ {
+ guint16 mcc;
+ guint16 mnc;
+ const gchar *description;
+
+ qmi_message_nas_get_home_network_output_get_home_network (
+ output,
+ &mcc,
+ &mnc,
+ &description,
+ NULL);
+
+ g_print ("\tHome network:\n"
+ "\t\tMCC: '%" G_GUINT16_FORMAT"'\n"
+ "\t\tMNC: '%" G_GUINT16_FORMAT"'\n"
+ "\t\tDescription: '%s'",
+ mcc,
+ mnc,
+ description);
+ }
+
+ {
+ guint16 sid;
+ guint16 nid;
+
+ if (qmi_message_nas_get_home_network_output_get_home_system_id (
+ output,
+ &sid,
+ &nid,
+ NULL)) {
+ g_print ("\t\tSID: '%" G_GUINT16_FORMAT"'\n"
+ "\t\tNID: '%" G_GUINT16_FORMAT"'\n",
+ sid,
+ nid);
+ }
+ }
+
+ {
+ guint16 mcc;
+ guint16 mnc;
+
+ if (qmi_message_nas_get_home_network_output_get_home_network_3gpp2 (
+ output,
+ &mcc,
+ &mnc,
+ NULL, /* display_description */
+ NULL, /* description_encoding */
+ NULL, /* description */
+ NULL)) {
+ g_print ("\t3GPP2 Home network (extended):\n"
+ "\t\tMCC: '%" G_GUINT16_FORMAT"'\n"
+ "\t\tMNC: '%" G_GUINT16_FORMAT"'\n",
+ mcc,
+ mnc);
+
+ /* TODO: convert description to UTF-8 and display */
+ }
+ }
+
+ qmi_message_nas_get_home_network_output_unref (output);
+ shutdown (TRUE);
+}
+
+static void
get_serving_system_ready (QmiClientNas *client,
GAsyncResult *res)
{
@@ -1949,6 +2044,18 @@ qmicli_nas_run (QmiDevice *device,
return;
}
+ /* Request to get home network? */
+ if (get_home_network_flag) {
+ g_debug ("Asynchronously getting home network...");
+ qmi_client_nas_get_home_network (ctx->client,
+ NULL,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_home_network_ready,
+ NULL);
+ return;
+ }
+
/* Request to get serving system? */
if (get_serving_system_flag) {
g_debug ("Asynchronously getting serving system...");