Add 'modem ussd' commands.
This CL adds the following modem commands for modems supported by
ModemManager, which are exposed via crosh:
modem ussd status - Show the status of any ongoing USSD session
modem ussd initiate <command> - Initiate a USSD session
modem ussd respond <response> - Respond to a USSD request
modme ussd cancel - Cancel any ongoing USSD session
BUG=chromium:258403
TEST=Tested the crosh commands below with a Y3400 modem connected to T-Mobile:
modem ussd
modem ussd status
modem ussd initiate
modem ussd initiate #686#
modem ussd respond
modem ussd cancel
modem ussd bogus-command
Change-Id: I92e0cee193d5c2f383394644d9954df85a204d18
Reviewed-on: https://gerrit.chromium.org/gerrit/63312
Reviewed-by: Arman Uguray <[email protected]>
Commit-Queue: Ben Chan <[email protected]>
Tested-by: Ben Chan <[email protected]>
diff --git a/modem b/modem
index 0569da6..d8510e4 100755
--- a/modem
+++ b/modem
@@ -244,6 +244,44 @@
rm -f "${tmpfile}"
}
+ussd() {
+ local modem
+ local operation="$1"
+ local data="$2"
+
+ $(arg_or_default modem $(default_modem))
+ [ -z "${modem}" ] && error_exit "No modem found."
+
+ if ! is_mm1_modem "${modem}"; then
+ error_exit "USSD is not supported on this modem."
+ fi
+
+ if [ -z "${operation}" ]; then
+ echo "Valid USSD operations are: status, initiate, respond, cancel"
+ return
+ fi
+
+ case "${operation}" in
+ status)
+ mmcli -m "${modem}" --3gpp-ussd-status
+ ;;
+ initiate)
+ [ -z "${data}" ] && error_exit "Missing USSD data."
+ mmcli -m "${modem}" --3gpp-ussd-initiate="${data}"
+ ;;
+ respond)
+ [ -z "${data}" ] && error_exit "Missing USSD data."
+ mmcli -m "${modem}" --3gpp-ussd-respond="${data}"
+ ;;
+ cancel)
+ mmcli -m "${modem}" --3gpp-ussd-cancel
+ ;;
+ *)
+ error_exit "'${operation}' is not valid USSD operation."
+ ;;
+ esac
+}
+
set_carrier() {
local modem
@@ -332,7 +370,7 @@
}
usage() {
- echo "Usage: $0 <command> [args...]"
+ echo "Usage: $(basename $0) <command> [args...]"
echo " activate [-modem <modem>] [<carrier>] Activate modem"
echo " activate-manual [-modem <modem>] [args...] Activate modem manually"
echo " ciprl-update " \
@@ -352,6 +390,13 @@
"Enable and launch OMA session"
echo " status Display modem status"
echo " update-prl [-modem <modem>] <prl-file-name> Install a PRL file"
+ echo " ussd [-modem <modem>] status " \
+ "Show status of ongoing USSD session"
+ echo " ussd [-modem <modem>] initiate <command> Initiate a USSD session"
+ echo " ussd [-modem <modem>] respond <response> " \
+ "Respond to a USSD request"
+ echo " ussd [-modem <modem>] cancel " \
+ "Cancel ongoing USSD session"
exit 0
}
@@ -405,6 +450,9 @@
update-prl)
update_prl "$@"
;;
+ ussd)
+ ussd "$@"
+ ;;
*)
usage
;;