nas: add --get-plmn
authorMartin Schiller <ms@dev.tdt.de>
Thu, 4 Jul 2019 11:35:37 +0000 (13:35 +0200)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 22 Nov 2020 21:07:29 +0000 (21:07 +0000)
This command is needed in the qmi proto handler to check if the plmn
is already set to 'auto'.

The reason for this is, that setting the plmn to 'auto' will implicitly
lead to a (delayed) network re-registration, which could further lead
to some timing related issues in the qmi proto handler.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
commands-nas.c
commands-nas.h

index 5874bfba505c4b9655b097500419aa2b681d4e63..1f7445d700aa5a6fa9874292084106971cbaba51 100644 (file)
@@ -292,6 +292,37 @@ cmd_nas_get_serving_system_prepare(struct qmi_dev *qmi, struct qmi_request *req,
        return QMI_CMD_REQUEST;
 }
 
+static void
+cmd_nas_get_plmn_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
+{
+       struct qmi_nas_get_system_selection_preference_response res;
+       static const char *modes[] = {
+               [QMI_NAS_NETWORK_SELECTION_PREFERENCE_AUTOMATIC] = "automatic",
+               [QMI_NAS_NETWORK_SELECTION_PREFERENCE_MANUAL] = "manual",
+       };
+       void *c;
+
+       qmi_parse_nas_get_system_selection_preference_response(msg, &res);
+
+       c = blobmsg_open_table(&status, NULL);
+       if (res.set.network_selection_preference) {
+               blobmsg_add_string(&status, "mode", modes[res.data.network_selection_preference]);
+       }
+       if (res.set.manual_network_selection) {
+               blobmsg_add_u32(&status, "mcc", res.data.manual_network_selection.mcc);
+               blobmsg_add_u32(&status, "mnc", res.data.manual_network_selection.mnc);
+       }
+
+       blobmsg_close_table(&status, c);
+}
+
+static enum qmi_cmd_result
+cmd_nas_get_plmn_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set_nas_get_system_selection_preference_request(msg);
+       return QMI_CMD_REQUEST;
+}
+
 static void
 cmd_nas_network_scan_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
 {
index 9ebfa0034625c6d850a9feb95ca8695dcaa50b65..4b175f9bf270308ea9e8bdf0e70864034b69dab6 100644 (file)
@@ -24,6 +24,7 @@
        __uqmi_command(nas_set_network_modes, set-network-modes, required, CMD_TYPE_OPTION), \
        __uqmi_command(nas_initiate_network_register, network-register, no, QMI_SERVICE_NAS), \
        __uqmi_command(nas_set_plmn, set-plmn, no, QMI_SERVICE_NAS), \
+       __uqmi_command(nas_get_plmn, get-plmn, no, QMI_SERVICE_NAS), \
        __uqmi_command(nas_set_mcc, mcc, required, CMD_TYPE_OPTION), \
        __uqmi_command(nas_set_mnc, mnc, required, CMD_TYPE_OPTION), \
        __uqmi_command(nas_network_scan, network-scan, no, QMI_SERVICE_NAS), \
@@ -44,6 +45,7 @@
                "  --set-plmn:                       Register at specified network\n" \
                "    --mcc <mcc>:                    Mobile Country Code (0 - auto)\n" \
                "    --mnc <mnc>:                    Mobile Network Code\n" \
+               "  --get-plmn:                       Get preferred network selection info\n" \
                "  --get-signal-info:                Get signal strength info\n" \
                "  --get-serving-system:             Get serving system info\n" \