unify multiple set_system_selection commands into one message, add --set-network...
authorFelix Fietkau <nbd@openwrt.org>
Mon, 10 Jun 2013 15:09:10 +0000 (17:09 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 10 Jun 2013 15:09:10 +0000 (17:09 +0200)
commands-nas.c
commands-nas.h

index 0eb6941fd42326031e9807745c6b53a702f32f0c..ccc58abd39728cab1b6a1356ef41c84269da2f8e 100644 (file)
@@ -2,6 +2,27 @@
 
 static struct qmi_nas_set_system_selection_preference_request sel_req;
 
+#define cmd_nas_do_set_system_selection_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_do_set_system_selection_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       qmi_set_nas_set_system_selection_preference_request(msg, &sel_req);
+       return QMI_CMD_REQUEST;
+}
+
+static enum qmi_cmd_result
+do_sel_network(void)
+{
+       static bool use_sel_req = false;
+
+       if (!use_sel_req) {
+               use_sel_req = true;
+               uqmi_add_command(NULL, __UQMI_COMMAND_nas_do_set_system_selection);
+       }
+
+       return QMI_CMD_DONE;
+}
+
 #define cmd_nas_set_network_modes_cb no_cb
 static enum qmi_cmd_result
 cmd_nas_set_network_modes_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
@@ -41,8 +62,7 @@ cmd_nas_set_network_modes_prepare(struct qmi_dev *qmi, struct qmi_request *req,
        }
 
        qmi_set(&sel_req, mode_preference, val);
-       qmi_set_nas_set_system_selection_preference_request(msg, &sel_req);
-       return QMI_CMD_REQUEST;
+       return do_sel_network();
 }
 
 #define cmd_nas_set_network_preference_cb no_cb
@@ -57,8 +77,26 @@ cmd_nas_set_network_preference_prepare(struct qmi_dev *qmi, struct qmi_request *
                pref = QMI_NAS_GSM_WCDMA_ACQUISITION_ORDER_PREFERENCE_WCDMA;
 
        qmi_set(&sel_req, gsm_wcdma_acquisition_order_preference, pref);
-       qmi_set_nas_set_system_selection_preference_request(msg, &sel_req);
-       return QMI_CMD_REQUEST;
+       return do_sel_network();
+}
+
+#define cmd_nas_set_roaming_cb no_cb
+static enum qmi_cmd_result
+cmd_nas_set_roaming_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       QmiNasRoamingPreference pref;
+
+       if (!strcmp(arg, "any"))
+               pref = QMI_NAS_ROAMING_PREFERENCE_ANY;
+       else if (!strcmp(arg, "only"))
+               pref = QMI_NAS_ROAMING_PREFERENCE_NOT_OFF;
+       else if (!strcmp(arg, "off"))
+               pref = QMI_NAS_ROAMING_PREFERENCE_OFF;
+       else
+               return uqmi_add_error("Invalid argument");
+
+       qmi_set(&sel_req, roaming_preference, pref);
+       return do_sel_network();
 }
 
 #define cmd_nas_initiate_network_register_cb no_cb
index 44c25f3b7052e33661a41022c669c3831dd42502..4a4dace89bda8f2e9200938c669dbe1952538f90 100644 (file)
@@ -1,16 +1,20 @@
 #define __uqmi_nas_commands \
-       __uqmi_command(nas_set_network_modes, set-network-modes, required, QMI_SERVICE_NAS), \
+       __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_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), \
-       __uqmi_command(nas_set_network_preference, set-network-preference, required, QMI_SERVICE_NAS) \
+       __uqmi_command(nas_set_network_preference, set-network-preference, required, CMD_TYPE_OPTION), \
+       __uqmi_command(nas_set_roaming, set-network-roaming, required, CMD_TYPE_OPTION) \
 
 #define nas_helptext \
                "  --set-network-modes <modes>:      Set usable network modes (Syntax: <mode1>[,<mode2>,...])\n" \
                "                                    Available modes: all, lte, umts, gsm, cdma, td-scdma\n" \
-               "  --set-network-preference <mode>   Set preferred network mode to <mode>\n" \
+               "  --set-network-preference <mode>:  Set preferred network mode to <mode>\n" \
                "                                    Available modes: auto, gsm, wcdma\n" \
+               "  --set-network-roaming <mode>:     Set roaming preference:\n" \
+               "                                    Available modes: any, off, only\n" \
                "  --network-scan:                   Initiate network scan\n" \
                "  --network-register:               Initiate network register\n" \
                "  --get-signal-info:                Get signal strength info\n" \