[PATCH] nas: implement 'Get LTE Cphy CA Info'

Bjørn Mork bjorn at mork.no
Thu Mar 31 14:13:37 UTC 2016


Carrier aggregation is much more fun when you can watch it being
activated :)

$ qmicli -p -d /dev/cdc-wdm0   --nas-get-lte-cphy-ca-info
[/dev/cdc-wdm0] Successfully got carrier aggregation info
DL Bandwidth: '20'
Secondary Cell Info
        Physical Cell ID: '101'
        TX Channel: '3050'
        DL Bandwidth: '20'
        LTE Band: 'eutran-7'
        State: 'activated'
Primary Cell Info
        Physical Cell ID: '299'
        TX Channel: '1450'
        DL Bandwidth: '20'
        LTE Band: 'eutran-3'
Secondary Cell index: '1'

I have absolutely no clue about the required NAS version, so I just put
the current version I have there...

Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
 data/qmi-service-nas.json       |  56 +++++++++++++++++++++
 src/libqmi-glib/qmi-enums-nas.h |  40 +++++++++++++++
 src/qmicli/qmicli-nas.c         | 106 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 202 insertions(+)

diff --git a/data/qmi-service-nas.json b/data/qmi-service-nas.json
index 5471713..053de79 100644
--- a/data/qmi-service-nas.json
+++ b/data/qmi-service-nas.json
@@ -3182,5 +3182,61 @@
                                                                                   "format"        : "gint32" },
                                                                                 { "name"          : "GPS Time In Milliseconds",
                                                                                   "format"        : "guint64" } ] } } ],
+                     "prerequisites": [ { "common-ref" : "Success" } ] } ] },
+
+  // *********************************************************************************
+  {  "name"    : "Get LTE Cphy CA Info",
+     "type"    : "Message",
+     "service" : "NAS",
+     "id"      : "0x00AC",
+     "version" : "1.25",
+     "output"  : [ { "common-ref" : "Operation Result" },
+                   { "name"       : "DL Bandwidth",
+                     "id"         : "0x11",
+                     "mandatory"  : "no",
+                     "type"       : "TLV",
+                     "format"     : "guint32",
+		     "public-format": "QmiNasDLBandwidth",
+                     "prerequisites": [ { "common-ref" : "Success" } ] },
+                   { "name"       : "Phy CA Agg SCell Info",
+                     "id"         : "0x12",
+                     "mandatory"  : "no",
+                     "type"       : "TLV",
+                     "format"     : "sequence",
+                     "contents"   : [ { "name"          : "Physical Cell ID",
+					"format"        : "guint16"},
+                                      { "name"   : "Tx Channel",
+					"format" : "guint16" },
+                                      { "name"   : "DL Bandwidth",
+					"format" : "guint32",
+					"public-format" : "QmiNasDLBandwidth" },
+                                      { "name"   : "LTE Band",
+					"format" : "guint16",
+					"public-format" : "QmiNasActiveBand" },
+                                      { "name"   : "State",
+					"format" : "guint32",
+				        "public-format" : "QmiNasScellState" } ],
+                     "prerequisites": [ { "common-ref" : "Success" } ] },
+                   { "name"       : "Phy CA Agg PCell Info",
+                     "id"         : "0x13",
+                     "mandatory"  : "no",
+                     "type"       : "TLV",
+                     "format"     : "sequence",
+                     "contents"   : [ { "name"          : "Physical Cell ID",
+					"format"        : "guint16"},
+                                      { "name"   : "Tx Channel",
+					"format" : "guint16" },
+                                      { "name"   : "DL Bandwidth",
+					"format" : "guint32",
+					"public-format" : "QmiNasDLBandwidth" },
+                                      { "name"   : "LTE Band",
+					"format" : "guint16",
+					"public-format" : "QmiNasActiveBand" } ],
+                     "prerequisites": [ { "common-ref" : "Success" } ] },
+                   { "name"       : "SCell index",
+                     "id"         : "0x14",
+                     "mandatory"  : "no",
+                     "type"       : "TLV",
+                     "format"     : "guint8",
                      "prerequisites": [ { "common-ref" : "Success" } ] } ] }
 ]
