[PATCH] nas: Implement vendor specific "Swi Get Status"
Bjørn Mork
bjorn at mork.no
Tue Aug 20 10:19:59 UTC 2019
This Sierra Wireless (swi) specific request returns some of the system
info known from the swi specific AT command "!GSTATUS?".
[/dev/cdc-wdm0] Successfully got status:
Common Info:
Temperature: '32'
Modem mode: 'online'
System mode: 'lte'
IMS registration state: 'no-srv'
Packet service state: 'attached'
LTE info:
Band: 'bc-3'
Bandwidth: '20'
RX channel: '1450'
TX channel: '19450'
EMM state: 'registered'
EMM sub state: '0'
EMM connection state: 'rrc-connecting'
Signed-off-by: Bjørn Mork <bjorn at mork.no>
---
data/qmi-service-nas.json | 56 ++++++++++++-
src/libqmi-glib/qmi-enums-nas.h | 138 ++++++++++++++++++++++++++++++++
src/qmicli/qmicli-nas.c | 110 +++++++++++++++++++++++++
3 files changed, 303 insertions(+), 1 deletion(-)
diff --git a/data/qmi-service-nas.json b/data/qmi-service-nas.json
index 1c5ab545a5e2..07763a16d4bc 100644
--- a/data/qmi-service-nas.json
+++ b/data/qmi-service-nas.json
@@ -3579,5 +3579,59 @@
"public-format" : "QmiNasScellState" },
{ "name" : "Cell Index",
"format" : "guint8" } ] },
- "prerequisites" : [ { "common-ref" : "Success" } ] } ] }
+ "prerequisites" : [ { "common-ref" : "Success" } ] } ] },
+
+ // *********************************************************************************
+ { "name" : "Swi Get Status",
+ "type" : "Message",
+ "service" : "NAS",
+ "id" : "0x5556",
+ "vendor" : "0x1199",
+ "since" : "1.20",
+ "output" : [ { "common-ref" : "Operation Result" },
+ { "name" : "Common Info",
+ "id" : "0x01",
+ "type" : "TLV",
+ "since" : "1.20",
+ "format" : "sequence",
+ "contents" : [ { "name" : "Temperature",
+ "format" : "guint8"},
+ { "name" : "Modem Mode",
+ "format" : "guint8",
+ "public-format" : "QmiNasSwiModemMode"},
+ { "name" : "System Mode",
+ "format" : "guint8",
+ "public-format" : "QmiNasSwiSystemMode"},
+ { "name" : "IMS Registration State",
+ "format" : "guint8",
+ "public-format" : "QmiNasSwiImsRegState"},
+ { "name" : "Packet Service State",
+ "format" : "guint8",
+ "public-format" : "QmiNasSwiPsState" } ],
+ "prerequisites" : [ { "common-ref" : "Success" } ] },
+ { "name" : "LTE Info",
+ "id" : "0x10",
+ "type" : "TLV",
+ "since" : "1.20",
+ "format" : "sequence",
+ "contents" : [ { "name" : "Band",
+ "format" : "guint8",
+ "public-format" : "QmiNasActiveBand" },
+ { "name" : "Bandwidth",
+ "format" : "guint8",
+ "public-format" : "QmiNasDLBandwidth"},
+ { "name" : "RX Channel",
+ "format" : "guint16" },
+ { "name" : "TX Channel",
+ "format" : "guint16" },
+ { "name" : "EMM State",
+ "format" : "guint8",
+ "public-format" : "QmiNasSwiEmmState"},
+ { "name" : "EMM Sub State",
+ "format" : "guint8" },
+ { "name" : "EMM Connection State",
+ "format" : "guint8",
+ "public-format" : "QmiNasSwiEmmConnectionState" } ],
+ "prerequisites" : [ { "common-ref" : "Success" } ] } ] }
+
]
diff --git a/src/libqmi-glib/qmi-enums-nas.h b/src/libqmi-glib/qmi-enums-nas.h
index 4f7f2544e8ca..b30e2efb8827 100644
--- a/src/libqmi-glib/qmi-enums-nas.h
+++ b/src/libqmi-glib/qmi-enums-nas.h
@@ -1525,4 +1525,142 @@ typedef enum {
QMI_NAS_USAGE_PREFERENCE_DATA_CENTRIC = 0x02
} QmiNasUsagePreference;
+/**
+ * QmiNasSwiModemMode:
+ * @QMI_NAS_SWI_MODEM_MODE_POWERING_OFF: Powering off
+ * @QMI_NAS_SWI_MODEM_MODE_FACTORY_TEST: Factory test
+ * @QMI_NAS_SWI_MODEM_MODE_OFFLINE: Offline
+ * @QMI_NAS_SWI_MODEM_MODE_OFFLINE_AMPS: Offline AMPS
+ * @QMI_NAS_SWI_MODEM_MODE_OFFLINE_CDMA: Offline CDMA
+ * @QMI_NAS_SWI_MODEM_MODE_ONLINE: Online
+ * @QMI_NAS_SWI_MODEM_MODE_LOW_POWER: Low power
+ * @QMI_NAS_SWI_MODEM_MODE_RESETTING: Resetting
+ * @QMI_NAS_SWI_MODEM_MODE_NETWORK_TEST: Network test
+ * @QMI_NAS_SWI_MODEM_MODE_OFFLINE_REQUEST: Offline request
+ * @QMI_NAS_SWI_MODEM_MODE_PSEUDO_ONLINE: Pseudo online
+ * @QMI_NAS_SWI_MODEM_MODE_RESETTING_MODEM: Resetting modem
+ * @QMI_NAS_SWI_MODEM_MODE_UNKNOWN: Unknown
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ QMI_NAS_SWI_MODEM_MODE_POWERING_OFF = 0x00,
+ QMI_NAS_SWI_MODEM_MODE_FACTORY_TEST = 0x01,
+ QMI_NAS_SWI_MODEM_MODE_OFFLINE = 0x02,
+ QMI_NAS_SWI_MODEM_MODE_OFFLINE_AMPS = 0x03,
+ QMI_NAS_SWI_MODEM_MODE_OFFLINE_CDMA = 0x04,
+ QMI_NAS_SWI_MODEM_MODE_ONLINE = 0x05,
+ QMI_NAS_SWI_MODEM_MODE_LOW_POWER = 0x06,
+ QMI_NAS_SWI_MODEM_MODE_RESETTING = 0x07,
+ QMI_NAS_SWI_MODEM_MODE_NETWORK_TEST = 0x08,
+ QMI_NAS_SWI_MODEM_MODE_OFFLINE_REQUEST = 0x09,
+ QMI_NAS_SWI_MODEM_MODE_PSEUDO_ONLINE = 0x0a,
+ QMI_NAS_SWI_MODEM_MODE_RESETTING_MODEM = 0x0b,
+ QMI_NAS_SWI_MODEM_MODE_UNKNOWN = 0xff
+} QmiNasSwiModemMode;
+
+/**
+ * QmiNasSwiSystemMode:
+ * @QMI_NAS_SWI_SYSTEM_MODE_NO_SERVICE: No service
+ * @QMI_NAS_SWI_SYSTEM_MODE_AMPS: AMPS
+ * @QMI_NAS_SWI_SYSTEM_MODE_CDMA: CDMA
+ * @QMI_NAS_SWI_SYSTEM_MODE_GSM: GSM
+ * @QMI_NAS_SWI_SYSTEM_MODE_HDR: HDR
+ * @QMI_NAS_SWI_SYSTEM_MODE_WCDMA: WCDMA
+ * @QMI_NAS_SWI_SYSTEM_MODE_GPS: GPS
+ * @QMI_NAS_SWI_SYSTEM_MODE_WLAN: WLAN
+ * @QMI_NAS_SWI_SYSTEM_MODE_LTE: LTE
+ * @QMI_NAS_SWI_SYSTEM_MODE_UNKNOWN: Unknown
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ QMI_NAS_SWI_SYSTEM_MODE_NO_SERVICE = 0x00,
+ QMI_NAS_SWI_SYSTEM_MODE_AMPS = 0x01,
+ QMI_NAS_SWI_SYSTEM_MODE_CDMA = 0x02,
+ QMI_NAS_SWI_SYSTEM_MODE_GSM = 0x03,
+ QMI_NAS_SWI_SYSTEM_MODE_HDR = 0x04,
+ QMI_NAS_SWI_SYSTEM_MODE_WCDMA = 0x05,
+ QMI_NAS_SWI_SYSTEM_MODE_GPS = 0x06,
+ QMI_NAS_SWI_SYSTEM_MODE_WLAN = 0x08,
+ QMI_NAS_SWI_SYSTEM_MODE_LTE = 0x09,
+ QMI_NAS_SWI_SYSTEM_MODE_UNKNOWN = 0xff
+} QmiNasSwiSystemMode;
+
+/**
+ * QmiNasSwiImsRegState:
+ * @QMI_NAS_SWI_IMS_REG_NO_SRV: No service
+ * @QMI_NAS_SWI_IMS_REG_IN_PROG: In prog
+ * @QMI_NAS_SWI_IMS_REG_FAILED: Failed
+ * @QMI_NAS_SWI_IMS_REG_LIMITED: Limited
+ * @QMI_NAS_SWI_IMS_REG_FULL_SRV: Full service
+ * @QMI_NAS_SWI_IMS_REG__UNKNOWN: Unknown
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ QMI_NAS_SWI_IMS_REG_NO_SRV = 0x00,
+ QMI_NAS_SWI_IMS_REG_IN_PROG = 0x01,
+ QMI_NAS_SWI_IMS_REG_FAILED = 0x02,
+ QMI_NAS_SWI_IMS_REG_LIMITED = 0x03,
+ QMI_NAS_SWI_IMS_REG_FULL_SRV = 0x04,
+ QMI_NAS_SWI_IMS_REG__UNKNOWN = 0xff
+} QmiNasSwiImsRegState;
+
+/**
+ * QmiNasSwiPsState:
+ * @QMI_NAS_SWI_PS_STATE_ATTACHED: Attached
+ * @QMI_NAS_SWI_PS_STATE_DETACHED: Detached
+ * @QMI_NAS_SWI_PS_STATE_UNKNOWN: Unknown
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ QMI_NAS_SWI_PS_STATE_ATTACHED = 0x00,
+ QMI_NAS_SWI_PS_STATE_DETACHED = 0x01,
+ QMI_NAS_SWI_PS_STATE_UNKNOWN = 0xff
+} QmiNasSwiPsState;
+
+/**
+ * QmiNasSwiEmmState:
+ * @QMI_NAS_SWI_EMM_STATE_DEREGISTERED: Deregistered
+ * @QMI_NAS_SWI_EMM_STATE_REG_INITIATED: Registration initiated
+ * @QMI_NAS_SWI_EMM_STATE_REGISTERED: Registered
+ * @QMI_NAS_SWI_EMM_STATE_TAU_INITIATED: TAU initiated
+ * @QMI_NAS_SWI_EMM_STATE_SR_INITIATED: SR initiated
+ * @QMI_NAS_SWI_EMM_STATE_DEREG_INITIATED: Deregistration initiated
+ * @QMI_NAS_SWI_EMM_STATE_INVALID: Invalid
+ * @QMI_NAS_SWI_EMM_STATE_UNKNOWN: Unknown
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ QMI_NAS_SWI_EMM_STATE_DEREGISTERED = 0x00,
+ QMI_NAS_SWI_EMM_STATE_REG_INITIATED = 0x01,
+ QMI_NAS_SWI_EMM_STATE_REGISTERED = 0x02,
+ QMI_NAS_SWI_EMM_STATE_TAU_INITIATED = 0x03,
+ QMI_NAS_SWI_EMM_STATE_SR_INITIATED = 0x04,
+ QMI_NAS_SWI_EMM_STATE_DEREG_INITIATED = 0x05,
+ QMI_NAS_SWI_EMM_STATE_INVALID = 0x06,
+ QMI_NAS_SWI_EMM_STATE_UNKNOWN = 0xff
+} QmiNasSwiEmmState;
+
+/**
+ * QmiNasSwiEmmConnectionState:
+ * @QMI_NAS_SWI_EMM_CONN_STATE_RRC_IDLE: RRC idle
+ * @QMI_NAS_SWI_EMM_CONN_STATE_WAITING_RRC_CFM: Waiting RRC Cfm
+ * @QMI_NAS_SWI_EMM_CONN_STATE_RRC_CONNECTING: RRC connecting
+ * @QMI_NAS_SWI_EMM_CONN_STATE_RRC_RELEASING: RRC releasing
+ * @QMI_NAS_SWI_EMM_CONN_STATE_UNKNOWN: Unknown
+ *
+ * Since: 1.20
+ */
+typedef enum {
+ QMI_NAS_SWI_EMM_CONN_STATE_RRC_IDLE = 0x00,
+ QMI_NAS_SWI_EMM_CONN_STATE_WAITING_RRC_CFM = 0x01,
+ QMI_NAS_SWI_EMM_CONN_STATE_RRC_CONNECTING = 0x02,
+ QMI_NAS_SWI_EMM_CONN_STATE_RRC_RELEASING = 0x03,
+ QMI_NAS_SWI_EMM_CONN_STATE_UNKNOWN = 0xff
+} QmiNasSwiEmmConnectionState;
+
#endif /* _LIBQMI_GLIB_QMI_ENUMS_NAS_H_ */
diff --git a/src/qmicli/qmicli-nas.c b/src/qmicli/qmicli-nas.c
index caf5609050a9..527f327f066f 100644
--- a/src/qmicli/qmicli-nas.c
+++ b/src/qmicli/qmicli-nas.c
@@ -59,6 +59,7 @@ static gboolean get_operator_name_flag;
static gboolean get_lte_cphy_ca_info_flag;
static gboolean get_rf_band_info_flag;
static gboolean get_supported_messages_flag;
+static gboolean swi_get_status_flag;
static gboolean reset_flag;
static gboolean noop_flag;
@@ -127,6 +128,10 @@ static GOptionEntry entries[] = {
"Get supported messages",
NULL
},
+ { "nas-swi-get-status", 0, 0, G_OPTION_ARG_NONE, &swi_get_status_flag,
+ "Get status ((Sierra Wireless specific)",
+ NULL
+ },
{ "nas-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag,
"Reset the service state",
NULL
@@ -178,6 +183,7 @@ qmicli_nas_options_enabled (void)
get_lte_cphy_ca_info_flag +
get_rf_band_info_flag +
get_supported_messages_flag +
+ swi_get_status_flag +
reset_flag +
noop_flag);
@@ -3377,6 +3383,98 @@ get_supported_messages_ready (QmiClientNas *client,
operation_shutdown (TRUE);
}
+static void
+swi_get_status_ready (QmiClientNas *client,
+ GAsyncResult *res)
+{
+ QmiMessageNasSwiGetStatusOutput *output;
+ GError *error = NULL;
+
+ guint8 temperature;
+ QmiNasSwiModemMode modem_mode;
+ QmiNasSwiSystemMode system_mode;
+ QmiNasSwiImsRegState ims_reg_state;
+ QmiNasSwiPsState ps_state;
+
+ QmiNasActiveBand band;
+ QmiNasDLBandwidth bandwidth;
+ guint16 rx_channel;
+ guint16 tx_channel;
+ QmiNasSwiEmmState emm_state;
+ guint8 emm_sub_state;
+ QmiNasSwiEmmConnectionState emm_conn_state;
+
+ output = qmi_client_nas_swi_get_status_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_swi_get_status_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't get status: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_nas_swi_get_status_output_unref (output);
+ operation_shutdown (FALSE);
+ return;
+ }
+
+ g_print ("[%s] Successfully got status:\n",
+ qmi_device_get_path_display (ctx->device));
+
+ if (qmi_message_nas_swi_get_status_output_get_common_info (
+ output,
+ &temperature,
+ &modem_mode,
+ &system_mode,
+ &ims_reg_state,
+ &ps_state,
+ NULL)) {
+ g_print ("Common Info:\n"
+ "\tTemperature: '%u'\n"
+ "\tModem mode: '%s'\n"
+ "\tSystem mode: '%s'\n"
+ "\tIMS registration state: '%s'\n"
+ "\tPacket service state: '%s'\n",
+ temperature,
+ qmi_nas_swi_modem_mode_get_string (modem_mode),
+ qmi_nas_swi_system_mode_get_string (system_mode),
+ qmi_nas_swi_ims_reg_state_get_string (ims_reg_state),
+ qmi_nas_swi_ps_state_get_string (ps_state));
+ }
+
+ if (qmi_message_nas_swi_get_status_output_get_lte_info (
+ output,
+ &band,
+ &bandwidth,
+ &rx_channel,
+ &tx_channel,
+ &emm_state,
+ &emm_sub_state,
+ &emm_conn_state,
+ NULL)) {
+ g_print ("LTE info:\n"
+ "\tBand: '%s'\n"
+ "\tBandwidth: '%s'\n"
+ "\tRX channel: '%" G_GUINT16_FORMAT"'\n"
+ "\tTX channel: '%" G_GUINT16_FORMAT"'\n"
+ "\tEMM state: '%s'\n"
+ "\tEMM sub state: '%u'\n"
+ "\tEMM connection state: '%s'\n",
+ qmi_nas_active_band_get_string (band),
+ qmi_nas_dl_bandwidth_get_string (bandwidth),
+ rx_channel,
+ tx_channel,
+ qmi_nas_swi_emm_state_get_string (emm_state),
+ emm_sub_state,
+ qmi_nas_swi_emm_connection_state_get_string (emm_conn_state));
+ }
+
+ qmi_message_nas_swi_get_status_output_unref (output);
+ operation_shutdown (TRUE);
+}
+
static void
reset_ready (QmiClientNas *client,
GAsyncResult *res)
@@ -3642,6 +3740,18 @@ qmicli_nas_run (QmiDevice *device,
return;
}
+ /* Request to get status */
+ if (swi_get_status_flag) {
+ g_debug ("Asynchronously getting status (Sierra Wireless specific)...");
+ qmi_client_nas_swi_get_status (ctx->client,
+ NULL,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)swi_get_status_ready,
+ NULL);
+ return;
+ }
+
/* Request to reset NAS service? */
if (reset_flag) {
g_debug ("Asynchronously resetting NAS service...");
--
2.20.1
More information about the libqmi-devel
mailing list