--- /dev/null
+static struct qmi_nas_set_system_selection_preference_request sel_req;
+
+#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)
+{
+ static const struct {
+ const char *name;
+ QmiNasRatModePreference val;
+ } modes[] = {
+ { "cdma", QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1X | QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1XEVDO },
+ { "td-scdma", QMI_NAS_RAT_MODE_PREFERENCE_TD_SCDMA },
+ { "gsm", QMI_NAS_RAT_MODE_PREFERENCE_GSM },
+ { "umts", QMI_NAS_RAT_MODE_PREFERENCE_UMTS },
+ { "lte", QMI_NAS_RAT_MODE_PREFERENCE_LTE },
+ };
+ QmiNasRatModePreference val = 0;
+ char *word;
+ int i;
+
+ for (word = strtok(arg, ",");
+ word;
+ word = strtok(NULL, ",")) {
+ bool found = false;
+
+ for (i = 0; i < ARRAY_SIZE(modes); i++) {
+ if (strcmp(word, modes[i].name) != 0 &&
+ strcmp(word, "all") != 0)
+ continue;
+
+ val |= modes[i].val;
+ found = true;
+ }
+
+ if (!found) {
+ fprintf(stderr, "Invalid network mode '%s'\n", word);
+ return QMI_CMD_EXIT;
+ }
+ }
+
+ qmi_set(&sel_req, mode_preference, val);
+ qmi_set_nas_set_system_selection_preference_request(msg, &sel_req);
+ return QMI_CMD_REQUEST;
+}
+
--- /dev/null
+#define __uqmi_nas_commands \
+ __uqmi_command(nas_set_network_modes, set-network-modes, required, 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"
+
#include "commands-wds.c"
#include "commands-dms.c"
+#include "commands-nas.c"
#define __uqmi_command(_name, _optname, _arg, _type) \
[__UQMI_COMMAND_##_name] = { \
#include <stdbool.h>
#include "commands-wds.h"
#include "commands-dms.h"
+#include "commands-nas.h"
enum qmi_cmd_result {
QMI_CMD_DONE,
__uqmi_command(set_client_id, set-client-id, required, CMD_TYPE_OPTION), \
__uqmi_command(get_client_id, get-client-id, required, QMI_SERVICE_CTL), \
__uqmi_wds_commands, \
- __uqmi_dms_commands
+ __uqmi_dms_commands, \
+ __uqmi_nas_commands
#define __uqmi_command(_name, _optname, _arg, _option) __UQMI_COMMAND_##_name
enum uqmi_command {