diff --git a/src/libqmi-glib/qmi-enums-nas.h b/src/libqmi-glib/qmi-enums-nas.h
index 8c00490..6c4cc21 100644
--- a/src/libqmi-glib/qmi-enums-nas.h
+++ b/src/libqmi-glib/qmi-enums-nas.h
@@ -893,4 +893,44 @@ typedef enum {
     QMI_NAS_WCDMA_RRC_STATE_CELL_DCH     = 4
 } QmiNasWcdmaRrcState;
 
+/*****************************************************************************/
+/* Helper enums for the 'QMI NAS Get LTE Cphy CA Info' request/response */
+/**
+ * QmiNasDLBandwidth:
+ * @QMI_NAS_DL_BANDWIDTH_1_4: 1.4 MHz
+ * @QMI_NAS_DL_BANDWIDTH_3: 3 MHz
+ * @QMI_NAS_DL_BANDWIDTH_5: 5 MHz
+ * @QMI_NAS_DL_BANDWIDTH_10: 10 MHz
+ * @QMI_NAS_DL_BANDWIDTH_15: 15 MHz
+ * @QMI_NAS_DL_BANDWIDTH_20: 20 MHz
+ * @QMI_NAS_DL_BANDWIDTH_INVALID: Invalid
+ * @QMI_NAS_DL_BANDWIDTH_UNKNOWN: Unknown
+ *
+ * DL Bandwidth.
+ */
+typedef enum {
+    QMI_NAS_DL_BANDWIDTH_1_4  = 0,
+    QMI_NAS_DL_BANDWIDTH_3,
+    QMI_NAS_DL_BANDWIDTH_5,
+    QMI_NAS_DL_BANDWIDTH_10,
+    QMI_NAS_DL_BANDWIDTH_15,
+    QMI_NAS_DL_BANDWIDTH_20,
+    QMI_NAS_DL_BANDWIDTH_INVALID,
+    QMI_NAS_DL_BANDWIDTH_UNKNOWN  = 0xFF
+} QmiNasDLBandwidth;
+
+/**
+ * QmiNasScellState:
+ * @QMI_NAS_SCELL_STATE_DECONFIGURED: Deconfigured
+ * @QMI_NAS_SCELL_STATE_DEACTIVATED: Deactivated
+ * @QMI_NAS_SCELL_STATE_ACTIVATED: Activated
+ *
+ * SCell State.
+ */
+typedef enum {
+    QMI_NAS_SCELL_STATE_DECONFIGURED = 0,
+    QMI_NAS_SCELL_STATE_DEACTIVATED,
+    QMI_NAS_SCELL_STATE_ACTIVATED
+} QmiNasScellState;
+
 #endif /* _LIBQMI_GLIB_QMI_ENUMS_NAS_H_ */
diff --git a/src/qmicli/qmicli-nas.c b/src/qmicli/qmicli-nas.c
index 312ae16..10e6b23 100644
--- a/src/qmicli/qmicli-nas.c
+++ b/src/qmicli/qmicli-nas.c
@@ -53,6 +53,7 @@ static gboolean get_system_selection_preference_flag;
 static gchar *set_system_selection_preference_str;
 static gboolean network_scan_flag;
 static gboolean get_cell_location_info_flag;
+static gboolean get_lte_cphy_ca_info_flag;
 static gboolean get_supported_messages_flag;
 static gboolean reset_flag;
 static gboolean noop_flag;
@@ -102,6 +103,10 @@ static GOptionEntry entries[] = {
       "Get Cell Location Info",
       NULL
     },
+    { "nas-get-lte-cphy-ca-info", 0, 0, G_OPTION_ARG_NONE, &get_lte_cphy_ca_info_flag,
+      "Get LTE Cphy CA Info",
+      NULL
+    },
     { "nas-get-supported-messages", 0, 0, G_OPTION_ARG_NONE, &get_supported_messages_flag,
       "Get supported messages",
       NULL
@@ -152,6 +157,7 @@ qmicli_nas_options_enabled (void)
                  !!set_system_selection_preference_str +
                  network_scan_flag +
                  get_cell_location_info_flag +
+                 get_lte_cphy_ca_info_flag +
                  get_supported_messages_flag +
                  reset_flag +
                  noop_flag);
@@ -2761,6 +2767,94 @@ get_cell_location_info_ready (QmiClientNas *client,
 }
 
 static void
