#include "qmi-message.h"
static struct qmi_nas_set_system_selection_preference_request sel_req;
+static struct {
+ bool mcc_is_set;
+ bool mnc_is_set;
+} plmn_code_flag;
#define cmd_nas_do_set_system_selection_cb no_cb
static enum qmi_cmd_result
return do_sel_network();
}
+#define cmd_nas_set_mcc_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_mcc_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ char *err;
+ int value = strtoul(arg, &err, 10);
+ if (err && *err) {
+ uqmi_add_error("Invalid MCC value");
+ return QMI_CMD_EXIT;
+ }
+
+ sel_req.data.network_selection_preference.mcc = value;
+ plmn_code_flag.mcc_is_set = true;
+ return QMI_CMD_DONE;
+}
+
+#define cmd_nas_set_mnc_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_mnc_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ char *err;
+ int value = strtoul(arg, &err, 10);
+ if (err && *err) {
+ uqmi_add_error("Invalid MNC value");
+ return QMI_CMD_EXIT;
+ }
+
+ sel_req.data.network_selection_preference.mnc = value;
+ plmn_code_flag.mnc_is_set = true;
+ return QMI_CMD_DONE;
+}
+
+#define cmd_nas_set_plmn_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_plmn_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+ sel_req.set.network_selection_preference = 1;
+ sel_req.data.network_selection_preference.mode = QMI_NAS_NETWORK_SELECTION_PREFERENCE_AUTOMATIC;
+
+ if (!plmn_code_flag.mcc_is_set && plmn_code_flag.mnc_is_set) {
+ uqmi_add_error("No MCC value");
+ return QMI_CMD_EXIT;
+ }
+
+ if (plmn_code_flag.mcc_is_set && sel_req.data.network_selection_preference.mcc) {
+ if (!plmn_code_flag.mnc_is_set) {
+ uqmi_add_error("No MNC value");
+ return QMI_CMD_EXIT;
+ } else {
+ sel_req.data.network_selection_preference.mode = QMI_NAS_NETWORK_SELECTION_PREFERENCE_MANUAL;
+ }
+ }
+
+ return do_sel_network();
+}
+
#define cmd_nas_initiate_network_register_cb no_cb
static enum qmi_cmd_result
cmd_nas_initiate_network_register_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
__uqmi_command(nas_do_set_system_selection, __set-system-selection, no, QMI_SERVICE_NAS), \
__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_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), \
__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), \
" Available modes: any, off, only\n" \
" --network-scan: Initiate network scan\n" \
" --network-register: Initiate network register\n" \
+ " --set-plmn: Register at specified network\n" \
+ " --mcc <mcc>: Mobile Country Code (0 - auto)\n" \
+ " --mnc <mnc>: Mobile Network Code\n" \
" --get-signal-info: Get signal strength info\n" \
" --get-serving-system: Get serving system info\n" \