From 287465bb805369f523ade06add9f7ddc0af7352f Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 10 Jun 2013 17:09:10 +0200 Subject: [PATCH] unify multiple set_system_selection commands into one message, add --set-network-roaming --- commands-nas.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- commands-nas.h | 10 +++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/commands-nas.c b/commands-nas.c index 0eb6941..ccc58ab 100644 --- a/commands-nas.c +++ b/commands-nas.c @@ -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 diff --git a/commands-nas.h b/commands-nas.h index 44c25f3..4a4dace 100644 --- a/commands-nas.h +++ b/commands-nas.h @@ -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 : Set usable network modes (Syntax: [,,...])\n" \ " Available modes: all, lte, umts, gsm, cdma, td-scdma\n" \ - " --set-network-preference Set preferred network mode to \n" \ + " --set-network-preference : Set preferred network mode to \n" \ " Available modes: auto, gsm, wcdma\n" \ + " --set-network-roaming : 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" \ -- 2.25.1