+get_lte_cphy_ca_info_ready (QmiClientNas *client,
+                            GAsyncResult *res)
+{
+    QmiMessageNasGetLteCphyCaInfoOutput *output;
+    GError *error = NULL;
+    guint16 pci;
+    guint16 channel;
+    QmiNasDLBandwidth dl_bandwidth;
+    QmiNasActiveBand band;
+    QmiNasScellState state;
+    guint8 index;
+
+    output = qmi_client_nas_get_lte_cphy_ca_info_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_nas_get_lte_cphy_ca_info_output_get_result (output, &error)) {
+        g_printerr ("error: couldn't get carrier aggregation info: %s\n", error->message);
+        g_error_free (error);
+        qmi_message_nas_get_lte_cphy_ca_info_output_unref (output);
+        operation_shutdown (FALSE);
+        return;
+    }
+
+    g_print ("[%s] Successfully got carrier aggregation info\n",
+             qmi_device_get_path_display (ctx->device));
+
+    if (qmi_message_nas_get_lte_cphy_ca_info_output_get_dl_bandwidth (
+        output,
+        &dl_bandwidth,
+        NULL)) {
+        g_print ("DL Bandwidth: '%s'\n",
+                 qmi_nas_dl_bandwidth_get_string (dl_bandwidth));
+    }
+
+    if (qmi_message_nas_get_lte_cphy_ca_info_output_get_phy_ca_agg_scell_info (
+        output,
+        &pci,
+        &channel,
+        &dl_bandwidth,
+        &band,
+        &state,
+        NULL)) {
+        g_print ("Secondary Cell Info\n");
+        g_print ("\tPhysical Cell ID: '%" G_GUINT16_FORMAT"'\n"
+                 "\tTX Channel: '%" G_GUINT16_FORMAT"'\n"
+                 "\tDL Bandwidth: '%s'\n"
+                 "\tLTE Band: '%s'\n"
+                 "\tState: '%s'\n",
+                 pci, channel,
+                 qmi_nas_dl_bandwidth_get_string (dl_bandwidth),
+                 qmi_nas_active_band_get_string (band),
+                 qmi_nas_scell_state_get_string (state));
+    }
+
+    if (qmi_message_nas_get_lte_cphy_ca_info_output_get_phy_ca_agg_pcell_info (
+        output,
+        &pci,
+        &channel,
+        &dl_bandwidth,
+        &band,
+        NULL)) {
+        g_print ("Primary Cell Info\n");
+        g_print ("\tPhysical Cell ID: '%" G_GUINT16_FORMAT"'\n"
+                 "\tTX Channel: '%" G_GUINT16_FORMAT"'\n"
+                 "\tDL Bandwidth: '%s'\n"
+                 "\tLTE Band: '%s'\n",
+                 pci, channel,
+                 qmi_nas_dl_bandwidth_get_string (dl_bandwidth),
+                 qmi_nas_active_band_get_string (band));
+    }
+
+    if (qmi_message_nas_get_lte_cphy_ca_info_output_get_scell_index (
+        output,
+        &index,
+        NULL)) {
+        g_print ("Secondary Cell index: '%u'\n", index);
+    }
+
+    qmi_message_nas_get_lte_cphy_ca_info_output_unref (output);
+    operation_shutdown (TRUE);
+}
+
+static void
 get_supported_messages_ready (QmiClientNas *client,
                               GAsyncResult *res)
 {
@@ -3004,6 +3098,18 @@ qmicli_nas_run (QmiDevice *device,
         return;
     }
 
+    /* Request to get carrier aggregation info? */
+    if (get_lte_cphy_ca_info_flag) {
+        g_debug ("Asynchronously getting carrier aggregation info ...");
+        qmi_client_nas_get_lte_cphy_ca_info (ctx->client,
+                                             NULL,
+                                             10,
+                                             ctx->cancellable,
+                                             (GAsyncReadyCallback)get_lte_cphy_ca_info_ready,
+                                             NULL);
+        return;
+    }
+
     /* Request to list supported messages? */
     if (get_supported_messages_flag) {
         g_debug ("Asynchronously getting supported NAS messages...");
-- 
2.1.4



More information about the libqmi-devel mailing list