add --get-serving-system
authorFelix Fietkau <nbd@openwrt.org>
Sun, 17 Feb 2013 21:52:24 +0000 (22:52 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 17 Feb 2013 21:52:24 +0000 (22:52 +0100)
commands-nas.c
commands-nas.h

index e4d7ce6f57d4fccc089e5959482721a2fea97e11..c3298e2473bfddca7077877add610396567127c9 100644 (file)
@@ -100,3 +100,43 @@ cmd_nas_get_signal_info_prepare(struct qmi_dev *qmi, struct qmi_request *req, st
        qmi_set_nas_get_signal_info_request(msg);
        return QMI_CMD_REQUEST;
 }
+
+static void
+cmd_nas_get_serving_system_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
+{
+       struct qmi_nas_get_serving_system_response res;
+       static const char *reg_states[] = {
+               [QMI_NAS_REGISTRATION_STATE_NOT_REGISTERED] = "not_registered",
+               [QMI_NAS_REGISTRATION_STATE_REGISTERED] = "registered",
+               [QMI_NAS_REGISTRATION_STATE_NOT_REGISTERED_SEARCHING] = "searching",
+               [QMI_NAS_REGISTRATION_STATE_REGISTRATION_DENIED] = "registering_denied",
+               [QMI_NAS_REGISTRATION_STATE_UNKNOWN] = "unknown",
+       };
+
+       qmi_parse_nas_get_serving_system_response(msg, &res);
+
+       if (res.set.serving_system) {
+               int state = res.data.serving_system.registration_state;
+
+               if (state > QMI_NAS_REGISTRATION_STATE_UNKNOWN)
+                       state = QMI_NAS_REGISTRATION_STATE_UNKNOWN;
+
+               blobmsg_add_string(&status, "registration", reg_states[state]);
+       }
+       if (res.set.current_plmn) {
+               blobmsg_add_u32(&status, "plmn_mcc", res.data.current_plmn.mcc);
+               blobmsg_add_u32(&status, "plmn_mnc", res.data.current_plmn.mnc);
+               if (res.data.current_plmn.description)
+                       blobmsg_add_string(&status, "plmn_description", res.data.current_plmn.description);
+       }
+
+       if (res.set.roaming_indicator)
+               blobmsg_add_u8(&status, "roaming", !res.data.roaming_indicator);
+}
+
+static enum qmi_cmd_result
+cmd_nas_get_serving_system_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set_nas_get_serving_system_request(msg);
+       return QMI_CMD_REQUEST;
+}
index 6b5c05d33c3f260ca348d4845bc9cb4479be2881..2478bcfffac8d3cef303ae8b3f16e3d9cf7c5f1f 100644 (file)
@@ -1,11 +1,13 @@
 #define __uqmi_nas_commands \
        __uqmi_command(nas_set_network_modes, set-network-modes, required, QMI_SERVICE_NAS), \
        __uqmi_command(nas_initiate_network_register, network-register, no, QMI_SERVICE_NAS), \
-       __uqmi_command(nas_get_signal_info, get-signal-info, no, QMI_SERVICE_NAS) \
+       __uqmi_command(nas_get_signal_info, get-signal-info, no, QMI_SERVICE_NAS), \
+       __uqmi_command(nas_get_serving_system, get-serving-system, no, QMI_SERVICE_NAS) \
 
 #define nas_helptext \
                "  --set-network-modes <modes>:      Set preferred network mode (Syntax: <mode1>[,<mode2>,...])\n" \
                "                                    Available modes: all, lte, umts, gsm, cdma, td-scdma\n" \
                "  --network-register:               Initiate network register\n" \
-               "  --get-signal-info:                Get signal strength info\n"
+               "  --get-signal-info:                Get signal strength info\n" \
+               "  --get-serving-system:             Get serving system info\n" \